Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

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