Reading Dates from excel prior to 1900 year

Hi Greetings!


We use Cells version 8.6.2 .

I have a requirement to read cell values into java Date and is working fine for the dates starting 01-01-1900, anything prior is being read as string from Cell.getValue/Cell.getDateTimeValue .

I am seeing below error
com.aspose.cells.DateTime incompatible with java.lang.String

Any suggestions ?

Thanks,
Ravi


Hi Ravi,


Thank you for contacting Aspose support.

I have evaluated the presented scenario while using the latest version of Aspose.Cells for Java 17.1.4, and I am able to notice CellsException: Not a DateTime value in Cell, if I try to read the date prior to 1900 using Cell.getDateTimeValue method. I have raised this incident as CELLSJAVA-42170 for further investigation.

That said, if I try to read such date using Cell.getValue method, the date can be read without any exception. Please try the scenario against the latest version (attached).

Hi again,


This is to update you that we have looked further into the matter logged earlier as CELLSJAVA-42170. Please note, it is the limitation of Excel application that it can only allow date time values starting from 1900-1-1. Please note, if you have any spreadsheet that shows date before than 1900-1-1 it is actually a string value. You can confirm this by changing the format of the cell to General. In case of valid date values, it will be converted to numeric value because Excel stores dates and times as a number representing the number of days since 1900-Jan-0, plus a fractional portion of a 24 hour day: ddddd.tttttt . This is called a serial date, or serial date-time. The integer portion of the number, ddddd, represents the number of days since 1900-Jan-0.

That said, Aspose.Cells APIs follow Excel’s guidelines and specifications in its processes therefore we have to close the ticket CELLSJAVA-42170 as Won’t Fix. Thank you for your understanding.