diff --git a/components/fpspreadsheet/tests/testbiff8_1899.xls b/components/fpspreadsheet/tests/testbiff8_1899.xls index c4af4f2e4..0e5058050 100644 Binary files a/components/fpspreadsheet/tests/testbiff8_1899.xls and b/components/fpspreadsheet/tests/testbiff8_1899.xls differ diff --git a/components/fpspreadsheet/tests/testbiff8_1904.xls b/components/fpspreadsheet/tests/testbiff8_1904.xls index 3e01305a8..afd8dfe46 100644 Binary files a/components/fpspreadsheet/tests/testbiff8_1904.xls and b/components/fpspreadsheet/tests/testbiff8_1904.xls differ diff --git a/components/fpspreadsheet/tests/testodf_1899.ods b/components/fpspreadsheet/tests/testodf_1899.ods index 15f28cf6b..abe07c4f2 100644 Binary files a/components/fpspreadsheet/tests/testodf_1899.ods and b/components/fpspreadsheet/tests/testodf_1899.ods differ diff --git a/components/fpspreadsheet/tests/testodf_1904.ods b/components/fpspreadsheet/tests/testodf_1904.ods index 8d1c9adda..9e1b21e14 100644 Binary files a/components/fpspreadsheet/tests/testodf_1904.ods and b/components/fpspreadsheet/tests/testodf_1904.ods differ diff --git a/components/fpspreadsheet/tests/testooxml_1899.xlsx b/components/fpspreadsheet/tests/testooxml_1899.xlsx index 6d3b1fa7c..4ff383c19 100644 Binary files a/components/fpspreadsheet/tests/testooxml_1899.xlsx and b/components/fpspreadsheet/tests/testooxml_1899.xlsx differ diff --git a/components/fpspreadsheet/tests/testooxml_1904.xlsx b/components/fpspreadsheet/tests/testooxml_1904.xlsx index e2d970e1e..aa3da7ba2 100644 Binary files a/components/fpspreadsheet/tests/testooxml_1904.xlsx and b/components/fpspreadsheet/tests/testooxml_1904.xlsx differ diff --git a/components/fpspreadsheet/xlscommon.pas b/components/fpspreadsheet/xlscommon.pas index 45865d742..83dc528fe 100644 --- a/components/fpspreadsheet/xlscommon.pas +++ b/components/fpspreadsheet/xlscommon.pas @@ -1197,6 +1197,12 @@ var err: TsErrorValue; ok: Boolean; cell: PCell; + + + + + + fmt: TsCellFormat; begin { Index to XF Record } ReadRowColXF(AStream, ARow, ACol, XF); @@ -1217,7 +1223,9 @@ begin InitCell(ARow, ACol, FVirtualCell); cell := @FVirtualCell; end else - cell := FWorksheet.AddCell(ARow, ACol); // "Real" cell + cell := FWorksheet.GetCell(ARow, ACol); // "Real" cell + // Don't call "AddCell" because, if the cell belongs to a shared formula, it + // already has been created before, and then would exist in the tree twice. // Now determine the type of the formula result if (Data[6] = $FF) and (Data[7] = $FF) then @@ -1243,9 +1251,9 @@ begin {Find out what cell type, set content type and value} ExtractNumberFormat(XF, nf, nfs); if IsDateTime(ResultFormula, nf, nfs, dt) then - FWorksheet.WriteDateTime(cell, dt, nf, nfs) + FWorksheet.WriteDateTime(cell, dt) //, nf, nfs) else - FWorksheet.WriteNumber(cell, ResultFormula, nf, nfs); + FWorksheet.WriteNumber(cell, ResultFormula); //, nf, nfs); end; { Formula token array } @@ -2025,7 +2033,9 @@ begin InitCell(r1, c1, FVirtualCell); cell := @FVirtualCell; end else - cell := FWorksheet.AddCell(r1, c1); // "Real" cell + cell := FWorksheet.GetCell(r1, c1); // "Real" cell + // Don't use "AddCell" here because this cell already exists in files written + // by Excel, and this would destroy its formatting. // Unused AStream.ReadByte;