Data validation

Validate and show errors to users if they enter invalid data

Validation rules can be added as part of your cellData

import { SpreadsheetProvider, CanvasGrid } from "@rowsncolumns/spreadsheet";

const MySpreadsheet = () => {
  return (
    <CanvasGrid
      getCellData={(sheetId, rowIndex, columnIndex) => {
        if (rowIndex === 2 && columnIndex === 2){
          return {
            dataValidation: {
              condition: {
                type: 'ONE_OF_LIST',
                values: [
                  {
                    userEnteredValue: 'Singapore'
                  },
                  {
                    userEnteredValue: 'USA'
                  },
                  {
                    userEnteredValue: 'UK'
                  }
                ]
              }
            }
          }
        }
      }}
    />
  );
};

const App = () => (
  <SpreadsheetProvider>
    <MySpreadsheet />
  </SpreadsheetProvider>
);

The following validation types are supported

Data Validation Editor

Last updated

Was this helpful?