You've already forked lazarus-ccr
fpspreadsheet: Fix incorrect writing of number and date/time values in ooxlm. Only 1 fail in unit test left (related to ods).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3385 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -92,6 +92,16 @@ begin
|
|||||||
MyWorksheet.WriteDateTime(1, 5, now, nfShortTime);
|
MyWorksheet.WriteDateTime(1, 5, now, nfShortTime);
|
||||||
MyWorksheet.WriteDateTime(2, 5, now, 'nn:ss.zzz');
|
MyWorksheet.WriteDateTime(2, 5, now, 'nn:ss.zzz');
|
||||||
|
|
||||||
|
// Write some numbers in various formats
|
||||||
|
MyWorksheet.WriteNumber(0, 6, 12345.6789, nfFixed, 0);
|
||||||
|
MyWorksheet.WriteNumber(1, 6, 12345.6789, nfFixed, 3);
|
||||||
|
MyWorksheet.WriteNumber(2, 6, 12345.6789, nfFixedTh, 0);
|
||||||
|
MyWorksheet.Writenumber(3, 6, 12345.6789, nfFixedTh, 3);
|
||||||
|
MyWorksheet.WriteNumber(4, 6, 12345.6789, nfExp, 2);
|
||||||
|
Myworksheet.Writenumber(5, 6, 12345.6789, nfExp, 4);
|
||||||
|
MyWorksheet.WriteCurrency(6, 6,-12345.6789, nfCurrency, 2);
|
||||||
|
MyWorksheet.WriteCurrency(7, 6,-12345.6789, nfCurrencyRed, 2);
|
||||||
|
|
||||||
// Save the spreadsheet to a file
|
// Save the spreadsheet to a file
|
||||||
MyWorkbook.WriteToFile(MyDir + 'test.xlsx', sfOOXML);
|
MyWorkbook.WriteToFile(MyDir + 'test.xlsx', sfOOXML);
|
||||||
MyWorkbook.Free;
|
MyWorkbook.Free;
|
||||||
|
@ -401,7 +401,8 @@ begin
|
|||||||
|
|
||||||
// get style index
|
// get style index
|
||||||
s := GetAttrValue(ANode, 's');
|
s := GetAttrValue(ANode, 's');
|
||||||
ApplyCellFormatting(cell, StrToInt(s));
|
if s <> '' then
|
||||||
|
ApplyCellFormatting(cell, StrToInt(s));
|
||||||
|
|
||||||
// get data
|
// get data
|
||||||
datanode := ANode.FirstChild;
|
datanode := ANode.FirstChild;
|
||||||
@ -1828,17 +1829,11 @@ var
|
|||||||
CellPosText: String;
|
CellPosText: String;
|
||||||
CellValueText: String;
|
CellValueText: String;
|
||||||
lStyleIndex: Integer;
|
lStyleIndex: Integer;
|
||||||
lDateTime: TDateTime;
|
|
||||||
begin
|
begin
|
||||||
Unused(AStream, ACell);
|
Unused(AStream, ACell);
|
||||||
CellPosText := TsWorksheet.CellPosToText(ARow, ACol);
|
CellPosText := TsWorksheet.CellPosToText(ARow, ACol);
|
||||||
lStyleIndex := GetStyleIndex(ACell);
|
lStyleIndex := GetStyleIndex(ACell);
|
||||||
lDateTime := ConvertDateTimeToExcelDateTime(AValue, FDateMode);
|
CellValueText := FloatToStr(AValue, FPointSeparatorSettings);
|
||||||
// !!!!!!!!!!!!!!!!!!!!! NEED "IF" TO CHECK FOR DATE/TIME !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
|
|
||||||
// CellValueText := Format('%g', [lDateTime], FPointSeparatorSettings);
|
|
||||||
CellValueText := FloatToStr(lDateTime, FPointSeparatorSettings);
|
|
||||||
|
|
||||||
AppendToStream(AStream, Format(
|
AppendToStream(AStream, Format(
|
||||||
'<c r="%s" s="%d" t="n"><v>%s</v></c>', [CellPosText, lStyleIndex, CellValueText]));
|
'<c r="%s" s="%d" t="n"><v>%s</v></c>', [CellPosText, lStyleIndex, CellValueText]));
|
||||||
end;
|
end;
|
||||||
@ -1846,21 +1841,16 @@ end;
|
|||||||
{*******************************************************************
|
{*******************************************************************
|
||||||
* TsSpreadOOXMLWriter.WriteDateTime ()
|
* TsSpreadOOXMLWriter.WriteDateTime ()
|
||||||
*
|
*
|
||||||
* DESCRIPTION: Writes a date/time value as a text
|
* DESCRIPTION: Writes a date/time value as a number
|
||||||
* ISO 8601 format is used to preserve interoperability
|
* Respects DateMode of the file
|
||||||
* between locales.
|
|
||||||
*
|
|
||||||
* Note: this should be replaced by writing actual date/time values
|
|
||||||
*
|
|
||||||
*******************************************************************}
|
*******************************************************************}
|
||||||
procedure TsSpreadOOXMLWriter.WriteDateTime(AStream: TStream;
|
procedure TsSpreadOOXMLWriter.WriteDateTime(AStream: TStream;
|
||||||
const ARow, ACol: Cardinal; const AValue: TDateTime; ACell: PCell);
|
const ARow, ACol: Cardinal; const AValue: TDateTime; ACell: PCell);
|
||||||
var
|
var
|
||||||
ExcelDateSerial: double;
|
ExcelDateSerial: double;
|
||||||
begin
|
begin
|
||||||
ExcelDateSerial := ConvertDateTimeToExcelDateTime(AValue, dm1900); //FDateMode);
|
ExcelDateSerial := ConvertDateTimeToExcelDateTime(AValue, FDateMode);
|
||||||
WriteNumber(AStream, ARow, ACol, ExcelDateSerial, ACell);
|
WriteNumber(AStream, ARow, ACol, ExcelDateSerial, ACell);
|
||||||
// WriteLabel(AStream, ARow, ACol, FormatDateTime(ISO8601Format, AValue), ACell);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user