fpspreadsheet: Add Excel XML reading support for missing cell-based conditional formats. Fix lost "max compatibility" flag of packages.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7550 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-07-18 15:57:19 +00:00
parent 2793744bf7
commit acb49d9590
8 changed files with 504 additions and 233 deletions

View File

@ -34,280 +34,281 @@
This package is all you need if you don't want graphical components (like grids and charts)."/>
<License Value="LGPL with static linking exception. This is the same license as is used in the LCL (Lazarus Component Library)."/>
<Version Major="1" Minor="13"/>
<Files>
<Item>
<Files Count="55">
<Item1>
<Filename Value="source\fps.inc"/>
<Type Value="Include"/>
</Item>
<Item>
</Item1>
<Item2>
<Filename Value="source\common\fpolebasic.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpolebasic"/>
</Item>
<Item>
</Item2>
<Item3>
<Filename Value="source\common\fpolestorage.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpolestorage"/>
</Item>
<Item>
</Item3>
<Item4>
<Filename Value="source\common\fpsallformats.pas"/>
<UnitName Value="fpsallformats"/>
</Item>
<Item>
</Item4>
<Item5>
<Filename Value="source\common\fpscell.pas"/>
<UnitName Value="fpsCell"/>
</Item>
<Item>
</Item5>
<Item6>
<Filename Value="source\common\fpsclasses.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpsclasses"/>
</Item>
<Item>
</Item6>
<Item7>
<Filename Value="source\common\fpscsv.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpscsv"/>
</Item>
<Item>
</Item7>
<Item8>
<Filename Value="source\common\fpscsvdocument.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpsCsvDocument"/>
</Item>
<Item>
</Item8>
<Item9>
<Filename Value="source\common\fpscurrency.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpsCurrency"/>
</Item>
<Item>
</Item9>
<Item10>
<Filename Value="source\common\fpsexprparser.pas"/>
<UnitName Value="fpsExprParser"/>
</Item>
<Item>
</Item10>
<Item11>
<Filename Value="source\common\fpsfunc.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpsfunc"/>
</Item>
<Item>
</Item11>
<Item12>
<Filename Value="source\common\fpsheaderfooterparser.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpsHeaderFooterParser"/>
</Item>
<Item>
</Item12>
<Item13>
<Filename Value="source\common\fpshtml.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpsHTML"/>
</Item>
<Item>
</Item13>
<Item14>
<Filename Value="source\common\fpshtmlutils.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpsHTMLUtils"/>
</Item>
<Item>
</Item14>
<Item15>
<Filename Value="source\common\fpsimages.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpsImages"/>
</Item>
<Item>
</Item15>
<Item16>
<Filename Value="source\common\fpsnumformat.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpsNumFormat"/>
</Item>
<Item>
</Item16>
<Item17>
<Filename Value="source\common\fpsopendocument.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpsopendocument"/>
</Item>
<Item>
</Item17>
<Item18>
<Filename Value="source\common\fpspagelayout.pas"/>
<UnitName Value="fpsPageLayout"/>
</Item>
<Item>
</Item18>
<Item19>
<Filename Value="source\common\fpspalette.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpsPalette"/>
</Item>
<Item>
</Item19>
<Item20>
<Filename Value="source\common\fpspatches.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpspatches"/>
</Item>
<Item>
</Item20>
<Item21>
<Filename Value="source\common\fpspreadsheet.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpspreadsheet"/>
</Item>
<Item>
</Item21>
<Item22>
<Filename Value="source\common\fpsreaderwriter.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpsReaderWriter"/>
</Item>
<Item>
</Item22>
<Item23>
<Filename Value="source\common\fpsrpn.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpsRPN"/>
</Item>
<Item>
</Item23>
<Item24>
<Filename Value="source\common\fpsstreams.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpsStreams"/>
</Item>
<Item>
</Item24>
<Item25>
<Filename Value="source\common\fpsstrings.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpsStrings"/>
</Item>
<Item>
</Item25>
<Item26>
<Filename Value="source\common\fpstypes.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpsTypes"/>
</Item>
<Item>
</Item26>
<Item27>
<Filename Value="source\common\fpsutils.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpsutils"/>
</Item>
<Item>
</Item27>
<Item28>
<Filename Value="source\common\fpsxmlcommon.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpsxmlcommon"/>
</Item>
<Item>
</Item28>
<Item29>
<Filename Value="source\common\fpszipper.pp"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="fpszipper"/>
</Item>
<Item>
</Item29>
<Item30>
<Filename Value="source\common\uvirtuallayer.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="uvirtuallayer"/>
</Item>
<Item>
</Item30>
<Item31>
<Filename Value="source\common\uvirtuallayer_ole.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="uvirtuallayer_ole"/>
</Item>
<Item>
</Item31>
<Item32>
<Filename Value="source\common\uvirtuallayer_ole_helpers.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="uvirtuallayer_ole_helpers"/>
</Item>
<Item>
</Item32>
<Item33>
<Filename Value="source\common\uvirtuallayer_ole_types.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="uvirtuallayer_ole_types"/>
</Item>
<Item>
</Item33>
<Item34>
<Filename Value="source\common\uvirtuallayer_stream.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="uvirtuallayer_stream"/>
</Item>
<Item>
</Item34>
<Item35>
<Filename Value="source\common\uvirtuallayer_types.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="uvirtuallayer_types"/>
</Item>
<Item>
</Item35>
<Item36>
<Filename Value="source\common\wikitable.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="wikitable"/>
</Item>
<Item>
</Item36>
<Item37>
<Filename Value="source\common\xlsbiff2.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="xlsbiff2"/>
</Item>
<Item>
</Item37>
<Item38>
<Filename Value="source\common\xlsbiff5.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="xlsbiff5"/>
</Item>
<Item>
</Item38>
<Item39>
<Filename Value="source\common\xlsbiff8.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="xlsbiff8"/>
</Item>
<Item>
</Item39>
<Item40>
<Filename Value="source\common\xlscommon.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="xlscommon"/>
</Item>
<Item>
</Item40>
<Item41>
<Filename Value="source\common\xlsconst.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="xlsconst"/>
</Item>
<Item>
</Item41>
<Item42>
<Filename Value="source\common\xlsescher.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="xlsEscher"/>
</Item>
<Item>
</Item42>
<Item43>
<Filename Value="source\common\xlsxml.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="xlsxml"/>
</Item>
<Item>
</Item43>
<Item44>
<Filename Value="source\common\xlsxooxml.pas"/>
<AddToUsesPkgSection Value="False"/>
<UnitName Value="xlsxooxml"/>
</Item>
<Item>
</Item44>
<Item45>
<Filename Value="source\common\fpssearch.pas"/>
<UnitName Value="fpsSearch"/>
</Item>
<Item>
</Item45>
<Item46>
<Filename Value="source\common\fpscrypto.pas"/>
<UnitName Value="fpsCrypto"/>
</Item>
<Item>
</Item46>
<Item47>
<Filename Value="source\common\fpsconditionalformat.pas"/>
<UnitName Value="fpsConditionalFormat"/>
</Item>
<Item>
</Item47>
<Item48>
<Filename Value="source\common\fpspreadsheet_cf.inc"/>
<Type Value="Binary"/>
</Item>
<Item>
</Item48>
<Item49>
<Filename Value="source\common\fpspreadsheet_fmt.inc"/>
<Type Value="Binary"/>
</Item>
<Item>
</Item49>
<Item50>
<Filename Value="source\common\fpspreadsheet_hyperlinks.inc"/>
<Type Value="Binary"/>
</Item>
<Item>
</Item50>
<Item51>
<Filename Value="source\common\fpspreadsheet_comments.inc"/>
<Type Value="Binary"/>
</Item>
<Item>
</Item51>
<Item52>
<Filename Value="source\common\fpspreadsheet_embobj.inc"/>
<Type Value="Binary"/>
</Item>
<Item>
</Item52>
<Item53>
<Filename Value="source\common\fpspreadsheet_numfmt.inc"/>
<Type Value="Binary"/>
</Item>
<Item>
</Item53>
<Item54>
<Filename Value="source\common\fpspreadsheet_fonts.inc"/>
<Type Value="Binary"/>
</Item>
<Item>
</Item54>
<Item55>
<Filename Value="source\common\fpspreadsheet_clipbrd.inc"/>
<Type Value="Binary"/>
</Item>
</Item55>
</Files>
<CompatibilityMode Value="True"/>
<i18n>
<EnableI18N Value="True"/>
<OutDir Value="languages"/>
<EnableI18NForLFM Value="True"/>
</i18n>
<RequiredPkgs>
<Item>
<RequiredPkgs Count="2">
<Item1>
<PackageName Value="LazUtils"/>
</Item>
<Item>
</Item1>
<Item2>
<PackageName Value="FCL"/>
<MinVersion Major="1" Valid="True"/>
</Item>
</Item2>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>

