指南Univer Sheets功能条件格式

条件格式

Facade API付费版本需要 Univer 服务端Univer on Node.jsPreset
---UniverSheetsConditionalFormattingPreset

条件格式是一种在单元格中设置规则,以根据数据的值自动设置单元格格式的功能。

该功能包含以下插件包:

Presets 安装

import { createUniver, defaultTheme, LocaleType, Tools } from '@univerjs/presets';
import { UniverSheetsCorePreset } from '@univerjs/presets/preset-sheets-core';
import UniverPresetSheetsCoreZhCN from '@univerjs/presets/preset-sheets-core/locales/zh-CN';
import { UniverSheetsConditionalFormattingPreset } from '@univerjs/presets/preset-sheets-conditional-formatting';
import UniverPresetSheetsConditionalFormattingZhCN from '@univerjs/presets/preset-sheets-conditional-formatting/locales/zh-CN';
 
const { univerAPI } = createUniver({
  locale: LocaleType.ZH_CN,
  locales: {
    zhCN: Tools.deepMerge(
      {},
      UniverPresetSheetsCoreZhCN,
      UniverPresetSheetsConditionalFormattingZhCN 
    ),
  },
  theme: defaultTheme,
  presets: [
    UniverSheetsCorePreset(),
    UniverSheetsConditionalFormattingPreset(),
  ],
});

高级安装

npm install @univerjs/sheets-conditional-formatting @univerjs/sheets-conditional-formatting-ui
import { LocaleType, Tools } from '@univerjs/core';
import { UniverSheetsConditionalFormattingPlugin } from '@univerjs/sheets-conditional-formatting';
import { UniverSheetsConditionalFormattingUIPlugin } from '@univerjs/sheets-conditional-formatting-ui';
import SheetsConditionalFormattingUIZhCN from '@univerjs/sheets-conditional-formatting-ui/locale/zh-CN';
 
import '@univerjs/sheets-conditional-formatting-ui/lib/index.css';
 
const univer = new Univer({
  theme: defaultTheme,
  locale: LocaleType.ZH_CN,
  locales: {
    [LocaleType.ZH_CN]: Tools.deepMerge(
      SheetsConditionalFormattingUIZhCN
    ),
  },
});
 
univer.registerPlugin(UniverSheetsConditionalFormattingPlugin);
univer.registerPlugin(UniverSheetsConditionalFormattingUIPlugin);

Univer on Node.js 高级安装

npm install @univerjs/sheets-conditional-formatting
import { LocaleType, Tools } from '@univerjs/core';
import { UniverSheetsConditionalFormattingPlugin } from '@univerjs/sheets-conditional-formatting';
 
import '@univerjs/sheets-conditional-formatting/facade';
 
const univer = new Univer({
  theme: defaultTheme,
  locale: LocaleType.ZH_CN,
});
 
univer.registerPlugin(UniverSheetsConditionalFormattingPlugin);

参考链接