Ole Excel Delphi Date Problem
I have a Delphi application which reads data from an excel spreadsheet using code similar to the following:
procedure TForm1.Button1Click(Sender: TObject);
var
xlApp, xlWorkBook, xlWorkSheet, arr: Variant;
begin
xlApp := CreateOLEObject('Excel.Application');
xlApp.Visible := False;
xlWorkBook := xlApp.Workbooks.Open('C:\Temp\Book1.xlsx');
xlWorkSheet := xl开发者_Python百科App.WorkSheets[1];
arr := xlWorksheet.Range['E2:E2'].Value;
xlApp.Quit;
end;
The value stored in the spreadsheet in cell E2:E2 is 10/01/1900 (dd/mm/yyyy). However, the value being returned is the 09/01/1900, ie the day before. Why is this happening as when it seems to be working correctly for all dates in other years from 1900 onwards?
Pete, this problem is an old bug of excel, because excel incorrectly assumes that the year 1900 is a leap year. so all the dates between 01-01-1900
and 29-02-1900
are affected by this bug.
check these links for more info
- Dates And Times In Excel
- Excel 2000 incorrectly assumes that the year 1900 is a leap year
- http://www.inc.com/magazine/20080701/how-hard-could-it-be-glory-days.html
精彩评论