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:
wp_xxyyzz
2014-07-27 10:17:14 +00:00
parent 565df8a3e3
commit c3d3cac3bc
2 changed files with 16 additions and 16 deletions

View File

@ -92,6 +92,16 @@ begin
MyWorksheet.WriteDateTime(1, 5, now, nfShortTime);
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
MyWorkbook.WriteToFile(MyDir + 'test.xlsx', sfOOXML);
MyWorkbook.Free;

View File

@ -401,7 +401,8 @@ begin
// get style index
s := GetAttrValue(ANode, 's');
ApplyCellFormatting(cell, StrToInt(s));
if s <> '' then
ApplyCellFormatting(cell, StrToInt(s));
// get data
datanode := ANode.FirstChild;
@ -1828,17 +1829,11 @@ var
CellPosText: String;
CellValueText: String;
lStyleIndex: Integer;
lDateTime: TDateTime;
begin
Unused(AStream, ACell);
CellPosText := TsWorksheet.CellPosToText(ARow, ACol);
lStyleIndex := GetStyleIndex(ACell);
lDateTime := ConvertDateTimeToExcelDateTime(AValue, FDateMode);
// !!!!!!!!!!!!!!!!!!!!! NEED "IF" TO CHECK FOR DATE/TIME !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// CellValueText := Format('%g', [lDateTime], FPointSeparatorSettings);
CellValueText := FloatToStr(lDateTime, FPointSeparatorSettings);
CellValueText := FloatToStr(AValue, FPointSeparatorSettings);
AppendToStream(AStream, Format(
'<c r="%s" s="%d" t="n"><v>%s</v></c>', [CellPosText, lStyleIndex, CellValueText]));
end;
@ -1846,21 +1841,16 @@ end;
{*******************************************************************
* TsSpreadOOXMLWriter.WriteDateTime ()
*
* DESCRIPTION: Writes a date/time value as a text
* ISO 8601 format is used to preserve interoperability
* between locales.
*
* Note: this should be replaced by writing actual date/time values
*
* DESCRIPTION: Writes a date/time value as a number
* Respects DateMode of the file
*******************************************************************}
procedure TsSpreadOOXMLWriter.WriteDateTime(AStream: TStream;
const ARow, ACol: Cardinal; const AValue: TDateTime; ACell: PCell);
var
ExcelDateSerial: double;
begin
ExcelDateSerial := ConvertDateTimeToExcelDateTime(AValue, dm1900); //FDateMode);
ExcelDateSerial := ConvertDateTimeToExcelDateTime(AValue, FDateMode);
WriteNumber(AStream, ARow, ACol, ExcelDateSerial, ACell);
// WriteLabel(AStream, ARow, ACol, FormatDateTime(ISO8601Format, AValue), ACell);
end;
{