MS Excel (.xls) + DATEMODE

Век живи, век учись.

Оказывается в заголовке xld-файла может храниться запись с тегом DATEMODE (=0×0022), которая определяет начальную дату, от которой ведут отсчет все значения-даты, хранимые в этом файле.

Например, отображается дата 25-Jan-2007, а на самом деле хранится в файле 24-Jan-2003

DATEMODE (0022H, BIFF2-BIFF8)
This record specifies the base date for displaying date values. All dates are stored as count of days past this base date. In BIFF2-BIFF4 this record is part of the Calculation Settings Block (➜5.3). In BIFF5-BIFF8 it is stored in the Workbook Globals Substream.

Offset Size Contents
0 2 0 = Base date is 1899-Dec-31 (the cell value 1 represents 1900-Jan-01)
1 = Base date is 1904-Jan-01 (the cell value 1 represents 1904-Jan-02)

Сейчас поправил свой парсер и такие левые файлы обрабатываются уже правильно. Кому понадобилось исчислять даты от 1904-Jan-01 можно только догадываться…

Leave a Reply

You must be logged in to post a comment.