fpspreadsheet: Make sure that formulas are erased when new cell values are written by WorksheetGrid.Cells into cells containing formulas.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4432 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-01-18 13:35:48 +00:00
parent 638b34c693
commit 96ceb0a296

View File

@ -4452,35 +4452,44 @@ begin
end else end else
fmt := nil; fmt := nil;
if VarIsNull(AValue) then if VarIsNull(AValue) then begin
Worksheet.WriteBlank(r, c) cell := Worksheet.WriteBlank(r, c);
else if cell <> nil then cell^.FormulaValue := '';
if VarIsType(AValue, varDate) then
Worksheet.WriteDateTime(r, c, VarToDateTime(AValue))
else
if VarIsNumeric(AValue) then begin
if (cell <> nil) then begin
if IsDateTimeFormat(nfp) then
Worksheet.WriteDateTime(cell, VarToDateTime(AValue))
{
else if IsBoolFormat(nfp) then
Worksheet.WriteBoolValue(cell, not (AValue=0) )
else if IsErrorFormat(nfp) then
Worksheet.WriteErrorValue(r, c, round(AValue));
}
else
Worksheet.WriteNumber(cell, AValue);
end else
Worksheet.WriteNumber(r, c, AValue);
end else end else
if VarIsBool(AValue) then if VarIsStr(AValue) then
Worksheet.WriteBoolValue(r, c, AValue) begin
else
if VarIsStr(AValue) then begin
s := VarToStr(AValue); s := VarToStr(AValue);
if (s[1] = '=') then if s[1] = '=' then
Worksheet.WriteFormula(r, c, Copy(s, 2, Length(s)), true) else begin
Worksheet.WriteCellValueAsString(r, c, s); Worksheet.WriteFormula(r, c, Copy(s, 2, Length(s)), true);
exit;
end;
Worksheet.WriteCellValueAsString(r, c, s);
cell^.FormulaValue := '';
end else
begin
if cell <> nil then
cell^.FormulaValue := '';
if VarIsType(AValue, varDate) then
Worksheet.WriteDateTime(r, c, VarToDateTime(AValue))
else
if VarIsNumeric(AValue) then begin
if (cell <> nil) then begin
if IsDateTimeFormat(nfp) then
Worksheet.WriteDateTime(cell, VarToDateTime(AValue))
{
else if IsBoolFormat(nfp) then
Worksheet.WriteBoolValue(cell, not (AValue=0) )
else if IsErrorFormat(nfp) then
Worksheet.WriteErrorValue(r, c, round(AValue));
}
else
Worksheet.WriteNumber(cell, AValue);
end else
Worksheet.WriteNumber(r, c, AValue);
end else
if VarIsBool(AValue) then
Worksheet.WriteBoolValue(r, c, AValue)
end; end;
end; end;