Open GoogleCodeExporter opened 9 years ago
http://support.microsoft.com/kb/214330
Original comment by garethte...@gmail.com
on 26 Oct 2010 at 2:10
Just the option to create it with or without would be ideal as 1904 dates are
valid in some cases, just not mine.
Thanks
Original comment by garethte...@gmail.com
on 26 Oct 2010 at 2:12
I have developed a solution to this issue that allows you to set the date mode
on the workbooks that you create with this ExcelLibrary.
1) In Workbook.cs, add the following property inside the Workbook class
definition:
public Int16 DateMode;
2) In WorkbookEncoder.cs, make the following changes inside the EncodeWorkbook
function:
Replace these two lines:
dateMode = 1;
sharedResource.BaseDate = DateTime.Parse("1904-01-01");
with
dateMode.Mode = workbook.DateMode;
sharedResource.BaseDate = workbook.DateMode == 1 ? DateTime.Parse("1904-01-01") : DateTime.Parse("1899-12-30");
3) This will allow you to choose either the 1904 date format (DateMode = 1) or
the 1900 date format (DateMode = 0) from your class that uses the ExcelLibrary
solution. For example, if your instance of your Workbook is called "workbook",
then you would set the property in the following way, anytime before you call
workbook.Save:
workbook.DateMode = 0;
Original comment by jamielmi...@gmail.com
on 17 Dec 2010 at 3:32
Why DateTime.Parse("1899-12-30") not DateTime.Parse("1900-01-01") for 1900 date
mode?
Original comment by China.LiuJunFeng
on 14 Apr 2011 at 12:24
Because excel thinks 1900 is a leap year, thus assuming it has one more day
than it really does. This cascades to make all dates miss by one day. Using
12/31/1989 is a way of compensating.
Original comment by Eric.Yar...@gmail.com
on 3 Aug 2011 at 3:45
Original issue reported on code.google.com by
garethte...@gmail.com
on 26 Oct 2010 at 2:06