From acb49d95908720afa25c63ee020167934891ef12 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 18 Jul 2020 15:57:19 +0000 Subject: [PATCH] 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 --- .../fpspreadsheet/laz_fpspreadsheet.lpk | 233 ++++++------ .../laz_fpspreadsheet_crypto.lpk | 1 + .../laz_fpspreadsheet_visual.lpk | 1 + .../laz_fpspreadsheet_visual_dsgn.lpk | 1 + .../laz_fpspreadsheetexport_visual.lpk | 1 + .../source/common/fpsexprparser.pas | 11 +- .../fpspreadsheet/source/common/xlsxml.pas | 133 ++++++- .../tests/conditionalformattests.pas | 356 ++++++++++++------ 8 files changed, 504 insertions(+), 233 deletions(-) diff --git a/components/fpspreadsheet/laz_fpspreadsheet.lpk b/components/fpspreadsheet/laz_fpspreadsheet.lpk index 80c6841a3..5605c1c96 100644 --- a/components/fpspreadsheet/laz_fpspreadsheet.lpk +++ b/components/fpspreadsheet/laz_fpspreadsheet.lpk @@ -34,280 +34,281 @@ This package is all you need if you don't want graphical components (like grids and charts)."/> - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + + - - + + - - + + - + diff --git a/components/fpspreadsheet/laz_fpspreadsheet_crypto.lpk b/components/fpspreadsheet/laz_fpspreadsheet_crypto.lpk index cbeb85935..1e844869e 100644 --- a/components/fpspreadsheet/laz_fpspreadsheet_crypto.lpk +++ b/components/fpspreadsheet/laz_fpspreadsheet_crypto.lpk @@ -24,6 +24,7 @@ + diff --git a/components/fpspreadsheet/laz_fpspreadsheet_visual.lpk b/components/fpspreadsheet/laz_fpspreadsheet_visual.lpk index c5743599a..23c601343 100644 --- a/components/fpspreadsheet/laz_fpspreadsheet_visual.lpk +++ b/components/fpspreadsheet/laz_fpspreadsheet_visual.lpk @@ -43,6 +43,7 @@ It provides graphical components like a grid and chart."/> + diff --git a/components/fpspreadsheet/laz_fpspreadsheet_visual_dsgn.lpk b/components/fpspreadsheet/laz_fpspreadsheet_visual_dsgn.lpk index 0a2194b7c..0929e66d8 100644 --- a/components/fpspreadsheet/laz_fpspreadsheet_visual_dsgn.lpk +++ b/components/fpspreadsheet/laz_fpspreadsheet_visual_dsgn.lpk @@ -24,6 +24,7 @@ + diff --git a/components/fpspreadsheet/laz_fpspreadsheetexport_visual.lpk b/components/fpspreadsheet/laz_fpspreadsheetexport_visual.lpk index dd7020640..b35d4b580 100644 --- a/components/fpspreadsheet/laz_fpspreadsheetexport_visual.lpk +++ b/components/fpspreadsheet/laz_fpspreadsheetexport_visual.lpk @@ -37,6 +37,7 @@ It provides a graphical export component on the Data Export tab."/> + diff --git a/components/fpspreadsheet/source/common/fpsexprparser.pas b/components/fpspreadsheet/source/common/fpsexprparser.pas index e54d49430..f50e6f165 100644 --- a/components/fpspreadsheet/source/common/fpsexprparser.pas +++ b/components/fpspreadsheet/source/common/fpsexprparser.pas @@ -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) diff --git a/components/fpspreadsheet/source/common/xlsxml.pas b/components/fpspreadsheet/source/common/xlsxml.pas index c0b8c47f3..2f95ef7d8 100644 --- a/components/fpspreadsheet/source/common/xlsxml.pas +++ b/components/fpspreadsheet/source/common/xlsxml.pas @@ -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>AVERAGE( IF(ISERROR(%2:s), "", IF(ISBLANK(%2:s), "", %2:s)))', // cfcAboveAverage - '', //'@RC<AVERAGE( IF(ISERROR(%2:s), "", IF(ISBLANK(%2:s), "", %2:s)))', // cfcBelowAverage - '', //'@RC>=AVERAGE( IF(ISERROR(%2:s), "", IF(ISBLANK(%2:s), "", %2:s)))', // cfcAboveEqualAverage - '', //'@RC<=AVERAGE( IF(ISERROR(%2:s), "", IF(ISBLANK(%2:s), "", %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>AVERAGE( IF(ISERROR(%2:s), "", IF(ISBLANK(%2:s), "", %2:s)))', // cfcAboveAverage + '@RC<AVERAGE( IF(ISERROR(%2:s), "", IF(ISBLANK(%2:s), "", %2:s)))', // cfcBelowAverage + '@RC>=AVERAGE( IF(ISERROR(%2:s), "", IF(ISBLANK(%2:s), "", %2:s)))', // cfcAboveEqualAverage + '@RC<=AVERAGE( IF(ISERROR(%2:s), "", IF(ISBLANK(%2:s), "", %2:s)))', // cfcBelowEqualAverage // The next 4 formulas are not supported by Excel-XML '', '', '', '', // cfcTop, cfcBottom, cfcTopPercent, cfcBottomPercent, '@AND(COUNTIF(%2:s, RC)>1,NOT(ISBLANK(RC)))', // cfcDuplicate @@ -243,6 +245,7 @@ const '@' // cfcExpression ); // The leading '@' indicates that the formula will be used in 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 := 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 + + '' + LineEnding); + + // replace by these when fpspreadsheet supports these meta data. + { + AppendToSstream(AStream, INDENT1 + + '' + LineEnding + INDENT2 + + '' + LineEnding + INDENT2 + + '' + LineEnding + INDENT2 + + '' + LineEnding + Indent2 + // Date in format YYYY-mm-ddThh:nn:ssZ + '16.00' + LineEnding + Indent1 + + '' + 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 + + '' + LineEnding + INDENT2 + + '' + LineEnding + INDENT1 + + '' + 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); diff --git a/components/fpspreadsheet/tests/conditionalformattests.pas b/components/fpspreadsheet/tests/conditionalformattests.pas index 6e7f67ea6..a488b330d 100644 --- a/components/fpspreadsheet/tests/conditionalformattests.pas +++ b/components/fpspreadsheet/tests/conditionalformattests.pas @@ -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);