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.

Thu Apr 27, 2017 6:21 pm

When I use Spire.XLS to read data from an XLSX file, and a particular cell contains a DATE value, the I actually get is an integer like "42,855".

How do I convert that value back into a date?

I understand that the value is supposed to represent the number of days since Jan-1,1900, but the results I get are several days off, like it's not correctly accounting for leap year or something like that.

mfulton
 
Posts: 2
Joined: Wed Jan 25, 2017 6:41 pm

Fri Apr 28, 2017 2:43 am

Dear mfulton,

Thanks for your inquiry.
After an initial test, sorry that I didn't find the issue you mentioned.
Please provide us with the sample file and code you were using for testing.

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Thu May 04, 2017 5:13 pm

The attached file contains a VS2017 project that demonstrates the problem.

The dates in column "D" are printed as integer numbers.
Attachments
ExcelDateTest.zip
(59.54 KiB) Downloaded 335 times

mfulton
 
Posts: 2
Joined: Wed Jan 25, 2017 6:41 pm

Fri May 05, 2017 2:41 am

Dear Mike,

Many thanks for the detail.
I checked the project you provided, and found you override Spire.XLS and then use the new dll(Excel).
I suppose the method cell.Text in your code is the method range.NumberValue in Spire.XLS. Please change to range.NumberText to get that date.
If there is any question, please let me know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.XLS