Spire.XLS for .NET is a professional Excel .NET library that can be used to any type of .NET( C#, VB.NET, ASP.NET, .NET Core) application, both ASP.NET web sites and Windows Forms application.

Wed May 16, 2012 8:27 am

Hi,

i want to try export to excel with an empty Date or Datetime and
in the Excel File i become "-1" to show?!

What can i do for an empty Cell by an empty Date?

best regards Lars

lameb
 
Posts: 10
Joined: Mon Feb 20, 2012 2:39 pm

Thu May 17, 2012 7:45 am

Hi lameb,
We assumed that you are inserting to Excel cell with empty datatime value and then encouter this problem. Here we solve this problem by not insert any item to the cell if the datatime value is empty. Please check my codes below:
Code: Select all
 DateTime defaultdate=DateTime.Parse("0001-1-1 00:00:00");
            if (date!=defaultdate )
            {
                sheet.Range["A1"].DateTimeValue = date;
            }


Although it works fine in my side, but if you still have more information to present or any doubt about the solution, please feel free to contact us at anytime, we will try best to help you.

Regards
Eric
e-iceblue

Eric
 
Posts: 17
Joined: Tue Apr 24, 2012 4:53 am

Return to Spire.XLS