fpspreadsheet: Write string formulas to ods files.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3457 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-08-08 19:14:08 +00:00
parent a0a19eb380
commit 755a36e055

View File

@ -3213,21 +3213,6 @@ begin
end;
*)
procedure TsSpreadOpenDocWriter.WriteFormula(AStream: TStream; const ARow,
ACol: Cardinal; const AFormula: TsFormula; ACell: PCell);
begin
Unused(AStream, ARow, ACol);
Unused(AFormula, ACell);
{ // The row should already be the correct one
FContent := FContent +
' <table:table-cell office:value-type="string">' + LineEnding +
' <text:p>' + AFormula.DoubleValue + '</text:p>' + LineEnding +
' </table:table-cell>' + LineEnding;
<table:table-cell table:formula="of:=[.A1]+[.B2]" office:value-type="float" office:value="1833">
<text:p>1833</text:p>
</table:table-cell>}
end;
{
Writes an empty cell
@ -3623,6 +3608,47 @@ begin
Result := '';
end;
{ Writes a string formula }
procedure TsSpreadOpenDocWriter.WriteFormula(AStream: TStream; const ARow,
ACol: Cardinal; const AFormula: TsFormula; ACell: PCell);
var
lStyle: String = '';
lIndex: Integer;
begin
Unused(AStream, ARow, ACol);
Unused(AFormula, ACell);
if ACell^.UsedFormattingFields <> [] then begin
lIndex := FindFormattingInList(ACell);
lStyle := ' table:style-name="ce' + IntToStr(lIndex) + '" ';
end else
lStyle := '';
// We are writing a very rudimentary formula here without result and result
// data type. Seems to work...
AppendToStream(AStream, Format(
'<table:table-cell table:formula="%s" %s>' +
'</table:table-cell>', [
ACell^.FormulaValue.FormulaStr, lStyle
]));
{
<table:table-cell table:formula="of:=[.A1]" office:value-type="time" office:time-value="PT982093H14M15.566999875S" calcext:value-type="time">
<text:p>982093:14:16</text:p>
</table:table-cell>
}
{ // The row should already be the correct one
FContent := FContent +
' <table:table-cell office:value-type="string">' + LineEnding +
' <text:p>' + AFormula.DoubleValue + '</text:p>' + LineEnding +
' </table:table-cell>' + LineEnding;
<table:table-cell table:formula="of:=[.A1]+[.B2]" office:value-type="float" office:value="1833">
<text:p>1833</text:p>
</table:table-cell>}
end;
{
Writes a cell with text content