cfsimplicity / spreadsheet-cfml

Standalone library for working with spreadsheets and CSV in CFML
MIT License
126 stars 35 forks source link

Add basic support for conditional formatting #323

Closed cfsimplicity closed 1 year ago

cfsimplicity commented 1 year ago

https://support.microsoft.com/en-us/office/use-conditional-formatting-to-highlight-information-fed60dfa-1d3f-4e13-9ecb-f1951ff89d7f

Allows specific formats to be applied to cells depending on their values, or any boolean condition/formula, using a builder syntax:

spreadsheet.newConditionalFormatting()
  .onCells( "A1:B1" )
  .when( "$A1<0" )
  .setFormat( { fontColor:"RED" } )
  .addToWorkbook( workbook );

or

spreadsheet.newConditionalFormatting()
  .onCells( "A1" )
  .whenCellValueIs( "LT", 0 )
  .setFormat( { fontColor:"RED" } )
  .addToWorkbook( workbook );