You've already forked lazarus-ccr
fpspreadsheet: Fix reading of shared formulas in xls files (bug introduced by the new calculation engine).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6584 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1887,33 +1887,40 @@ begin
|
|||||||
// Don't call "AddCell" because, if the cell belongs to a shared formula, it
|
// 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.
|
// already has been created before, and then would exist in the tree twice.
|
||||||
|
|
||||||
// Now determine the type of the formula result
|
// Prevent shared formulas (which already may have been written at this time)
|
||||||
if (Data[6] = $FF) and (Data[7] = $FF) then
|
// being erased when cell content is written
|
||||||
case Data[0] of
|
TsWorkbook(sheet.Workbook).LockFormulas;
|
||||||
0: // String -> Value is found in next record (STRING)
|
try
|
||||||
FIncompleteCell := cell;
|
// Now determine the type of the formula result
|
||||||
|
if (Data[6] = $FF) and (Data[7] = $FF) then
|
||||||
|
case Data[0] of
|
||||||
|
0: // String -> Value is found in next record (STRING)
|
||||||
|
FIncompleteCell := cell;
|
||||||
|
|
||||||
1: // Boolean value
|
1: // Boolean value
|
||||||
sheet.WriteBoolValue(cell, Data[2] = 1);
|
sheet.WriteBoolValue(cell, Data[2] = 1);
|
||||||
|
|
||||||
2: begin // Error value
|
2: begin // Error value
|
||||||
err := ConvertFromExcelError(Data[2]);
|
err := ConvertFromExcelError(Data[2]);
|
||||||
sheet.WriteErrorValue(cell, err);
|
sheet.WriteErrorValue(cell, err);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
3: sheet.WriteBlank(cell);
|
3: sheet.WriteBlank(cell);
|
||||||
end
|
end
|
||||||
else
|
|
||||||
begin
|
|
||||||
// Result is a number or a date/time
|
|
||||||
Move(Data[0], ResultFormula, SizeOf(Data));
|
|
||||||
|
|
||||||
{Find out what cell type, set content type and value}
|
|
||||||
ExtractNumberFormat(XF, nf, nfs);
|
|
||||||
if IsDateTime(ResultFormula, nf, nfs, dt) then
|
|
||||||
sheet.WriteDateTime(cell, dt) //, nf, nfs)
|
|
||||||
else
|
else
|
||||||
sheet.WriteNumber(cell, ResultFormula);
|
begin
|
||||||
|
// Result is a number or a date/time
|
||||||
|
Move(Data[0], ResultFormula, SizeOf(Data));
|
||||||
|
|
||||||
|
{Find out what cell type, set content type and value}
|
||||||
|
ExtractNumberFormat(XF, nf, nfs);
|
||||||
|
if IsDateTime(ResultFormula, nf, nfs, dt) then
|
||||||
|
sheet.WriteDateTime(cell, dt) //, nf, nfs)
|
||||||
|
else
|
||||||
|
sheet.WriteNumber(cell, ResultFormula);
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
TsWorkbook(sheet.Workbook).UnlockFormulas;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Formula token array }
|
{ Formula token array }
|
||||||
|
Reference in New Issue
Block a user