Univer
Univer Sheet
Features
Data Validation

Data Validation

📊 Univer Sheet

Data validation is a feature that sets rules in cells to ensure that the data entered by users meets specific conditions. Currently supported data validation types:

  • number
  • integer
  • Text length
  • date
  • checkbox
  • Drop-down list (single/multiple)
  • Custom formula

Installation

pnpm add @univerjs/data-validation @univerjs/sheets-data-validation @univerjs/sheets-data-validation-ui

Import

import '@univerjs/sheets-data-validation-ui/lib/index.css';
 
import { UniverDataValidationPlugin } from '@univerjs/data-validation';
import { UniverSheetsDataValidationPlugin } from '@univerjs/sheets-data-validation';
import { UniverSheetsDataValidationUIPlugin } from '@univerjs/sheets-data-validation-ui';

Internationalization

import { LocaleType, Tools } from '@univerjs/core';
import SheetsDataValidationEnUS from '@univerjs/sheets-data-validation-ui/locale/en-US';
 
const univer = new Univer({
  theme: defaultTheme,
  locale: LocaleType.EN_US,
  locales: {
    [LocaleType.EN_US]: Tools.deepMerge(
      // ...other_locales,
      SheetsDataValidationEnUS
    ),
  },
});

Register

univer.registerPlugin(UniverDataValidationPlugin);
 
univer.registerPlugin(UniverSheetsDataValidationPlugin);
 
univer.registerPlugin(UniverSheetsDataValidationUIPlugin, {
  // Whether to show the edit button in the dropdown menu
  showEditOnDropdown: true
});

Copyright © 2021-2024 DreamNum Co,Ltd. All Rights Reserved.