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 067050c53..8fd4d1f61 100644 --- a/components/fpspreadsheet/examples/other/conditional_formatting/demo_conditional_formatting.pas +++ b/components/fpspreadsheet/examples/other/conditional_formatting/demo_conditional_formatting.pas @@ -85,6 +85,16 @@ begin fmtIdx := wb.AddCellFormat(fmt); sh.WriteConditionalCellFormat(Range(0, 0, 100, 100), cfcContainsErrors, fmtIdx); + + { ------ 6th conditional format: unique/duplicate values ----------------- } + sh.WriteNumber(0, 1, 1.0); + sh.WriteNumber(1, 1, 99.0); + InitFormatRecord(fmt); + fmt.SetBackgroundColor(scSilver); + sh.WriteConditionalCellFormat(Range(0, 0, 1, 1), cfcUnique, wb.AddCellFormat(fmt)); + fmt.SetBackgroundColor(scGreen); + sh.WriteConditionalCellFormat(Range(0, 0, 1, 1), cfcDuplicate, wb.AddCellFormat(fmt)); + { ------ Save workbook to file-------------------------------------------- } wb.WriteToFile('test.xlsx', true); finally diff --git a/components/fpspreadsheet/source/common/xlsxooxml.pas b/components/fpspreadsheet/source/common/xlsxooxml.pas index c8903d7c3..8181fd210 100644 --- a/components/fpspreadsheet/source/common/xlsxooxml.pas +++ b/components/fpspreadsheet/source/common/xlsxooxml.pas @@ -3360,7 +3360,7 @@ const var i: Integer; dxfID: Integer; - aveStr, stdDevStr, eqAveStr, opStr: String; + typeStr, aveStr, stdDevStr, eqAveStr, opStr: String; firstCellOfRange: String; begin dxfID := -1; @@ -3424,6 +3424,16 @@ begin opStr ])); end; + + cfcDuplicate, cfcUnique: + begin + if ARule.Condition = cfcUnique then + typeStr := 'uniqueValues' + else + typeStr := 'duplicateValues'; + AppendToStream(AStream, Format( + '', [typeStr, dxfID, APriority])); + end; else FWorkbook.AddErrorMsg('ConditionalFormat operator not supported.'); end;