If I write Archive.WriteNumber(row,1,Now);
the current date is written to the spreadsheet, but, when the spreadsheet is opened, the value is 44295,3617921759. I want it to be formatted as today's date.
Unlike Excel, fpspreadsheet treats numbers and dates as different quantities, and there are different commands to write them to the worksheet. In order to write a date/time you must use one of the WriteDateTime overloads.
type
TsWorksheet = class(TsBasicWorksheet)
...
function WriteDateTime(ARow, ACol: Cardinal; AValue: TDateTime): PCell; overload;
procedure WriteDateTime(ACell: PCell; AValue: TDateTime); overload;
function WriteDateTime(ARow, ACol: Cardinal; AValue: TDateTime;
ANumFormat: TsNumberFormat; ANumFormatStr: String = ''): PCell; overload;
procedure WriteDateTime(ACell: PCell; AValue: TDateTime;
ANumFormat: TsNumberFormat; ANumFormatStr: String = ''); overload;
function WriteDateTime(ARow, ACol: Cardinal; AValue: TDateTime;
ANumFormatStr: String): PCell; overload;
procedure WriteDateTime(ACell: PCell; AValue: TDateTime;
ANumFormatStr: String); overload;
The NumFormat used here is one of the date/time nfXXXX constants (nfShortDateTime, nfShortDate, nfLongDate, nfShortTime, nfLongTime, nfShortTimeAM, nfLongTimeAM, nfDayMonth, nfMonthYear, nfTimeInterval), and the ANumFormatStr is a formatstring as used by FormatDateTime, such as 'dd/mm/yyyy',