Conditional formatting
Change text or background colour of cells based on the value
CanvasGrid accepts array of conditionalFormats prop which can be used to inject formatting rules based on the value of a cell. Formula values are supported.
import { SpreadsheetProvider, CanvasGrid } from "@rowsncolumns/spreadsheet";
const MySpreadsheet = () => {
return (
<CanvasGrid
conditionalFormats={[
{
ranges: [
{
startRowIndex: 1,
endRowIndex: 1000,
startColumnIndex: 2,
endColumnIndex: 2,
},
],
booleanRule: {
condition: {
type: "NUMBER_LESS",
values: [
{
userEnteredValue: "0",
},
],
},
format: {
backgroundColor: "red",
},
},
},
]}
/>
);
};
const App = () => (
<SpreadsheetProvider>
<MySpreadsheet />
</SpreadsheetProvider>
);
Gradient scale or heatmaps
Supported conditions
Adding conditional format editor UI
Spreadsheet comes with a default conditional format editor.
Right click on any cell and select Conditional format editor . Or you can invoke the function onRequestConditionalFormat from useSpreadsheetState hook

Last updated
Was this helpful?