View File

@ -24,6 +24,7 @@
<UnitName Value="xlsxooxml_crypto"/>
</Item2>
</Files>
<CompatibilityMode Value="True"/>
<RequiredPkgs Count="3">
<Item1>
<PackageName Value="dcpcrypt"/>

View File

@ -43,6 +43,7 @@ It provides graphical components like a grid and chart."/>
<UnitName Value="fpsActions"/>
</Item5>
</Files>
<CompatibilityMode Value="True"/>
<RequiredPkgs Count="4">
<Item1>
<PackageName Value="laz_fpspreadsheet"/>

View File

@ -24,6 +24,7 @@
<UnitName Value="fpsvisualreg"/>
</Item1>
</Files>
<CompatibilityMode Value="True"/>
<RequiredPkgs Count="2">
<Item1>
<PackageName Value="laz_fpspreadsheet_visual"/>

View File

@ -37,6 +37,7 @@ It provides a graphical export component on the Data Export tab."/>
<UnitName Value="fpsexportreg"/>
</Item2>
</Files>
<CompatibilityMode Value="True"/>
<RequiredPkgs Count="4">
<Item1>
<PackageName Value="lazdbexport"/>

View File

@ -1156,6 +1156,7 @@ var
C: Char;
S: String;
ok: Boolean;
baseCol, baseRow: Cardinal;
begin
C := CurrentChar;
isQuoted := C = '''';
@ -1175,8 +1176,16 @@ begin
end;
if (FParser.Dialect = fdExcelR1C1) then begin
if FParser.FDestCell = nil then begin
baseRow := 0;
baseCol := 0;
end else
begin
baseRow := FParser.FDestCell^.Row;
baseCol := FParser.FDestCell^.Col;
end;
ok := ParseCellRangeString_R1C1(FToken,
FParser.FDestCell^.Row, FParser.FDestCell^.Col,
baseRow, baseCol,
FSheet1, FSheet2,
FCellRange.Row1, FCellRange.Col1, FCellRange.Row2, FCellRange.Col2,
FFlags)

View File

@ -95,8 +95,10 @@ type
procedure WriteConditionalFormat(AStream: TStream; AWorksheet: TsBasicWorksheet;
AFormat: TsConditionalFormat);
procedure WriteConditionalFormatting(AStream: TStream; AWorksheet: TsBasicWorksheet);
procedure WriteDocumentProperties(AStream: TStream);
procedure WriteExcelWorkbook(AStream: TStream);
procedure WriteNames(AStream: TStream; AWorksheet: TsBasicWorksheet);
procedure WriteOfficeDocumentSettings(AStream: TStream);
procedure WritePageBreaks(AStream: TStream; AWorksheet: TsBasicWorksheet);
procedure WriteRows(AStream: TStream; AWorksheet: TsBasicWorksheet);
procedure WriteStyle(AStream: TStream; AIndex: Integer);
@ -225,11 +227,11 @@ const
'Equal', 'NotEqual', // cfcEqual, cfcNotEqual,
'Greater', 'Less', 'GreaterOrEqual', 'LessOrEqual', // cfcGreaterThan, cfcLessThan, cfcGreaterEqual, cfcLessEqual,
'Between', 'NotBetween', // cfcBetween, cfcNotBetween,
// the following 4 formulas are copies of Excel-generated files, but do not work...
'', //'@RC&gt;AVERAGE( IF(ISERROR(%2:s), &quot;&quot;, IF(ISBLANK(%2:s), &quot;&quot;, %2:s)))', // cfcAboveAverage
'', //'@RC&lt;AVERAGE( IF(ISERROR(%2:s), &quot;&quot;, IF(ISBLANK(%2:s), &quot;&quot;, %2:s)))', // cfcBelowAverage
'', //'@RC&gt;=AVERAGE( IF(ISERROR(%2:s), &quot;&quot;, IF(ISBLANK(%2:s), &quot;&quot;, %2:s)))', // cfcAboveEqualAverage
'', //'@RC&lt;=AVERAGE( IF(ISERROR(%2:s), &quot;&quot;, IF(ISBLANK(%2:s), &quot;&quot;, %2:s)))', // cfcBelowEqualAverage
// the following 4 formulas are copies of Excel-generated files, they exist in the xmls file, but Excel does not display them...
'@RC&gt;AVERAGE( IF(ISERROR(%2:s), &quot;&quot;, IF(ISBLANK(%2:s), &quot;&quot;, %2:s)))', // cfcAboveAverage
'@RC&lt;AVERAGE( IF(ISERROR(%2:s), &quot;&quot;, IF(ISBLANK(%2:s), &quot;&quot;, %2:s)))', // cfcBelowAverage
'@RC&gt;=AVERAGE( IF(ISERROR(%2:s), &quot;&quot;, IF(ISBLANK(%2:s), &quot;&quot;, %2:s)))', // cfcAboveEqualAverage
'@RC&lt;=AVERAGE( IF(ISERROR(%2:s), &quot;&quot;, IF(ISBLANK(%2:s), &quot;&quot;, %2:s)))', // cfcBelowEqualAverage
// The next 4 formulas are not supported by Excel-XML
'', '', '', '', // cfcTop, cfcBottom, cfcTopPercent, cfcBottomPercent,
'@AND(COUNTIF(%2:s, RC)&gt;1,NOT(ISBLANK(RC)))', // cfcDuplicate
@ -243,6 +245,7 @@ const
'@' // cfcExpression
);
// The leading '@' indicates that the formula will be used in <Value1> node
// Parameter 0 is Operand1, parameter 1 is Operand2 and parameter 2 is Range
function GetCellContentTypeStr(ACell: PCell): String;
begin
@ -358,6 +361,73 @@ begin
Result := false;
end;
{ Analyzes the given expression. Using the @ templates of CF_CONDITIONS it
determines the condition type as well as the parameters. }
procedure AnalyzeCFExpression(AExpr: String; out ACondition: TsCFCondition;
out AParam: String);
var
p, n: Integer;
begin
AParam := '';
//AExpr := UTF8TextToXMLText(AExpr);
if pos('RC>AVERAGE(', AExpr) = 1 then
ACondition := cfcAboveAverage
else
if pos ('RC<AVERAGE(', AExpr) = 1 then
ACondition := cfcBelowAverage
else
if pos('RC>=AVERAGE(', AExpr) = 1 then
ACondition := cfcAboveEqualAverage
else
if pos('RC<=AVERAGE(', AExpr) = 1 then
ACondition := cfcBelowEqualAverage
else
if (pos('AND(COUNTIF(', AExpr) = 1) and (pos('>', AExpr) > 0) then
ACondition := cfcDuplicate
else
if (pos('AND(COUNTIF(', AExpr) = 1) and (pos('=1', AExpr) > 0) then
ACondition := cfcUnique
else
if pos('LEFT(RC,LEN(', AExpr) = 1 then
begin
ACondition := cfcBeginsWith;
p := pos(')', AExpr);
n := Length('LEFT(RC,LEN(');
AParam := UnquoteStr(Trim(Copy(AExpr, n+1, p-n-1)));
end else
if pos('RIGHT(RC,LEN(',AExpr) = 1 then
begin
ACondition := cfcEndsWith;
p := pos(')', AExpr);
n := Length('RIGHT(RC,LEN(');
AParam := UnquoteStr(Trim(Copy(AExpr, n+1, p-n-1)));
end else
if pos('NOT(ISERROR(SEARCH(', AExpr) = 1 then
begin
ACondition := cfcContainsText;
p := pos(',', AExpr);
n := Length('NOT(ISERROR(SEARCH(');
AParam := UnquoteStr(Trim(Copy(AExpr, n+1, p-n-1)));
end else
if pos('ISERROR(SEARCH(', AExpr) = 1 then
begin
ACondition := cfcNotContainsText;
p := pos(',', AExpr);
n := Length('ISERROR(SEARCH(');
AParam := UnquoteStr(Trim(Copy(AExpr, n+1, p-n-1)));
end else
if AExpr = 'ISERROR(RC)' then
ACondition := cfcContainsErrors
else
if AExpr = 'NOT(ISERROR(RC))' then
ACondition := cfcNotContainsErrors
else
begin
ACondition := cfcExpression;
AParam := AExpr;
end;
end;
{===============================================================================
TsSpreadExcelXMLReader
@ -782,6 +852,7 @@ var
lineColor: TsColor;
commonBorder: TsCellBorderStyle;
borderStyles: TsCellBorderStyles;
parser: TsSpreadsheetParser;
begin
sheet := TsWorksheet(AWorksheet);
book := TsWorkbook(FWorkbook);
@ -939,6 +1010,29 @@ begin
end;
childNode := childNode.NextSibling;
end;
if (condition = -1) and (op1 <> '') then
begin
AnalyzeCFExpression(op1, TsCFCondition(condition), s);
if s = '' then
VarClear(op1)
else
if TsCFCondition(condition) = cfcExpression then
begin
parser := TsSpreadsheetParser.Create(AWorksheet);
try
try
parser.R1C1Expression[nil] := s; // Parse in Excel-R1C1 dialect
op1 := parser.Expression[fdExcelA1]; // Convert to Excel-A1 dialect
except
VarClear(op1);
end;
finally
parser.Free;
end;
end else
op1 := s;
end;
end;
ANode := ANode.NextSibling;
end;
@ -2571,6 +2665,24 @@ begin
]));
end;
procedure TsSpreadExcelXMLWriter.WriteDocumentProperties(AStream: TStream);
begin
AppendToStream(AStream, INDENT1 +
'<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office" />' + LineEnding);
// replace by these when fpspreadsheet supports these meta data.
{
AppendToSstream(AStream, INDENT1 +
'<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">' + LineEnding + INDENT2 +
'<Author></Author>' + LineEnding + INDENT2 +
'<LastAuthor></LastAuthor>' + LineEnding + INDENT2 +
'<Created></Created>' + LineEnding + Indent2 + // Date in format YYYY-mm-ddThh:nn:ssZ
'<Version>16.00</Version>' + LineEnding + Indent1 +
'</DocumentProperties>' + LineEnding
);
}
end;
procedure TsSpreadExcelXMLWriter.WriteError(AStream: TStream;
const ARow, ACol: Cardinal; const AValue: TsErrorValue; ACell: PCell);
begin
@ -2815,6 +2927,15 @@ begin
);
end;
procedure TsSpreadExcelXMLWriter.WriteOfficeDocumentSettings(AStream: TStream);
begin
AppendToStream(AStream, INDENT1 +
'<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">' + LineEnding + INDENT2 +
'<AllowPNG/>' + LineEnding + INDENT1 +
'</OfficeDocumentSettings>' + LineEnding
);
end;
procedure TsSpreadExcelXMLWriter.WritePageBreaks(AStream: TStream;
AWorksheet: TsBasicWorksheet);
var
@ -3165,6 +3286,8 @@ begin
' xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"' + LF +
' xmlns:html="http://www.w3.org/TR/REC-html40">' + LF);
WriteDocumentProperties(AStream);
WriteOfficeDocumentSettings(AStream);
WriteExcelWorkbook(AStream);
WriteStyles(AStream);
WriteWorksheets(AStream);

View File

@ -90,6 +90,22 @@ type
procedure TestWriteRead_CF_CellFmt_XML_LessEqual_Const;
procedure TestWriteRead_CF_CellFmt_XML_Between_Const;
procedure TestWriteRead_CF_CellFmt_XML_NotBetween_Const;
procedure TestWriteRead_CF_CellFmt_XML_AboveAverage;
procedure TestWriteRead_CF_CellFmt_XML_BelowAverage;
procedure TestWriteRead_CF_CellFmt_XML_AboveEqualAverage;
procedure TestWriteRead_CF_CellFmt_XML_BelowEqualAverage;
procedure TestWriteRead_CF_CellFmt_XML_BeginsWith;
procedure TestWriteRead_CF_CellFmt_XML_EndsWith;
procedure TestWriteRead_CF_CellFmt_XML_Contains;
procedure TestWriteRead_CF_CellFmt_XML_NotContains;
procedure TestWriteRead_CF_CellFmt_XML_Unique;
procedure TestWriteRead_CF_CellFmt_XML_Duplicate;
procedure TestWriteRead_CF_CellFmt_XML_ContainsErrors;
procedure TestWriteRead_CF_CellFmt_XML_NotContainsErrors;
procedure TestWriteRead_CF_CellFmt_XML_Expression;
procedure TestWriteRead_CF_CellFmt_XML_Background;
procedure TestWriteRead_CF_CellFmt_XML_Border4;
procedure TestWriteRead_CF_CellFmt_XML_Border2;
@ -626,7 +642,7 @@ var
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfOOXML, cfcExpression, 'ISNUMBER(A1)', fmt);
TestWriteRead_CF_CellFmt(sfOOXML, cfcExpression, 'ISNUMBER($A$1)', fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XLSX_Background;
@ -657,6 +673,234 @@ begin
end;
{ Excel XML }
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_Equal_Const;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcEqual, 5, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_NotEqual_Const;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcNotEqual, 5, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_GreaterThan_Const;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcGreaterThan, 5, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_LessThan_Const;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcLessThan, 5, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_GreaterEqual_Const;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcGreaterEqual, 5, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_LessEqual_Const;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcLessEqual, 5, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_Between_Const;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcBetween, 3, 7, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_NotBetween_Const;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcNotBetween, 3, 7, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_AboveAverage;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcAboveAverage, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_BelowAverage;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcBelowAverage, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_AboveEqualAverage;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcAboveEqualAverage, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_BelowEqualAverage;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcBelowEqualAverage, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_BeginsWith;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcBeginsWith, 'ab', fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_EndsWith;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcEndsWith, 'kl', fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_Contains;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcEndsWith, 'b', fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_NotContains;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcEndsWith, 'b', fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_Unique;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcUnique, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_Duplicate;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcDuplicate, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_ContainsErrors;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcContainsErrors, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_NotContainsErrors;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcNotContainsErrors, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_Expression;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcExpression, 'ISNUMBER($A$1)', fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_Background;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackground(fsHatchDiag, scYellow, scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcEqual, 5, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_Border4;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBorders([cbNorth, cbEast, cbSouth, cbWest], scBlue, lsDotted);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcEqual, 5, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_Border2;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBorders([cbNorth,cbSouth], scBlue, lsDashed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcEqual, 5, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_Font;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.FontIndex := MaxInt; // Indicator for the test routine to create a predefined font
TestWriteRead_CF_CellFmt(sfExcelXML, cfcEqual, 5, fmt);
end;
{-------------------------------------------------------------------------------
Color range tests
--------------------------------------------------------------------------------}
@ -940,116 +1184,6 @@ begin
end;
{ Excel XML }
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_Equal_Const;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcEqual, 5, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_NotEqual_Const;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcNotEqual, 5, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_GreaterThan_Const;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcGreaterThan, 5, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_LessThan_Const;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcLessThan, 5, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_GreaterEqual_Const;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcGreaterEqual, 5, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_LessEqual_Const;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcLessEqual, 5, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_Between_Const;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcBetween, 3, 7, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_NotBetween_Const;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackgroundColor(scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcNotBetween, 3, 7, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_Background;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBackground(fsHatchDiag, scYellow, scRed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcEqual, 5, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_Border4;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBorders([cbNorth, cbEast, cbSouth, cbWest], scBlue, lsDotted);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcEqual, 5, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_Border2;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.SetBorders([cbNorth,cbSouth], scBlue, lsDashed);
TestWriteRead_CF_CellFmt(sfExcelXML, cfcEqual, 5, fmt);
end;
procedure TSpreadWriteReadCFTests.TestWriteRead_CF_CellFmt_XML_Font;
var
fmt: TsCellFormat;
begin
InitFormatRecord(fmt);
fmt.FontIndex := MaxInt; // Indicator for the test routine to create a predefined font
TestWriteRead_CF_CellFmt(sfExcelXML, cfcEqual, 5, fmt);
end;
initialization
RegisterTest(TSpreadWriteReadCFTests);