核心功能
Univer Sheets 的核心由電子表格編輯器及其所需的元件組成,包括公式引擎、渲染引擎、數字格式化引擎、設計系統和 UI 元件庫。這些部分共同支援多種電子表格格式,並處理實際工作簿中出現的複雜操作。
特性
這些核心功能包括:
- 電子表格渲染:繪製表格內容、游標和選區。
- 單元格樣式:設定單元格的字型、顏色、邊框和對齊方式。
- 公式計算:新增並計算公式,幾乎覆蓋所有 Excel 函式,包括數學、統計、文字和日期函式。
- 數字格式化:把數字格式化成貨幣、百分比、日期等樣式。
- 網格線和凍結窗格:顯示網格線和凍結窗格,便於檢視和編輯大資料量的表格。
- 預設樣式:設定電子表格的預設字型、字號、顏色等樣式。
- 外掛系統:支援新增自定義外掛,例如公式外掛、圖片外掛和圖表外掛。外掛系統也是 Univer 的核心架構能力之一。
外掛模式
安裝
pnpm add @univerjs/core @univerjs/design @univerjs/engine-render @univerjs/engine-formula @univerjs/ui @univerjs/docs @univerjs/docs-ui @univerjs/sheets @univerjs/sheets-ui @univerjs/sheets-formula @univerjs/sheets-formula-ui @univerjs/sheets-numfmt @univerjs/sheets-numfmt-uinpm install @univerjs/core @univerjs/design @univerjs/engine-render @univerjs/engine-formula @univerjs/ui @univerjs/docs @univerjs/docs-ui @univerjs/sheets @univerjs/sheets-ui @univerjs/sheets-formula @univerjs/sheets-formula-ui @univerjs/sheets-numfmt @univerjs/sheets-numfmt-uiyarn add @univerjs/core @univerjs/design @univerjs/engine-render @univerjs/engine-formula @univerjs/ui @univerjs/docs @univerjs/docs-ui @univerjs/sheets @univerjs/sheets-ui @univerjs/sheets-formula @univerjs/sheets-formula-ui @univerjs/sheets-numfmt @univerjs/sheets-numfmt-uibun add @univerjs/core @univerjs/design @univerjs/engine-render @univerjs/engine-formula @univerjs/ui @univerjs/docs @univerjs/docs-ui @univerjs/sheets @univerjs/sheets-ui @univerjs/sheets-formula @univerjs/sheets-formula-ui @univerjs/sheets-numfmt @univerjs/sheets-numfmt-ui使用
import { LocaleType, mergeLocales, Univer } from '@univerjs/core'import DesignZhTW from '@univerjs/design/locale/zh-TW'import { UniverDocsPlugin } from '@univerjs/docs'import { UniverDocsUIPlugin } from '@univerjs/docs-ui'import DocsUIZhTW from '@univerjs/docs-ui/locale/zh-TW'import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula'import { UniverRenderEnginePlugin } from '@univerjs/engine-render'import { UniverSheetsPlugin } from '@univerjs/sheets'import { UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula'import { UniverSheetsFormulaUIPlugin } from '@univerjs/sheets-formula-ui'import SheetsFormulaUIZhTW from '@univerjs/sheets-formula-ui/locale/zh-TW'import { UniverSheetsNumfmtPlugin } from '@univerjs/sheets-numfmt'import { UniverSheetsNumfmtUIPlugin } from '@univerjs/sheets-numfmt-ui'import SheetsNumfmtUIZhTW from '@univerjs/sheets-numfmt-ui/locale/zh-TW'import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui'import SheetsUIZhTW from '@univerjs/sheets-ui/locale/zh-TW'import SheetsZhTW from '@univerjs/sheets/locale/zh-TW'import { UniverUIPlugin } from '@univerjs/ui'import UIZhTW from '@univerjs/ui/locale/zh-TW'import '@univerjs/design/lib/index.css'import '@univerjs/ui/lib/index.css'import '@univerjs/docs-ui/lib/index.css'import '@univerjs/sheets-ui/lib/index.css'import '@univerjs/sheets-formula-ui/lib/index.css'import '@univerjs/sheets-numfmt-ui/lib/index.css'import '@univerjs/engine-formula/facade'import '@univerjs/ui/facade'import '@univerjs/docs-ui/facade'import '@univerjs/sheets/facade'import '@univerjs/sheets-ui/facade'import '@univerjs/sheets-formula/facade'import '@univerjs/sheets-numfmt/facade'const univer = new Univer({ locale: LocaleType.ZH_TW, locales: { [LocaleType.ZH_TW]: mergeLocales( DesignZhTW, UIZhTW, DocsUIZhTW, SheetsZhTW, SheetsUIZhTW, SheetsFormulaUIZhTW, SheetsNumfmtUIZhTW, ), },})univer.registerPlugin(UniverRenderEnginePlugin)univer.registerPlugin(UniverFormulaEnginePlugin)univer.registerPlugin(UniverUIPlugin, { container: 'app',})univer.registerPlugin(UniverDocsPlugin)univer.registerPlugin(UniverDocsUIPlugin)univer.registerPlugin(UniverSheetsPlugin)univer.registerPlugin(UniverSheetsUIPlugin)univer.registerPlugin(UniverSheetsFormulaPlugin)univer.registerPlugin(UniverSheetsFormulaUIPlugin)univer.registerPlugin(UniverSheetsNumfmtPlugin)univer.registerPlugin(UniverSheetsNumfmtUIPlugin)外掛設定
@univerjs/core
這是 Univer 的核心庫,負責建立 Univer 例項,並管理主題、語言等基礎功能。
themeTheme預設值:defaultTheme編輯器使用的主題。[palette]object[shade]string依色彩名稱和色階組織的色盤,可參照defaultTheme。
darkModeboolean預設值:false啟動時使用深色模式。localestring選單和對話方塊使用的語言。regionstring預設值: 跟隨locale地區格式使用的 BCP 47 標籤,例如LocaleType.DE_DE。影響工具列顯示的貨幣符號。localesRecord<string, ILanguagePack>按語言提供翻譯資源。[locale]ILanguagePack對應語言的翻譯套件,以該語言的值為鍵。
logLevelLogLevel預設值:LogLevel.INFO執行時日誌的詳細程度。
參考:Univer
@univerjs/engine-render
這是 Univer 的渲染引擎,負責繪製表格內容、捲軸、游標和選區,並匯出 UniverRenderEnginePlugin。
@univerjs/engine-formula
這是 Univer 的公式引擎,負責計算和處理公式,並匯出 UniverFormulaEnginePlugin。
@univerjs/design
這是 Univer 的設計系統,提供全部基礎元件和樣式。
詳見:UI 章節
@univerjs/ui
這是 Univer 的 UI 基座,匯出 UniverUIPlugin。
UniverUIPlugin 接受一組用於基礎版面配置的配置項。
containerstring | HTMLElement編輯器掛載的元素。headerboolean預設值:true顯示頂端區域。toolbarboolean預設值:true顯示工具列。ribbonTypeRibbonType預設值:'classic'選擇 Ribbon 版面。contextMenuboolean預設值:true啟用右鍵選單。disableAutoFocustrue啟動時停用自動聚焦。customFontFamilyIFontConfig[] | object在字型下拉清單中新增這些選項。listIFontConfig[]在字型下拉清單中新增這些選項。valuestringCSS 使用的字型名稱。labelstring顯示名稱或翻譯鍵。categoryFontCategory字型群組,可選sans-serif、serif、monospace、display或handwriting。
overrideboolean預設值:false以傳入的清單取代內建字型選項。
override[DependencyIdentifier, Provider | null][]取代預設注入的相依項目。[0]DependencyIdentifier要替換的相依性識別碼。[1]Provider | null替代的提供者。傳入null可移除此相依性。
用 menu 可以控制特定選單項的顯示或隱藏:
univer.registerPlugin(UniverUIPlugin, { menu: { 'sheet.command.set-range-bold': { hidden: true, }, 'sheet.command.set-range-italic': { hidden: true, disabled: true, }, },})這裡的 'sheet.command.set-range-bold' 和 'sheet.command.set-range-italic' 都是選單項 ID,完整列表見下方的 選單項 ID 列表。
參考:@univerjs/ui
@univerjs/docs
這是 Univer Docs 的核心外掛,匯出 UniverDocsPlugin。
@univerjs/docs-ui
這是 Univer Docs 的 UI 外掛,包含文件編輯器的 UI 元件和互動,並匯出 UniverDocsUIPlugin。
@univerjs/sheets
這是 Univer Sheets 的核心外掛,提供電子表格編輯器的核心功能,匯出 UniverSheetsPlugin。
UniverSheetsPlugin 也接收幾個編輯器配置項:
isRowStylePrecedeColumnStyleboolean預設值:false讓列樣式優先於欄樣式。autoHeightForMergedCellsboolean預設值:false為合併單元格自動調整行高。freezeSyncboolean預設值:true協作時同步凍結的列與欄。textLineGapnumber預設值:0設定儲存格文字額外行距,單位為像素。
@univerjs/sheets-ui
這是 Univer Sheets 的 UI 外掛,包含電子表格編輯器的 UI 元件和互動,並匯出 UniverSheetsUIPlugin。
UniverSheetsUIPlugin 接收一組用於調整編輯器 UI 的配置項:
formulaBarboolean預設值:true顯示公式列。clipboardConfigobject貼上後隱藏選項按鈕。hidePasteOptionsboolean預設值:false貼上後隱藏選項按鈕。
scrollConfigobject設定捲軸。mainSceneScene捲軸所屬的場景。thumbMarginnumber預設值:2軌道與滑塊之間的間距,單位為像素。thumbLengthRationumber預設值:1滑塊長度的倍率。thumbBackgroundColorstring預設值:'gray.300'滑塊色彩。thumbHoverBackgroundColorstring預設值:'gray.400'游標停留時的滑塊色彩。thumbActiveBackgroundColorstring預設值:'gray.500'拖曳時的滑塊色彩。trackBackgroundColorstring預設值:'gray.0'軌道背景色彩。trackBorderColorstring預設值:'gray.0'軌道邊框色彩。barSizenumber預設值:10捲動軌道厚度,單位為像素。barBordernumber預設值:1軌道邊框厚度,單位為像素。enableHorizontalboolean預設值:true顯示水平捲軸。enableVerticalboolean預設值:true顯示垂直捲軸。hideTrackWhenUnscrollableboolean預設值:false對應軸未溢出時隱藏軌道。minThumbSizeHnumber預設值:17水平滑塊的最小寬度,單位為像素。minThumbSizeVnumber預設值:17垂直滑塊的最小高度,單位為像素。
protectedRangeShadowboolean | 'always' | 'non-editable' | 'non-viewable' | 'none'預設值:true選擇哪些受保護範圍顯示陰影。protectedRangeUserSelectorobject設定保護範圍的自訂使用者選擇器。componentComponentType<IPermissionDetailUserPartProps>用於選取使用者的元件。frameworkstring元件使用的框架,例如react。
disableForceStringAlertboolean預設值:false隱藏強制文字值的提示。disableForceStringMarkboolean預設值:false隱藏強制文字值的標記。maxAutoHeightCountnumber預設值:1000限制自動調整列高的列數。allowArrowKeyWrapOnSheetBoundaryboolean預設值:true方向鍵到達邊界時移到另一列或欄。selectionAnimationboolean預設值:true在桌面點選其他儲存格時播放選取動畫,遵循系統的動態效果設定。enableFillHandleboolean預設值:true顯示桌面填滿控點。填滿命令仍可用。warnBeforeDragOverwriteboolean預設值:true拖曳覆寫前先確認。移動驗證與復原仍會生效。
行動裝置支援
請先配置行動版編輯器。在本頁外掛模式的初始化程式碼中,把下面這些桌面版註冊替換為同一套件匯出的行動版外掛,並且必須在開啟文件前完成。模型外掛、樣式、語言套件和 Facade 匯入均需保留,不要同時註冊兩個版本。
| 套件 | 桌面版註冊 | 行動版註冊 |
|---|---|---|
@univerjs/sheets-formula-ui | UniverSheetsFormulaUIPlugin | UniverSheetsFormulaMobileUIPlugin |
@univerjs/sheets-numfmt-ui | UniverSheetsNumfmtUIPlugin | UniverSheetsNumfmtMobileUIPlugin |
預設模式
安裝
pnpm add @univerjs/presets @univerjs/preset-sheets-corenpm install @univerjs/presets @univerjs/preset-sheets-coreyarn add @univerjs/presets @univerjs/preset-sheets-corebun add @univerjs/presets @univerjs/preset-sheets-core使用
import { UniverSheetsCorePreset } from '@univerjs/preset-sheets-core'import UniverPresetSheetsCoreZhTW from '@univerjs/preset-sheets-core/locales/zh-TW'import { createUniver, LocaleType, mergeLocales } from '@univerjs/presets'import '@univerjs/preset-sheets-core/lib/index.css'const { univerAPI } = createUniver({ locale: LocaleType.ZH_TW, locales: { [LocaleType.ZH_TW]: mergeLocales(UniverPresetSheetsCoreZhTW), }, presets: [UniverSheetsCorePreset()],})univerAPI.createWorkbook({})預設設定
@univerjs/presets
本預設提供 createUniver,用於建立 Univer 應用,並重新匯出 @univerjs/core 和 @univerjs/design 的全部方法和物件。
createUniver 接收一個配置物件,其中包含主題、語言、預設等選項。它返回 Univer 例項 univer 和 FUniver 例項 univerAPI,透過後者呼叫 Facade API。
themeTheme預設值:defaultTheme編輯器使用的主題。[palette]object[shade]string依色彩名稱和色階組織的色盤,可參照defaultTheme。
darkModeboolean預設值:false啟動時使用深色模式。localestring選單和對話方塊使用的語言。regionstring預設值: 跟隨locale地區格式使用的 BCP 47 標籤,例如LocaleType.DE_DE。影響工具列顯示的貨幣符號。localesRecord<string, ILanguagePack>按語言提供翻譯資源。[locale]ILanguagePack對應語言的翻譯套件,以該語言的值為鍵。
logLevelLogLevel預設值:LogLevel.WARN執行時日誌的詳細程度。presets(IPreset | [IPreset, IPresetOptions])[]要註冊的預設。[0]IPreset預設工廠傳回的預設。[1]IPresetOptions延後註冊此預設的外掛。lazyboolean延後註冊此預設的外掛。
lazyboolean延後註冊此預設的外掛。
plugins(PluginCtor | [PluginCtor, object])[]註冊額外外掛與設定。[0]PluginCtor外掛的建構函式。[1]object該外掛建構函式接受的設定。
參考:createUniver
@univerjs/preset-sheets-core
這是 Univer Sheets 的核心預設,把電子表格所需的文件編輯器、公式引擎、渲染引擎等部分打包在一起。
containerstring | HTMLElement預設值:'app'編輯器掛載的元素。headerboolean預設值:true顯示頂端區域。toolbarboolean預設值:true顯示工具列。ribbonTypeRibbonType預設值:'classic'選擇 Ribbon 版面。contextMenuboolean預設值:true啟用右鍵選單。disableAutoFocustrue啟動時停用自動聚焦。customFontFamilyIFontConfig[] | object在字型下拉清單中新增這些選項。listIFontConfig[]在字型下拉清單中新增這些選項。valuestringCSS 使用的字型名稱。labelstring顯示名稱或翻譯鍵。categoryFontCategory字型群組,可選sans-serif、serif、monospace、display或handwriting。
overrideboolean預設值:false以傳入的清單取代內建字型選項。
formulaBarboolean預設值:true顯示公式列。disableTextFormatAlertboolean預設值:false隱藏儲存格文字格式警告。disableTextFormatMarkboolean預設值:false隱藏儲存格文字格式標記。sheetsobject該功能的設定。isRowStylePrecedeColumnStyleboolean預設值:false讓列樣式優先於欄樣式。autoHeightForMergedCellsboolean預設值:false為合併單元格自動調整行高。freezeSyncboolean預設值:true協作時同步凍結的列與欄。textLineGapnumber預設值:0設定儲存格文字額外行距,單位為像素。clipboardConfigobject貼上後隱藏選項按鈕。hidePasteOptionsboolean預設值:false貼上後隱藏選項按鈕。
scrollConfigobject設定捲軸。mainSceneScene捲軸所屬的場景。thumbMarginnumber預設值:2軌道與滑塊之間的間距,單位為像素。thumbLengthRationumber預設值:1滑塊長度的倍率。thumbBackgroundColorstring預設值:'gray.300'滑塊色彩。thumbHoverBackgroundColorstring預設值:'gray.400'游標停留時的滑塊色彩。thumbActiveBackgroundColorstring預設值:'gray.500'拖曳時的滑塊色彩。trackBackgroundColorstring預設值:'gray.0'軌道背景色彩。trackBorderColorstring預設值:'gray.0'軌道邊框色彩。barSizenumber預設值:10捲動軌道厚度,單位為像素。barBordernumber預設值:1軌道邊框厚度,單位為像素。enableHorizontalboolean預設值:true顯示水平捲軸。enableVerticalboolean預設值:true顯示垂直捲軸。hideTrackWhenUnscrollableboolean預設值:false對應軸未溢出時隱藏軌道。minThumbSizeHnumber預設值:17水平滑塊的最小寬度,單位為像素。minThumbSizeVnumber預設值:17垂直滑塊的最小高度,單位為像素。
protectedRangeShadowboolean | 'always' | 'non-editable' | 'non-viewable' | 'none'預設值:true選擇哪些受保護範圍顯示陰影。protectedRangeUserSelectorobject設定保護範圍的自訂使用者選擇器。componentComponentType<IPermissionDetailUserPartProps>用於選取使用者的元件。frameworkstring元件使用的框架,例如react。
disableForceStringAlertboolean預設值:false隱藏強制文字值的提示。disableForceStringMarkboolean預設值:false隱藏強制文字值的標記。maxAutoHeightCountnumber預設值:1000限制自動調整列高的列數。allowArrowKeyWrapOnSheetBoundaryboolean預設值:true方向鍵到達邊界時移到另一列或欄。selectionAnimationboolean預設值:true在桌面點選其他儲存格時播放選取動畫,遵循系統的動態效果設定。enableFillHandleboolean預設值:true顯示桌面填滿控點。填滿命令仍可用。warnBeforeDragOverwriteboolean預設值:true拖曳覆寫前先確認。移動驗證與復原仍會生效。
docsobject該功能的設定。hasScrollboolean顯示 Docs 捲軸。
formulaobject設定公式函數、說明、計算模式與函數提示。function[Ctor<BaseFunction>, string][]自定義公式的實現類。[0]Ctor<BaseFunction>公式類別。[1]string公式中使用的函式名稱。
descriptionobject[]編輯器中顯示的函式說明。functionNamestring函式名稱。aliasFunctionNamestring函式別名。functionTypeFunctionType函式分類。descriptionstring詳細說明。abstractstring簡短摘要。functionParameterobject[]參數說明清單。namestring參數名稱。detailstring參數詳情。examplestring使用範例。require0 | 1是否必填,1表示必填,0表示選填。repeat0 | 1是否可重複,1表示可重複,0表示只出現一次。
initialFormulaComputingCalculationMode預設值:CalculationMode.WHEN_EMPTY活頁簿開啟時的公式計算方式。functionScreenTipsboolean預設值:true編輯公式時顯示函式提示。
workerURLstring | URL | Worker在瀏覽器 Worker 中計算公式。
用 menu 可以控制特定選單項的顯示或隱藏:
UniverSheetsCorePreset({ menu: { 'sheet.command.set-range-bold': { hidden: true, }, 'sheet.command.set-range-italic': { hidden: true, disabled: true, }, },})這裡的 'sheet.command.set-range-bold' 和 'sheet.command.set-range-italic' 都是選單項 ID,完整列表見下方的 選單項 ID 列表。
參考:@univerjs/preset-sheets-core
工具列佈局與 RibbonType
在 IUniverSheetsCorePresetConfig 或 IUniverUIConfig 中設定 ribbonType,即可選擇工具欄版面配置。
共有四種模式:
classic:預設模式。分組位於上方,工具欄在其下方平鋪,與使用者習慣的傳統版面配置一致。grid:保留頂部標籤頁,每個分組的工具在下方按兩行網格排列,適合需要在桌面版同時顯示更多工具的場景。collapsed:分組和工具欄位於同一行,適合垂直空間有限的場景。simple:取消分組,所有工具排成一個平鋪列表,適合已熟悉各按鈕用途的使用者。
grid Ribbon 寬度不足時,整組會移入“更多”選單,並在其中改用緊湊版面配置;容器變寬後它們會恢復顯示。這一切換隨可用寬度自動發生,主工具欄仍使用已有的 gridLayout 配置。溢位選單中的命令、禁用狀態和權限檢查與主工具欄保持一致。
選單順序與網格佈局
menu 的鍵可以是 Ribbon 頁籤(如 ribbon.insert)、分組(如 ribbon.start.format)或選單項 ID。
order 按數值從小到大排序同級節點:Ribbon 中的頁籤、頁籤中的分組、分組或子選單中的選單項。它不會把選單項移到其他分組。鍵也可以不使用字串,而使用 @univerjs/ui 匯出的 RibbonPosition 和各分組列舉。
按所用的接入模式,把這些選項合併到現有的初始化配置中。其他外掛、語言、主題和容器設定均需保留,同一個外掛不要註冊兩次。
import type { MenuConfig } from '@univerjs/ui'const menu: MenuConfig = { 'ribbon.insert': { order: -1 }, 'ribbon.start.format': { order: -1 }, 'sheet.command.set-range-font-family': { order: 0, gridLayout: { row: 1, column: 1, width: 160 }, },}import { UniverUIPlugin } from '@univerjs/ui'univer.registerPlugin(UniverUIPlugin, { ribbonType: 'grid', menu,})import { UniverSheetsCorePreset } from '@univerjs/preset-sheets-core'import { createUniver } from '@univerjs/presets'const { univerAPI } = createUniver({ presets: [ UniverSheetsCorePreset({ ribbonType: 'grid', menu, }), ],})選取與拖曳
工作表邊界的鍵盤導覽
allowArrowKeyWrapOnSheetBoundary 決定方向鍵到達工作表邊界後是否繞到下一行或下一列。預設值為 true,設為 false 時停在邊界。選區內使用 Enter/Tab 迴圈切換不受影響。預設模式下放在 sheets 中,外掛模式下直接傳給 UniverSheetsUIPlugin。
selectionAnimation: false 關閉在單元格之間切換選區時的選區輪廓動畫,系統的減少動態效果設定優先。enableFillHandle: false 隱藏填充柄,填充命令和 Facade API 仍然可用。warnBeforeDragOverwrite: false 跳過拖動覆蓋已有內容前的確認提示,移動校驗和撤銷重做仍然生效。三個選項預設都是 true,可以放在 UniverSheetsCorePreset 的 sheets 中,也可以直接傳給 UniverSheetsUIPlugin。
univer.registerPlugin(UniverSheetsUIPlugin, { allowArrowKeyWrapOnSheetBoundary: false, selectionAnimation: false, enableFillHandle: false, warnBeforeDragOverwrite: false,})createUniver({ presets: [ UniverSheetsCorePreset({ sheets: { allowArrowKeyWrapOnSheetBoundary: false, selectionAnimation: false, enableFillHandle: false, warnBeforeDragOverwrite: false, }, }), ],})用 Facade API 更新選單
執行時更新
公開 Facade 會合並所做的修改並立即重新整理 UI。未指定的屬性沿用之前的值或 Schema 預設值,這些覆蓋對之後註冊的選單同樣生效。外掛模式下需要先匯入 @univerjs/ui/facade。
import '@univerjs/ui/facade'univerAPI.updateMenuConfig({ 'sheet.command.set-range-bold': { order: 0, gridLayout: { row: 2, column: 2 }, }, 'sheet.command.set-range-italic': { gridLayout: { row: 2, column: 1 }, },})gridLayout 僅在 ribbonType: 'grid' 時生效。每個分組固定兩行,row 和 column 都從 1 開始。座標是顯式的,因此只修改 order 不會移動顯式擺放的按鈕。交換兩個按鈕的位置時,兩個按鈕都要修改,否則會重疊。可選欄位包括 rowSpan、columnSpan、showLabel、width 和 iconSize,尺寸單位為畫素。約束和預設值見 IRibbonGridLayout。
自訂選單的位置
createMenu() 和 createSubmenu() 同樣接受 order 和 gridLayout。子選單中的這兩個欄位控制 Ribbon 上的觸發按鈕,而非彈層的內容。以下範例在歷史操作分組的第三列新增一個按鈕:
univerAPI .createMenu({ id: 'custom-action', title: 'Custom action', action: () => console.log('Custom action clicked'), order: 4, gridLayout: { row: 1, column: 3, showLabel: true, width: 96 }, }) .appendTo('ribbon.start.history')菜單項 ID 列表
以下各表按桌面版選單的出現位置整理。同一個選單項可能出現在多個位置,行標題和列標題選單也複用了一部分單元格右鍵選單。功能選單需要先註冊對應外掛,是否顯示還取決於權限和當前選中的內容。僅在行動版出現的 ID 單獨列在最後。
data-u-command 屬性即為該選單項的 ID。配置 menu 時使用的就是這個選單項 ID,它可能與選單項執行的命令 ID 不同。工具列菜單項
| 菜單項 ID | 菜單項名稱 |
|---|---|
| univer.command.undo | 復原 |
| univer.command.redo | 重做 |
| ui.operation.activate-format-painter | 複製格式 |
| sheet.command.set-range-bold | 粗體 |
| sheet.command.set-range-italic | 斜體 |
| sheet.command.set-range-underline | 底線 |
| sheet.command.set-range-stroke | 刪除線 |
| sheet.command.set-range-font-family | 字體 |
| sheet.command.set-range-fontsize | 字號 |
| sheet.command.set-range-text-color | 文字顏色 |
| sheet.command.set-background-color | 儲存格顏色 |
| sheet.command.set-border-basic | 邊框 |
| sheet.command.set-horizontal-text-align | 水平對齊 |
| sheet.command.set-vertical-text-align | 垂直對齊 |
| sheet.command.set-text-wrap | 文字換行 |
| sheet.command.set-text-rotation | 文字旋轉 |
| sheet.command.add-worksheet-merge | 合併儲存格 |
| sheet.command.add-worksheet-merge-all | 合併儲存格 - 全部合併 |
| sheet.command.add-worksheet-merge-vertical | 合併儲存格 - 垂直合併 |
| sheet.command.add-worksheet-merge-horizontal | 合併儲存格 - 水平合併 |
| sheet.command.remove-worksheet-merge | 合併儲存格 - 取消合併 |
| sheet.operation.open.conditional.formatting.panel | 條件式格式設定 |
| formula-ui.operation.insert-function.common | 常用函數 |
| formula-ui.operation.more-functions | 函數 - 更多函數 |
| sheet.menu.sheets-sort | 排序 |
| sheet.command.sort-range-asc | 排序 - 當前區域升冪 |
| sheet.command.sort-range-asc-ext | 排序 - 拓展區域升冪 |
| sheet.command.sort-range-desc | 排序 - 當前區域降冪 |
| sheet.command.sort-range-desc-ext | 排序 - 拓展區域降冪 |
| sheet.command.sort-range-custom | 排序 - 自訂排序 |
| sheet.menu.image | 圖片 |
| sheet.command.insert-float-image | 圖片 - 浮動圖片 |
| sheet.command.insert-cell-image | 圖片 - 儲存格圖片 |
| sheet.command.numfmt.set.currency | 貨幣 |
| sheet.command.numfmt.add.decimal.command | 增加小數位 |
| sheet.command.numfmt.subtract.decimal.command | 減少小數位 |
| sheet.command.numfmt.set.percent | 百分比 |
| sheet.operation.open.numfmt.panel | 數字格式 |
| sheet.menu.data-validation | 資料驗證 |
| data-validation.operation.open-validation-panel | 資料驗證 - 管理資料驗證 |
| data-validation.command.addRuleAndOpen | 資料驗證 - 新建規則 |
| sheet.command.smart-toggle-filter | 篩選 |
| sheet.command.clear-filter-criteria | 篩選 - 清除篩選條件 |
| sheet.command.re-calc-filter | 篩選 - 重新計算 |
| sheet.operation.open-pivot-table-range-selector-panel | 樞紐分析表 |
| sheet.menu.print | 列印 |
| sheet.operation.print-open | 列印 - 列印 |
| sheet.operation.open-print-grid-sidebar | 列印 - 列印佈局 |
| sheet.command.menu-insert-chart | 插入圖表 |
| sheet.command.add-range-protection-from-toolbar | 保護 |
| univer.operation.toggle-edit-history | 歷史記錄 |
| sheet.operation.open-sparkline-selector | 走勢圖 |
| sheet.operation.toggle-comment-panel | 評論管理 |
| sheet.operation.insert-hyper-link-toolbar | 插入連結 |
| ui.operation.open-find-dialog | 尋找與取代 |
| base-ui.operation.toggle-shortcut-panel | 打開收起快速鍵面板 |
| sheet.command.add-data-bar-conditional-rule | 資料條 |
| sheet.command.add-icon-set-conditional-rule | 圖示集 |
| sheet.operation.toggle-crosshair-highlight | 十字高亮 |
| data-validation.command.insert-quick-rule | 複選框 |
| sheet.menu.quick-dropdown | 下拉選單 |
| sheet.menu.quick-date | 日期 |
| sheet.menu.worksheet-background-image | 背景圖片 |
| sheet.command.add-worksheet-background-image | 新增背景圖片 |
| sheet.command.delete-worksheet-background-image | 刪除背景圖片 |
| formula-ui.operation.insert-function.financial | 財務 |
| formula-ui.operation.insert-function.logical | 邏輯 |
| formula-ui.operation.insert-function.text | 文字 |
| formula-ui.operation.insert-function.date | 日期與時間 |
| formula-ui.operation.insert-function.lookup | 尋找與引用 |
| formula-ui.operation.insert-function.math | 數學與三角函數 |
| formula-ui.operation.insert-function.statistical | 統計 |
| formula-ui.operation.insert-function.engineering | 工程 |
| formula-ui.operation.insert-function.information | 訊息 |
| formula-ui.operation.insert-function.database | 資料庫 |
| sheets-formula-ui.operation.calculation-options | 計算選項 |
| sheet.operation.open-table-selector | 表格 |
| sheet.menu.paste | 貼上 |
| sheet.command.set-range-font-increase | 放大字型 |
| sheet.command.set-range-font-decrease | 縮小字型 |
| sheet.command.reset-range-text-color | 字型顏色 - 重置顏色 |
| sheet.command.reset-background-color | 填滿色彩 - 重置顏色 |
| sheet.command.set-shrink-to-fit | 縮小字型填滿 |
| sheet.toolbar.sheet-frozen | 凍結窗格 |
| sheet.menu.zoom-ratio | 縮放 |
| sheet.command.toggle-gridlines | 切換網格線 |
| base-ui.operation.toggle-fullscreen | 全螢幕 |
| ui.command.clear-formatting | 清除格式 |
| ui.operation.open-feature-search | 搜尋功能 |
| sheet.toolbar.dimension-outline.group | 群組 |
| sheet.command.menu-insert-pivot-chart | 樞紐分析圖 |
| sheet.pivot-chart.insert | 樞紐分析圖 |
| sheet.command.menu-insert-shape | 插入形狀 |
| sheet.operation.open-shape-object-list-panel | 圖層 |
| sheet.operation.open-slicer-insert-dialog | 插入交叉分析篩選器 |
| sheet.menu.insert-timeline | 插入時間表 |
右鍵菜單項
| 菜單項 ID | 菜單項名稱 |
|---|---|
| sheet.command.copy | 複製 |
| sheet.command.cut | 剪下 |
| sheet.command.paste | 貼上 |
| sheet.menu.copy-special | 選擇性複製 |
| sheet.command.copy-formula-only | 選擇性複製 - 僅複製公式 |
| sheet.menu.paste-special | 選擇性貼上 |
| sheet.command.paste-value | 選擇性貼上 - 僅貼上值 |
| sheet.command.paste-format | 選擇性貼上 - 僅貼上格式 |
| sheet.command.paste-col-width | 選擇性貼上 - 僅貼上欄寬 |
| sheet.command.paste-besides-border | 選擇性貼上 - 僅貼上邊框以外內容 |
| sheet.command.paste-formula | 選擇性貼上 - 僅貼上公式 |
| sheet.menu.clear-selection | 清除 |
| sheet.command.clear-selection-content | 清除 - 清除內容 |
| sheet.command.clear-selection-format | 清除 - 清除格式 |
| sheet.command.clear-selection-all | 清除 - 清除全部 |
| sheet.contextMenu.text-to-number | 文字轉數字 |
| sheet.menu.cell-insert | 插入 |
| sheet.command.insert-row-before | 插入 - 在上方插入行 |
| sheet.command.insert-col-before | 插入 - 在左側插入列 |
| sheet.command.insert-range-move-right-confirm | 插入 - 右移 |
| sheet.command.insert-range-move-down-confirm | 插入 - 下移 |
| sheet.menu.delete | 刪除 |
| sheet.command.remove-row-confirm | 刪除選中行 |
| sheet.command.remove-col-confirm | 刪除選中列 |
| sheet.command.delete-range-move-left-confirm | 刪除 - 左移 |
| sheet.command.delete-range-move-up-confirm | 刪除 - 上移 |
| sheet.menu.sheet-frozen | 凍結 |
| sheet.command.set-selection-frozen | 凍結 - 凍結 |
| sheet.command.set-row-frozen | 凍結 - 凍結行 |
| sheet.command.set-col-frozen | 凍結 - 凍結列 |
| sheet.command.cancel-frozen | 凍結 - 取消凍結 |
| sheet.contextMenu.permission | 保護行列 |
| sheet.command.add-range-protection-from-context-menu | 保護行列 - 新增保護範圍 |
| sheet.command.set-range-protection-from-context-menu | 保護行列 - 設置保護範圍 |
| sheet.command.delete-range-protection-from-context-menu | 保護行列 - 移除保護範圍 |
| sheet.command.view-sheet-permission-from-context-menu | 保護行列 - 查看所有保護範圍 |
| sheet.menu.sheets-sort-ctx | 排序 |
| sheet.command.sort-range-asc-ctx | 排序 - 當前區域升冪 |
| sheet.command.sort-range-asc-ext-ctx | 排序 - 拓展區域升冪 |
| sheet.command.sort-range-desc-ctx | 排序 - 當前區域降冪 |
| sheet.command.sort-range-desc-ext-ctx | 排序 - 拓展區域降冪 |
| sheet.command.sort-range-custom-ctx | 排序 - 自訂排序 |
| sheet.operation.show-comment-modal | 添加評論 |
| sheet.operation.insert-hyper-link | 添加連結 |
| sheet.operation.screenshot | 複製為截圖 |
| sheet.command.save-cell-images | 儲存儲存格圖片 |
| sheet.operation.add-note-popup | 新增批註 |
| sheet.command.delete-note | 刪除批註 |
| sheet.command.toggle-note-popup | 顯示/隱藏批註 |
| sheet.table.context-insert_menu-id | 表格插入 |
| sheet.command.table-insert-row | 插入表格列 |
| sheet.command.table-insert-col | 插入表格欄 |
| sheet.table.context-remove_menu-id | 表格刪除 |
| sheet.command.table-remove-row | 刪除表格列 |
| sheet.command.table-remove-col | 刪除表格欄 |
| sheet.command.set-first-row-frozen | 凍結第一列 |
| sheet.command.set-first-column-frozen | 凍結第一欄 |
| sheet.sparkline.context-menu-id | 迷你圖 |
| sheet.operation.open-sparkline-panel | 編輯迷你圖 |
| sheet.command.remove-sparkline | 刪除迷你圖 |
右鍵菜單項 - 行標題
| 菜單項 ID | 菜單項名稱 |
|---|---|
| sheet.command.insert-multi-rows-above | 在上方插入行 |
| sheet.command.insert-multi-rows-after | 在下方插入行 |
| sheet.command.hide-row-confirm | 隱藏選中行 |
| sheet.command.set-selected-rows-visible | 顯示隱藏行 |
| sheet.command.set-row-height | 列高 |
| sheet.command.set-row-is-auto-height | 自動調整 |
| sheet.row-header-menu.sheet-frozen | 凍結窗格 |
| sheet.contextMenu.dimension-outline | 群組 |
右鍵菜單項 - 列標題
| 菜單項 ID | 菜單項名稱 |
|---|---|
| sheet.command.insert-multi-cols-before | 在左側插入列 |
| sheet.command.insert-multi-cols-right | 在右側插入列 |
| sheet.command.hide-col-confirm | 隱藏選中列 |
| sheet.command.set-selected-cols-visible | 顯示隱藏列 |
| sheet.command.set-worksheet-col-width | 欄寬 |
| sheet.command.set-col-auto-width | 自動調整 |
| sheet.column-header-menu.sheet-frozen | 凍結窗格 |
| sheet.contextMenu.dimension-outline | 群組 |
右鍵菜單項 - 工作表標籤
| 菜單項 ID | 菜單項名稱 |
|---|---|
| sheet.command.remove-sheet-confirm | 刪除 |
| sheet.command.copy-sheet | 複製 |
| sheet.operation.rename-sheet | 重新命名 |
| sheet.command.set-tab-color | 更改顏色 |
| sheet.command.set-worksheet-hidden | 隱藏 |
| ui-sheet.command.show-menu-list | 取消隱藏 |
| sheet.command.add-range-protection-from-sheet-bar | 保護工作表 |
| sheet.command.delete-worksheet-protection-from-sheet-bar | 取消保護工作表 |
| sheet.command.change-sheet-protection-from-sheet-bar | 更改工作表權限 |
| sheet.command.view-sheet-permission-from-sheet-bar | 查看所有保護範圍 |
樞紐分析表與樞紐分析圖右鍵菜單項
| 菜單項 ID | 菜單項名稱 |
|---|---|
| sheet.pivot-chart.expand-collapse | 展開/摺疊 |
| sheet.pivot.context-menu.date-group | 日期分組 |
| sheet.pivot.context-menu.excel-date-group | 日期分組 |
| sheet.pivot.context-menu.number-group | 數值分組 |
| sheet.pivot.context-menu.manual-group | 群組項目 |
| sheet.pivot.context-menu.manual-rename | 重新命名群組 |
| sheet.pivot.context-menu.manual-ungroup | 取消群組 |
| sheet.pivot.context-menu.show-data-as | 值顯示方式 |
| sheet.pivot.context-menu.value-filter | 值篩選 |
| sheet.pivot.context-menu.date-group.year | 日期分組 - 年 |
| sheet.pivot.context-menu.date-group.year-quarter | 日期分組 - 年-季 |
| sheet.pivot.context-menu.date-group.quarter | 日期分組 - 季 |
| sheet.pivot.context-menu.date-group.year-month | 日期分組 - 年-月 |
| sheet.pivot.context-menu.date-group.month | 日期分組 - 月 |
| sheet.pivot.context-menu.date-group.month-date | 日期分組 - 月-日 |
| sheet.pivot.context-menu.date-group.year-month-date | 日期分組 - 年-月-日 |
| sheet.pivot.context-menu.date-group.date | 日期分組 - 日 |
| sheet.pivot.context-menu.date-group.hour | 日期分組 - 小時 |
| sheet.pivot.context-menu.date-group.minute | 日期分組 - 分鐘 |
| sheet.pivot.context-menu.date-group.hour-minute | 日期分組 - 小時-分鐘 |
| sheet.pivot.context-menu.show-data-as.1 | 值顯示方式 - 無計算 |
| sheet.pivot.context-menu.show-data-as.4 | 值顯示方式 - 總計百分比 |
| sheet.pivot.context-menu.show-data-as.3 | 值顯示方式 - 列總計百分比 |
| sheet.pivot.context-menu.show-data-as.2 | 值顯示方式 - 欄總計百分比 |
| sheet.pivot.context-menu.show-data-as.6 | 值顯示方式 - 上層列總計百分比 |
| sheet.pivot.context-menu.show-data-as.5 | 值顯示方式 - 上層欄總計百分比 |
| sheet.pivot.context-menu.show-data-as.8 | 值顯示方式 - 指數 |
| sheet.pivot.context-menu.show-data-as.14 | 值顯示方式 - 上層總計百分比 |
| sheet.pivot.context-menu.show-data-as.13 | 值顯示方式 - 百分比 |
| sheet.pivot.context-menu.show-data-as.9 | 值顯示方式 - 差異 |
| sheet.pivot.context-menu.show-data-as.10 | 值顯示方式 - 差異百分比 |
| sheet.pivot.context-menu.show-data-as.11 | 值顯示方式 - 累計 |
| sheet.pivot.context-menu.show-data-as.12 | 值顯示方式 - 累計百分比 |
| sheet.pivot.context-menu.show-data-as.15 | 值顯示方式 - 由小至大排名 |
| sheet.pivot.context-menu.show-data-as.16 | 值顯示方式 - 由大至小排名 |
繪圖與圖表菜單項
| 菜單項 ID | 菜單項名稱 |
|---|---|
| contextMenu.drawing-group | 組合 |
| drawing.operation.set-drawing-group | 組合 |
| drawing.operation.cancel-drawing-group | 取消組合 |
| contextMenu.drawing-arrange | 排列 |
| drawing.operation.set-drawing-arrange-front | 置於頂層 |
| drawing.operation.set-drawing-arrange-forward | 上移一層 |
| drawing.operation.set-drawing-arrange-back | 置於底層 |
| drawing.operation.set-drawing-arrange-backward | 下移一層 |
| contextMenu.drawing-align | 對齊方式 |
| sheet.operation.set-drawing-align-left | 左對齊 |
| sheet.operation.set-drawing-align-center | 水平居中 |
| sheet.operation.set-drawing-align-right | 右對齊 |
| sheet.operation.set-drawing-align-top | 頂部對齊 |
| sheet.operation.set-drawing-align-middle | 垂直居中 |
| sheet.operation.set-drawing-align-bottom | 底部對齊 |
| sheet.operation.set-drawing-align-horizon | 水平分佈 |
| sheet.operation.set-drawing-align-vertical | 垂直分佈 |
| sheet.operation.add-drawing-comment | 新增評論 |
| sheet.command.chart.open-focused-panel | 開啟圖表面板 |
| sheet.command.chart.copy-focused-chart | 複製 |
| sheet.command.chart.export-focused-image | 匯出圖片 |
| sheet.command.chart.delete-focused-chart | 刪除圖表 |
上下文工具列菜單項
選中對應的形狀、切片器或時間線時,這些控制元件才會顯示。
| 菜單項 ID | 菜單項名稱 |
|---|---|
| sheet.operation.apply-shape-quick-style | 快捷樣式 |
| sheet.operation.update-shape-type | 變更圖形 |
| sheets-shape-ui.ribbon.shape-format.style-control | 圖形樣式控制項 |
| sheets-shape-ui.ribbon.shape-format.text-control | 圖形文字控制項 |
| sheet.menu.shape.flip-horizontal | 水平翻轉 |
| sheet.menu.shape.flip-vertical | 垂直翻轉 |
| sheets-shape-ui.ribbon.shape-format.arrange-forward | 上移一層 |
| sheets-shape-ui.ribbon.shape-format.arrange-backward | 下移一層 |
| sheets-shape-ui.ribbon.shape-format.arrange-front | 置於頂層 |
| sheets-shape-ui.ribbon.shape-format.arrange-back | 置於底層 |
| sheets-shape-ui.ribbon.shape-format.formula-control | 公式圖形控制項 |
| sheet.operation.open-sheet-shape-format-panel | 格式化形狀 |
| shape-editor-ui.operation.toggle-floating-toolbar | 浮動工具列 |
| sheet.menu.slicer-quick-style | 快速樣式 |
| sheet.menu.slicer-settings | 交叉分析篩選器設定 |
| sheet.menu.timeline-settings | 時間表設定 |
| sheet.menu.slicer-connections | 報表連線 |
行動端專用菜單項
| 菜單項 ID | 菜單項名稱 |
|---|---|
| sheet.menu.mobile.crosshair-highlight | 十字高亮 |
| sheet.menu.mobile.numfmt | 數字格式 |
| sheet.command.set-once-format-painter | 複製格式 |
你覺得這篇文檔如何?