For the complete documentation index, see llms.txt. This page is also available as Markdown.

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

Data bars

Paint a horizontal bar inside each cell, scaled by the cell's value relative to the range min/max. Round-trips XLSX + ODS.

Icon sets

Stamp an icon to the left of each cell based on which bucket the value falls in. Many built-in icon families ship: 3TrafficLights1, 3TrafficLights2, 3Arrows, 3Symbols, 4Rating, 5Rating, 5Arrows, etc.

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

Conditional format editor

Last updated