From fba35bacb434d9b341087ae7e70ee5fb899c134e Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Wed, 1 Jul 2020 16:14:35 +0000 Subject: [PATCH] fpspreadsheet: Add to the demo a test of conditional format with two rules in the same cell range git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7512 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../demo_conditional_formatting.pas | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/components/fpspreadsheet/examples/other/conditional_formatting/demo_conditional_formatting.pas b/components/fpspreadsheet/examples/other/conditional_formatting/demo_conditional_formatting.pas index 6a041e9b8..64112e812 100644 --- a/components/fpspreadsheet/examples/other/conditional_formatting/demo_conditional_formatting.pas +++ b/components/fpspreadsheet/examples/other/conditional_formatting/demo_conditional_formatting.pas @@ -21,7 +21,7 @@ begin sh.WriteDefaultColWidth(15, suMillimeters); sh.WriteText(0, 0, 'Condition'); - sh.WriteColWidth(0, 60, suMillimeters); + sh.WriteColWidth(0, 70, suMillimeters); sh.WriteText(0, 1, 'Format'); sh.WriteColWidth(1, 90, suMillimeters); sh.WriteText(0, 2, 'Test values'); @@ -265,6 +265,18 @@ begin fmtIdx := wb.AddCellFormat(fmt); sh.WriteConditionalCellFormat(Range(row, 2, row, lastCol), cfcNotContainsErrors, fmtIdx); + // Two rules in the same conditional format + inc(row); + sh.WriteText(row, 0, 'Two rules: #1: equal to 5, #2: equal to 3'); + sh.WriteText(row, 1, '#1: background yellow, #2: background green'); + InitFormatRecord(fmt); + fmt.SetBackgroundColor(scYellow); + fmtIdx := wb.AddCellFormat(fmt); + sh.WriteConditionalCellFormat(Range(row, 2, row, lastCol), cfcEqual, 5, fmtIdx); + fmt.SetBackgroundColor(scGreen); + fmtIdx := wb.AddCellFormat(fmt); + sh.WriteConditionalCellFormat(Range(row, 2, row, lastCol), cfcEqual, 3, fmtIdx); + { ------ Save workbook to file-------------------------------------------- } wb.WriteToFile('test.xlsx', true); wb.WriteToFile('test.ods', true);