We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

DateTime values read from cells off by 4 years and 1 day

I am using Aspose.Cells version for .NET 1.1. When reading a value from a cell using the following method, the value read represents a DateTime that is 4 years and one day less than the value in the cell.

Aspose.Cells.Cells cells = new Cells();
string result = cells[row, column].StringValue;

This only occurs when the file in question is an Excel 97/2003 Workbook
(as far as I can tell). If I save the file in the CSV format, the value
read is correct.

We are using the StringValue property instead of the DateTimeValue property because each cell value may be wrapped with a =" on the left and " on the right to force certain types of data to be read as strings.

So we may put a value such as the one that follows in a “DateTime” cell:


However, when we read such a value with the StringValue property, we get the following:


Please see the attached file to reproduce the problem. Columns K an O both have multiple dates which all exhibit the same off by 4 years and 1 day phenomenon.

Thanks for you help,

Hi Michael,

Thanks for providing us the template file.

Well, I have checked your template file, your template file is set for 1904 date system as its workbook options i.e..., Open your template file into MS Excel (97-2003), Click "Tools" menu and select "Options....", now click Calculation tab and you can see 1904 date system is checked. Therefore, the dates that are displayed in MS Excel are increased by 4 years or so. If you could turn this option off, you may find that Aspose.Cells is actually showing the date values just fine.

You can also programatically turn this options off:

Workbook workbook = new Workbook();
workbook.Date1904 = false;

Thank you.