FWorkbook
Facade API object bounded to a workbook. It provides a set of methods to interact with the workbook.
Get this object from the initialized univerAPI instance. The example assumes a workbook is already open.
const workbook = univerAPI.getActiveWorkbook()if (!workbook) throw new Error('No active workbook')console.log(workbook.getSheets().map((sheet) => sheet.getName()))Access
Access through:
FUniver.createWorkbook()FUniver.getActiveWorkbook()FUniver.getWorkbook()FUniver.getSheetCommandTarget()FUniver.getActiveSheet()FCollaboration.loadSheetAsync()
Setup
Register @univerjs/sheets or a preset that includes it. In plugin mode, import @univerjs/sheets/facade. Additional methods below require their listed plugin packages. See Facade setup.
@univerjs/sheets
FWorkbook.addStyles
Add styles to the workbook styles.
addStyles(styles: Record<string, IStyleData>): voidParameters
styles— Required. Styles to add
Examples
const fWorkbook = univerAPI.getActiveWorkbook()// Add styles to the workbook stylesconst styles = { 'custom-style-1': { bg: { rgb: 'rgb(255, 0, 0)', }, }, 'custom-style-2': { fs: 20, n: { pattern: '@', }, },}fWorkbook.addStyles(styles)// Set values with the new stylesconst fWorksheet = fWorkbook.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')const fRange = fWorksheet.getRange('A1:B2')fRange.setValues([ [ { v: 'Hello', s: 'custom-style-1' }, { v: 'Univer', s: 'custom-style-1' }, ], [ { v: 'To', s: 'custom-style-1' }, { v: '0001', s: 'custom-style-2' }, ],])Types: Record · IStyleData
Package: @univerjs/sheets · Type definitions
FWorkbook.create
Create a new worksheet and returns a handle to it.
create(name: string, rows: number, columns: number, options?: { index?: number; sheet?: Partial<IWorksheetData>; }): FWorksheetParameters
name— Required. Name of the new sheetrows— Required. How many rows would the new sheet havecolumns— Required. How many columns would the new sheet haveoptions— Optional. The options for the new sheet
Returns
The new created sheet
Examples
const fWorkbook = univerAPI.getActiveWorkbook()// Create a new sheet named 'MyNewSheet' with 10 rows and 10 columnsconst newSheet = fWorkbook.create('MyNewSheet', 10, 10)console.log(newSheet)// Create a new sheet named 'MyNewSheetWithData' with 10 rows and 10 columns and some data, and set it as the first sheetconst sheetData = { // ... Omit other properties cellData: { 0: { 0: { v: 'Hello Univer!', }, }, }, // ... Omit other properties}const newSheetWithData = fWorkbook.create('MyNewSheetWithData', 10, 10, { index: 0, sheet: sheetData,})console.log(newSheetWithData)Types: FWorksheet · Partial · IWorksheetData
Package: @univerjs/sheets · Type definitions
FWorkbook.createRangeThemeStyle
Create a range theme style.
createRangeThemeStyle(themeName: string, themeStyleJson?: Omit<IRangeThemeStyleJSON, 'name'>): RangeThemeStyleParameters
themeName— Required. The name of the theme to registerthemeStyleJson— Optional. The theme style json to register
Returns
- The created range theme style
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const rangeThemeStyle = fWorkbook.createRangeThemeStyle('MyTheme', { secondRowStyle: { bg: { rgb: 'rgb(214,231,241)', }, },})console.log(rangeThemeStyle)Types: RangeThemeStyle · Omit · IRangeThemeStyleJSON
Package: @univerjs/sheets · Type definitions
FWorkbook.deleteActiveSheet
Deletes the currently active sheet.
deleteActiveSheet(): booleanReturns
true if the sheet was deleted, false otherwise
Examples
const fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.deleteActiveSheet()Package: @univerjs/sheets · Type definitions
FWorkbook.deleteDefinedName
Delete the defined name with the given name.
deleteDefinedName(name: string): booleanParameters
name— Required. The name of the defined name to delete
Returns
true if the defined name was deleted, false otherwise
Examples
// The code below deletes the defined name with the given nameconst fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.deleteDefinedName('MyDefinedName')Package: @univerjs/sheets · Type definitions
FWorkbook.deleteSheet
Deletes the specified worksheet.
deleteSheet(sheet: FWorksheet | string): booleanParameters
sheet— Required. The instance or id of the worksheet to delete.
Returns
True if the worksheet was deleted, false otherwise.
Examples
// The code below deletes the specified worksheetconst fWorkbook = univerAPI.getActiveWorkbook()const sheet = fWorkbook.getSheets()[1]fWorkbook.deleteSheet(sheet)// The code below deletes the specified worksheet by id// fWorkbook.deleteSheet(sheet.getSheetId());Types: FWorksheet
Package: @univerjs/sheets · Type definitions
FWorkbook.dispose
Releases this facade's resources. Use univerAPI.disposeUnit() to unload the owning unit.
dispose(): voidPackage: @univerjs/sheets · Type definitions
FWorkbook.duplicateActiveSheet
Duplicates the active sheet.
duplicateActiveSheet(): FWorksheetReturns
The duplicated worksheet
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const duplicatedSheet = fWorkbook.duplicateActiveSheet()console.log(duplicatedSheet)Types: FWorksheet
Package: @univerjs/sheets · Type definitions
FWorkbook.duplicateSheet
Duplicates the given worksheet.
duplicateSheet(sheet: FWorksheet): FWorksheetParameters
sheet— Required. The worksheet to duplicate.
Returns
The duplicated worksheet
Examples
// The code below duplicates the given worksheetconst fWorkbook = univerAPI.getActiveWorkbook()const activeSheet = fWorkbook.getSheetByName('Sheet1')if (!activeSheet) throw new Error('activeSheet is not available')const duplicatedSheet = fWorkbook.duplicateSheet(activeSheet)console.log(duplicatedSheet)Types: FWorksheet
Package: @univerjs/sheets · Type definitions
FWorkbook.getActiveCell
Returns the active cell in this spreadsheet.
getActiveCell(): FRange | nullReturns
The active cell
Examples
const fWorkbook = univerAPI.getActiveWorkbook()console.log(fWorkbook.getActiveCell().getA1Notation())Types: FRange
Package: @univerjs/sheets · Type definitions
FWorkbook.getActiveRange
Returns the selected range in the active sheet, or null if there is no active range.
getActiveRange(): FRange | nullReturns
The active range
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const activeRange = fWorkbook.getActiveRange()console.log(activeRange)Types: FRange
Package: @univerjs/sheets · Type definitions
FWorkbook.getActiveSheet
Get the active sheet of the workbook.
getActiveSheet(): FWorksheetReturns
The active sheet of the workbook
Examples
// The code below gets the active sheet of the workbookconst fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getActiveSheet()if (!fWorksheet) throw new Error('fWorksheet is not available')console.log(fWorksheet)Types: FWorksheet
Package: @univerjs/sheets · Type definitions
FWorkbook.getCustomMetadata
Get custom metadata of workbook
getCustomMetadata(): CustomData | undefinedReturns
custom metadata
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const custom = fWorkbook.getCustomMetadata()console.log(custom)Types: CustomData
Package: @univerjs/sheets · Type definitions
FWorkbook.getDefinedName
Get the defined name by name.
getDefinedName(name: string): FDefinedName | nullParameters
name— Required. The name of the defined name to get
Returns
The defined name with the given name
Examples
// The code below gets the defined name by nameconst fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedName('MyDefinedName')console.log(definedName?.getFormulaOrRefString())Types: FDefinedName
Package: @univerjs/sheets · Type definitions
FWorkbook.getDefinedNames
Get all the defined names in the workbook.
getDefinedNames(): FDefinedName[]Returns
All the defined names in the workbook
Examples
// The code below gets all the defined names in the workbookconst fWorkbook = univerAPI.getActiveWorkbook()const definedNames = fWorkbook.getDefinedNames()console.log(definedNames, definedNames[0]?.getFormulaOrRefString())Types: FDefinedName
Package: @univerjs/sheets · Type definitions
FWorkbook.getId
Get the id of the workbook.
getId(): stringReturns
The id of the workbook.
Examples
// The code below gets the id of the workbookconst fWorkbook = univerAPI.getActiveWorkbook()const unitId = fWorkbook.getId()console.log(unitId)Package: @univerjs/sheets · Type definitions
FWorkbook.getName
Get the name of the workbook.
getName(): stringReturns
The name of the workbook.
Examples
// The code below gets the name of the workbookconst fWorkbook = univerAPI.getActiveWorkbook()const name = fWorkbook.getName()console.log(name)Package: @univerjs/sheets · Type definitions
FWorkbook.getNumSheets
Get the number of sheets in the workbook.
getNumSheets(): numberReturns
The number of sheets in the workbook
Examples
// The code below gets the number of sheets in the workbookconst fWorkbook = univerAPI.getActiveWorkbook()console.log(fWorkbook.getNumSheets())Package: @univerjs/sheets · Type definitions
FWorkbook.getRegisteredRangeThemes
Gets the registered range themes.
getRegisteredRangeThemes(): string[]Returns
The name list of registered range themes.
Examples
// The code below gets the registered range themesconst fWorkbook = univerAPI.getActiveWorkbook()const themes = fWorkbook.getRegisteredRangeThemes()console.log(themes)Package: @univerjs/sheets · Type definitions
FWorkbook.getSheetByName
Get a worksheet by sheet name.
getSheetByName(name: string): FWorksheet | nullParameters
name— Required. The name of the sheet to get.
Returns
The worksheet with given sheet name
Examples
// The code below gets a worksheet by sheet nameconst fWorkbook = univerAPI.getActiveWorkbook()const sheet = fWorkbook.getSheetByName('Sheet1')console.log(sheet)Types: FWorksheet
Package: @univerjs/sheets · Type definitions
FWorkbook.getSheetBySheetId
Get a worksheet by sheet id.
getSheetBySheetId(sheetId: string): FWorksheet | nullParameters
sheetId— Required. The id of the sheet to get.
Returns
The worksheet with given sheet id
Examples
// The code below gets a worksheet by sheet idconst fWorkbook = univerAPI.getActiveWorkbook()const sheet = fWorkbook.getSheetBySheetId('sheetId')console.log(sheet)Types: FWorksheet
Package: @univerjs/sheets · Type definitions
FWorkbook.getSheets
Gets all the worksheets in this workbook
getSheets(): FWorksheet[]Returns
An array of all the worksheets in the workbook
Examples
// The code below gets all the worksheets in the workbookconst fWorkbook = univerAPI.getActiveWorkbook()const sheets = fWorkbook.getSheets()console.log(sheets)Types: FWorksheet
Package: @univerjs/sheets · Type definitions
FWorkbook.getUrl
Get the URL of the workbook.
getUrl(): stringReturns
The URL of the workbook
Examples
// The code below gets the URL of the workbookconst fWorkbook = univerAPI.getActiveWorkbook()const url = fWorkbook.getUrl()console.log(url)Package: @univerjs/sheets · Type definitions
FWorkbook.getWorkbook
Get the Workbook instance.
getWorkbook(): WorkbookReturns
The Workbook instance.
Examples
// The code below gets the Workbook instanceconst fWorkbook = univerAPI.getActiveWorkbook()const workbook = fWorkbook.getWorkbook()console.log(workbook)Types: Workbook
Package: @univerjs/sheets · Type definitions
FWorkbook.getWorkbookPermission
Get the WorkbookPermission instance for managing workbook-level permissions. This is the new permission API that provides a more intuitive and type-safe interface.
getWorkbookPermission(): FWorkbookPermissionReturns
- The WorkbookPermission instance.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const permission = fWorkbook.getWorkbookPermission()// Set workbook to read-only modeawait permission.setMode('viewer')// Add a collaboratorawait permission.addCollaborator({ userId: 'user123', name: 'John Doe', role: 'editor',})// Subscribe to permission changespermission.permission$.subscribe((snapshot) => { console.log('Permissions changed:', snapshot)})Types: FWorkbookPermission
Package: @univerjs/sheets · Type definitions
FWorkbook.id
The workbook unit id used to identify this workbook in commands and snapshots.
readonly id: stringPackage: @univerjs/sheets · Type definitions
FWorkbook.insertDefinedName
Insert a defined name.
insertDefinedName(name: string, formulaOrRefString: string): FWorkbookParameters
name— Required. The name of the defined name to insertformulaOrRefString— Required. The formula(=sum(A2:b10)) or reference(A1) string of the defined name to insert
Returns
The current FWorkbook instance
Examples
// The code below inserts a defined nameconst fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.insertDefinedName('MyDefinedName', 'Sheet1!$A$1')Types: FWorkbook
Package: @univerjs/sheets · Type definitions
FWorkbook.insertDefinedNameBuilder
Insert a defined name by builder param.
insertDefinedNameBuilder(param: ISetDefinedNameMutationParam): voidParameters
param— Required. The param to insert the defined name
Examples
// The code below inserts a defined name by builder paramconst fWorkbook = univerAPI.getActiveWorkbook()const definedNameParam = fWorkbook .newDefinedNameBuilder() .setRef('Sheet1!$A$1') .setName('MyDefinedName') .setComment('This is a comment') .build()fWorkbook.insertDefinedNameBuilder(definedNameParam)Types: ISetDefinedNameMutationParam
Package: @univerjs/sheets · Type definitions
FWorkbook.insertSheet
Inserts a new worksheet into the workbook. Using a default sheet name. The new sheet becomes the active sheet
insertSheet(sheetName?: string, options?: { index?: number; sheet?: Partial<IWorksheetData>; }): FWorksheetParameters
sheetName— Optional. The name of the new sheetoptions— Optional. The options for the new sheet
Returns
The new sheet
Examples
const fWorkbook = univerAPI.getActiveWorkbook()// Create a new sheet with default configurationconst newSheet = fWorkbook.insertSheet()console.log(newSheet)// Create a new sheet with custom name and default configurationconst newSheetWithName = fWorkbook.insertSheet('MyNewSheet')console.log(newSheetWithName)// Create a new sheet with custom name and custom configurationconst sheetData = { // ... Omit other properties cellData: { 0: { 0: { v: 'Hello Univer!', }, }, }, // ... Omit other properties}const newSheetWithData = fWorkbook.insertSheet('MyNewSheetWithData', { index: 0, sheet: sheetData,})console.log(newSheetWithData)Types: FWorksheet · Partial · IWorksheetData
Package: @univerjs/sheets · Type definitions
FWorkbook.moveActiveSheet
Move the active sheet to the specified index.
moveActiveSheet(index: number): FWorkbookParameters
index— Required. The index to move the active sheet to
Returns
This workbook, for chaining
Examples
// The code below moves the active sheet to the specified indexconst fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.moveActiveSheet(1)Types: FWorkbook
Package: @univerjs/sheets · Type definitions
FWorkbook.moveSheet
Move the sheet to the specified index.
moveSheet(sheet: FWorksheet, index: number): FWorkbookParameters
sheet— Required. The sheet to moveindex— Required. The index to move the sheet to
Returns
This workbook, for chaining
Examples
// The code below moves the sheet to the specified indexconst fWorkbook = univerAPI.getActiveWorkbook()const sheet = fWorkbook.getSheetByName('Sheet1')if (!sheet) throw new Error('sheet is not available')fWorkbook.moveSheet(sheet, 1)Types: FWorkbook · FWorksheet
Package: @univerjs/sheets · Type definitions
FWorkbook.newDefinedNameBuilder
Create a new defined name builder.
newDefinedNameBuilder(): FDefinedNameBuilderReturns
- The defined name builder.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const definedNameParam = fWorkbook .newDefinedNameBuilder() .setRef('Sheet1!$A$1') .setName('MyDefinedName') .setComment('This is a comment') .build()console.log(definedNameParam)fWorkbook.insertDefinedNameBuilder(definedNameParam)Types: FDefinedNameBuilder
Package: @univerjs/sheets · Type definitions
FWorkbook.onBeforeCommandExecute
Callback for command execution.
Register a callback that will be triggered before invoking a command targeting the Univer sheet.
onBeforeCommandExecute(callback: CommandListener): IDisposableParameters
callback— Required. the callback.
Returns
A function to dispose the listening.
Examples
// The code below registers a callback that will be triggered before invoking a command targeting the Univer sheetconst fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.onBeforeCommandExecute((command) => { console.log('Before command execute:', command)})Types: IDisposable · CommandListener
Package: @univerjs/sheets · Type definitions
FWorkbook.onCommandExecuted
Callback for command execution.
Register a callback that will be triggered when a command is invoked targeting the Univer sheet.
onCommandExecuted(callback: CommandListener): IDisposableParameters
callback— Required. the callback.
Returns
A function to dispose the listening.
Examples
// The code below registers a callback that will be triggered when a command is invoked targeting the Univer sheetconst fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.onCommandExecuted((command) => { console.log('Command executed:', command)})Types: IDisposable · CommandListener
Package: @univerjs/sheets · Type definitions
FWorkbook.onSelectionChange
Callback for selection changes.
Register a callback that will be triggered when the selection changes.
onSelectionChange(callback: (selections: IRange[]) => void): IDisposableParameters
callback— Required. The callback.
Returns
A function to dispose the listening
Examples
// The code below registers a callback that will be triggered when the selection changesconst fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.onSelectionChange((selections) => { console.log('Selection changed:', selections)})Types: IDisposable · IRange
Package: @univerjs/sheets · Type definitions
FWorkbook.redo
Redo the last undone action.
redo(): FWorkbookReturns
This workbook, for chaining.
Examples
// The code below redoes the last undone actionconst fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.redo()Types: FWorkbook
Package: @univerjs/sheets · Type definitions
FWorkbook.registerRangeTheme
Register a custom range theme style.
registerRangeTheme(rangeThemeStyle: RangeThemeStyle): voidParameters
rangeThemeStyle— Required. The range theme style to register
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const rangeThemeStyle = fWorkbook.createRangeThemeStyle('MyTheme', { secondRowStyle: { bg: { rgb: 'rgb(214,231,241)', }, },})fWorkbook.registerRangeTheme(rangeThemeStyle)Types: RangeThemeStyle
Package: @univerjs/sheets · Type definitions
FWorkbook.removeStyles
Remove styles from the workbook styles.
removeStyles(styleKeys: string[]): voidParameters
styleKeys— Required. Style keys to remove
Examples
const fWorkbook = univerAPI.getActiveWorkbook()// Add styles to the workbook stylesconst styles = { 'custom-style-1': { bg: { rgb: 'rgb(255, 0, 0)', }, }, 'custom-style-2': { fs: 20, n: { pattern: '@', }, },}fWorkbook.addStyles(styles)// Set values with the new stylesconst fWorksheet = fWorkbook.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')const fRange = fWorksheet.getRange('A1:B2')fRange.setValues([ [ { v: 'Hello', s: 'custom-style-1' }, { v: 'Univer', s: 'custom-style-1' }, ], [ { v: 'To', s: 'custom-style-1' }, { v: '0001', s: 'custom-style-2' }, ],])// Remove the style `custom-style-1` after 2 secondssetTimeout(() => { fWorkbook.removeStyles(['custom-style-1']) fWorksheet.refreshCanvas()}, 2000)Package: @univerjs/sheets · Type definitions
FWorkbook.save
Save workbook snapshot data, including conditional formatting, data validation, and other plugin data.
save(): IWorkbookDataReturns
Workbook snapshot data
Examples
// The code below saves the workbook snapshot dataconst fWorkbook = univerAPI.getActiveWorkbook()const snapshot = fWorkbook.save()console.log(snapshot)Types: IWorkbookData
Package: @univerjs/sheets · Type definitions
FWorkbook.setActiveRange
Sets the selection region for active sheet.
setActiveRange(range: FRange): FWorkbookParameters
range— Required. The range to set as the active selection.
Returns
FWorkbook instance
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')const range = fWorksheet.getRange('A10:B10')fWorkbook.setActiveRange(range)Package: @univerjs/sheets · Type definitions
FWorkbook.setActiveSheet
Sets the given worksheet to be the active worksheet in the workbook.
setActiveSheet(sheet: FWorksheet | string): FWorksheetParameters
sheet— Required. The instance or id of the worksheet to set as active.
Returns
The active worksheet
Examples
// The code below sets the given worksheet to be the active worksheetconst fWorkbook = univerAPI.getActiveWorkbook()const sheet = fWorkbook.getSheets()[1]fWorkbook.setActiveSheet(sheet)Types: FWorksheet
Package: @univerjs/sheets · Type definitions
FWorkbook.setCustomMetadata
Set custom metadata of workbook
setCustomMetadata(custom: CustomData | undefined): FWorkbookParameters
custom— Required. custom metadata
Returns
FWorkbook
Examples
const fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.setCustomMetadata({ key: 'value' })Types: FWorkbook · CustomData
Package: @univerjs/sheets · Type definitions
FWorkbook.setEditable
Used to modify the editing permissions of the workbook. When the value is false, editing is not allowed.
setEditable(value: boolean): FWorkbookParameters
value— Required. editable value want to set
Returns
FWorkbook instance
Examples
// The code below sets the editing permissions of the workbookconst fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.setEditable(false)Types: FWorkbook
Package: @univerjs/sheets · Type definitions
FWorkbook.setName
Set the name of the workbook.
setName(name: string): thisParameters
name— Required. The new name of the workbook.
Returns
The current FWorkbook instance for chaining.
Examples
// The code below sets the name of the workbookconst fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.setName('MyWorkbook')Package: @univerjs/sheets · Type definitions
FWorkbook.undo
Undo the last action.
undo(): FWorkbookReturns
This workbook, for chaining.
Examples
// The code below undoes the last actionconst fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.undo()Types: FWorkbook
Package: @univerjs/sheets · Type definitions
FWorkbook.unregisterRangeTheme
Unregister a custom range theme style.
unregisterRangeTheme(themeName: string): voidParameters
themeName— Required. The name of the theme to unregister
Examples
const fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.unregisterRangeTheme('MyTheme')Package: @univerjs/sheets · Type definitions
FWorkbook.updateDefinedNameBuilder
Update the defined name with the given name.
updateDefinedNameBuilder(param: ISetDefinedNameMutationParam): voidParameters
param— Required. The param to insert the defined name
Examples
// The code below updates the defined name with the given nameconst fWorkbook = univerAPI.getActiveWorkbook()const definedName = fWorkbook.getDefinedName('MyDefinedName')console.log(definedName?.getFormulaOrRefString())// Update the defined nameif (definedName) { const newDefinedNameParam = definedName .toBuilder() .setName('NewDefinedName') .setRef('Sheet1!$A$2') .build() fWorkbook.updateDefinedNameBuilder(newDefinedNameParam)}Types: ISetDefinedNameMutationParam
Package: @univerjs/sheets · Type definitions
@univerjs/sheets-data-validation
FWorkbook.getAllDataValidationErrorAsync
Get all data validation errors for current workbook.
getAllDataValidationErrorAsync(): Promise<IDataValidationError[]>Returns
A promise that resolves to an array of validation errors.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const errors = await fWorkbook.getAllDataValidationErrorAsync()console.log(errors)Types: IDataValidationError · Promise
Package: @univerjs/sheets-data-validation · Type definitions
FWorkbook.getValidatorStatus
Get data validation validator status for current workbook.
getValidatorStatus(): Promise<Record<string, ObjectMatrix<Nullable<DataValidationStatus>>>>Returns
A promise resolving to an object keyed by sheet ID, with a validation-status matrix for each sheet.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const status = await fWorkbook.getValidatorStatus()console.log(status)Types: Record · ObjectMatrix · Nullable · DataValidationStatus · Promise
Package: @univerjs/sheets-data-validation · Type definitions
@univerjs/sheets-formula
FWorkbook.getAllFormulaError
Get all formula errors in the workbook
getAllFormulaError(): ISheetFormulaError[]Returns
Array of formula errors
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const errors = fWorkbook.getAllFormulaError()console.log('Formula errors:', errors)Types: ISheetFormulaError
Package: @univerjs/sheets-formula · Type definitions
@univerjs/sheets-hyper-link
FWorkbook.getUrlOfDefineName
Create a hyperlink url for the defined name. The defined name must exist in the current workbook and must be a reference to a range, otherwise an error will be thrown.
getUrlOfDefineName(name: string): stringParameters
name— Required. The name of the defined name.
Returns
The hyperlink url of the defined name.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')// Create a defined name "TestRange" for the range A1:B10 of the active sheetconst definedNameParam = fWorkbook .newDefinedNameBuilder() .setName('TestRange') .setRef('Sheet1!$A$1:$B$10') .build()fWorkbook.insertDefinedNameBuilder(definedNameParam)// Create a hyperlink to the defined name "TestRange" on cell C1const url = fWorkbook.getUrlOfDefineName('TestRange')console.log(url)const fRange = fWorksheet.getRange('C1')fRange.setHyperLink(url, 'Link to TestRange')// Create a hyperlink to the exiting defined name on cell C2const definedNames = fWorkbook.getDefinedNames()console.log(definedNames)const exitsDefinedNameUrl = fWorkbook.getUrlOfDefineName(definedNames[0].getName())console.log(exitsDefinedNameUrl)const fRange2 = fWorksheet.getRange('C2')fRange2.setHyperLink(exitsDefinedNameUrl, `Link to ${definedNames[0].getName()}`)Package: @univerjs/sheets-hyper-link · Type definitions
FWorkbook.parseSheetHyperlink
Parse the hyperlink string to get the hyperlink info.
parseSheetHyperlink(hyperlink: string): ISheetHyperLinkInfoParameters
hyperlink— Required. The hyperlink string.
Returns
The hyperlink info.
Examples
// Create a hyperlink to the range A1:D10 of the current sheetconst fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')const fRange = fWorksheet.getRange('A1:D10')const hyperlink = fRange.getUrl()// Parse the hyperlinkconst hyperlinkInfo = fWorkbook.parseSheetHyperlink(hyperlink)console.log(hyperlinkInfo)Types: ISheetHyperLinkInfo
Package: @univerjs/sheets-hyper-link · Type definitions
@univerjs/sheets-hyper-link-ui
FWorkbook.navigateToSheetHyperlink
Navigate to the sheet hyperlink.
navigateToSheetHyperlink(hyperlink: string): voidParameters
hyperlink— Required. The hyperlink string
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const sheets = fWorkbook.getSheets()// Create a hyperlink to the cell F6 in the first sheetconst sheet1 = sheets[0]const range = sheet1.getRange('F6')const hyperlink = range.getUrl()// Switch to the second sheetfWorkbook.setActiveSheet(sheets[1])console.log(fWorkbook.getActiveSheet().getSheetName())// Navigate to the hyperlink after 3 secondssetTimeout(() => { fWorkbook.navigateToSheetHyperlink(hyperlink) console.log(fWorkbook.getActiveSheet().getSheetName())}, 3000)Types: FWorkbook
Package: @univerjs/sheets-hyper-link-ui · Type definitions
@univerjs/sheets-numfmt
FWorkbook.setNumfmtLocal
Set the locale for number formatting.
setNumfmtLocal(locale: INumfmtLocaleTag): FWorkbookParameters
locale— Required. zh_CN,zh_TW,zh_HK,ja,ko,th,cs,da,nl,en,en_AU,en_CA,en_GB,en_IE,fi,fr,fr_CA,fr_CH,de,de_CH,el,hu,is,id,it,it_CH,nb,no,pl,pt,pt_BR,ru,sk,es,es_AR,es_BO,es_CL,es_CO,es_EC,es_MX,es_PY,es_UY,es_VE,sv,tr,cy,az,be,bg,ca,fil,gu,he,hr,hy,ka,kk,kn,lt,lv,ml,mn,mr,my,pa,ro,sl,sr,ta,te,uk,vi,ar,bn,hi
Returns
The FWorkbook instance for chaining.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')const fRange = fWorksheet.getRange('A1')fRange.setValue(1234.567).setNumberFormat('#,##0.00')// Set the locale en_US for number formatting.fWorkbook.setNumfmtLocal('en_US')console.log(fRange.getDisplayValue()) // 1,234.57// Set the locale de_DE for number formatting.fWorkbook.setNumfmtLocal('de_DE')console.log(fRange.getDisplayValue()) // 1.234,57Types: FWorkbook · INumfmtLocaleTag
Package: @univerjs/sheets-numfmt · Type definitions
@univerjs/sheets-table
FWorkbook.addTable
Add table
addTable(subUnitId: string, tableName: string, rangeInfo: ITableRange, tableId?: string, options?: ITableOptions): Promise<string | undefined>Parameters
subUnitId— Required. The sub unit idtableName— Required. The table namerangeInfo— Required. The table range informationtableId— Optional. The table idoptions— Optional. The table options
Returns
A promise resolving to the table ID, or undefined if the name is invalid or creation fails.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')// Insert a table in the range B2:F11const fRange = fWorksheet.getRange('B2:F11')const id = await fWorkbook.addTable(fWorksheet.getSheetId(), 'name-1', fRange.getRange(), 'id-1', { tableStyleId: 'table-default-4',})if (id) { const tableInfo = fWorkbook.getTableInfo(id) console.log('debugger tableInfo', tableInfo)}Types: Promise · ITableRange · ITableOptions
Package: @univerjs/sheets-table · Type definitions
FWorkbook.getTableInfo
Get table information
getTableInfo(tableId: string): ITableInfoWithUnitId | undefinedParameters
tableId— Required. The table id
Returns
The table information, including workbook and worksheet IDs, or undefined if not found.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')// Insert a table in the range B2:F11const fRange = fWorksheet.getRange('B2:F11')const success = await fWorksheet.addTable('name-1', fRange.getRange(), 'id-1', { tableStyleId: 'table-default-4',})if (success) { const tableInfo = fWorkbook.getTableInfo('id-1') console.log('debugger tableInfo', tableInfo)}Types: ITableInfoWithUnitId
Package: @univerjs/sheets-table · Type definitions
FWorkbook.getTableInfoByName
Get table information by name
getTableInfoByName(tableName: string): ITableInfoWithUnitId | undefinedParameters
tableName— Required. The table name
Returns
The table information, including workbook and worksheet IDs, or undefined if not found.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')// Insert a table in the range B2:F11const fRange = fWorksheet.getRange('B2:F11')const success = await fWorksheet.addTable('name-1', fRange.getRange(), 'id-1', { tableStyleId: 'table-default-4',})if (success) { const tableInfo = fWorkbook.getTableInfoByName('name-1') console.log('debugger tableInfo', tableInfo)}Types: ITableInfoWithUnitId
Package: @univerjs/sheets-table · Type definitions
FWorkbook.getTableList
Get table list
getTableList(): ITableInfoWithUnitId[]Returns
The table list
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const tables = fWorkbook.getTableList()console.log('debugger tables', tables)Types: ITableInfoWithUnitId
Package: @univerjs/sheets-table · Type definitions
FWorkbook.removeTable
Remove table
removeTable(tableId: string): Promise<boolean>Parameters
tableId— Required. The table id
Returns
A promise resolving to whether the table was removed; false if the table is not found.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const tableInfo = fWorkbook.getTableInfo('id-1')console.log('debugger tableInfo', tableInfo)if (tableInfo) { // Remove the table with the specified id await fWorkbook.removeTable('id-1')}Types: Promise
Package: @univerjs/sheets-table · Type definitions
FWorkbook.setTableFilter
set table filter
setTableFilter(tableId: string, column: number, filter: ITableFilterItem | undefined): Promise<boolean>Parameters
tableId— Required. The table idcolumn— Required. The column index, starting from 0.filter— Required. The filter to apply, orundefinedto clear the column filter.
Returns
The result of set table filter
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')// Insert a table in the range B2:F11const fRange = fWorksheet.getRange('B2:F11')const success = await fWorksheet.addTable('name-1', fRange.getRange(), 'id-1', { tableStyleId: 'table-default-4',})if (success) { // Set the filter for the second column await fWorkbook.setTableFilter('id-1', 1, { filterType: univerAPI.Enum.TableColumnFilterTypeEnum.condition, filterInfo: { conditionType: univerAPI.Enum.TableConditionTypeEnum.Number, compareType: univerAPI.Enum.TableNumberCompareTypeEnum.GreaterThan, expectedValue: 10, }, }) const tableInfo = fWorkbook.getTableInfo('id-1') console.log('debugger tableInfo', tableInfo)}Types: Promise · ITableFilterItem
Package: @univerjs/sheets-table · Type definitions
@univerjs/sheets-thread-comment
FWorkbook.clearComments
Clear all comments in the current workbook
clearComments(): Promise<boolean>Returns
Whether the comments are cleared successfully.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const result = await fWorkbook.clearComments()console.log(result)Types: Promise
Package: @univerjs/sheets-thread-comment · Type definitions
FWorkbook.getComments
Get all comments in the current workbook
getComments(): FThreadComment[]Returns
All comments in the current workbook
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const comments = fWorkbook.getComments()comments.forEach((comment) => { const isRoot = comment.getIsRoot() if (isRoot) { console.log('root comment:', comment.getCommentData()) const replies = comment.getReplies() replies.forEach((reply) => { console.log('reply comment:', reply.getCommentData()) }) }})Types: FThreadComment
Package: @univerjs/sheets-thread-comment · Type definitions
@univerjs/sheets-ui
FWorkbook.abortEditingAsync
End the editing process of the current active cell, and discard the changes.
abortEditingAsync(): Promise<boolean>Returns
Whether the editing process is ended successfully
Examples
const fWorkbook = univerAPI.getActiveWorkbook()await fWorkbook.abortEditingAsync()Types: Promise
Package: @univerjs/sheets-ui · Type definitions
FWorkbook.customizeColumnHeader
Customize the column header of the all worksheets in the workbook.
customizeColumnHeader(cfg: IColumnsHeaderCfgParam): voidParameters
cfg— Required. The configuration of the column header.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.customizeColumnHeader({ headerStyle: { fontColor: '#fff', backgroundColor: '#4e69ee', fontSize: 9, }, columnsCfg: { 0: 'kuma II', 3: { text: 'Size', textAlign: 'left', // CanvasTextAlign fontColor: '#fff', fontSize: 12, borderColor: 'pink', backgroundColor: 'pink', }, 4: 'Wow', },})Types: IColumnsHeaderCfgParam
Package: @univerjs/sheets-ui · Type definitions
FWorkbook.customizeRowHeader
Customize the row header of the all worksheets in the workbook.
customizeRowHeader(cfg: IRowsHeaderCfgParam): voidParameters
cfg— Required. The configuration of the row header.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.customizeRowHeader({ headerStyle: { backgroundColor: 'pink', fontSize: 12, }, rowsCfg: { 0: 'Moka II', 3: { text: 'Size', textAlign: 'left', // CanvasTextAlign }, },})Types: IRowsHeaderCfgParam
Package: @univerjs/sheets-ui · Type definitions
FWorkbook.disableSelection
Disable selection. After disabled, there would be no response for selection.
disableSelection(): FWorkbookReturns
FWorkbook instance for chaining
Examples
const fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.disableSelection()Types: FWorkbook
Package: @univerjs/sheets-ui · Type definitions
FWorkbook.enableSelection
Enable selection. After this you can select range.
enableSelection(): FWorkbookReturns
FWorkbook instance for chaining
Examples
const fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.enableSelection()Types: FWorkbook
Package: @univerjs/sheets-ui · Type definitions
FWorkbook.endEditingAsync
End the editing process of the current active cell
endEditingAsync(save?: boolean): Promise<boolean>Parameters
save— Optional. Default:true. Whether to save the changes, default is true
Returns
Whether the editing process is ended successfully
Examples
const fWorkbook = univerAPI.getActiveWorkbook()await fWorkbook.endEditingAsync(false)Types: Promise
Package: @univerjs/sheets-ui · Type definitions
FWorkbook.getScrollStateBySheetId
Get scroll state of specified sheet.
getScrollStateBySheetId(sheetId: string): Nullable<IScrollState>Parameters
sheetId— Required. sheet id
Returns
The sheet scroll state, or a nullish value when no state is available.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')// scroll to cell D10fWorksheet.scrollToCell(9, 3)// get scroll stateconst scrollState = fWorkbook.getScrollStateBySheetId(fWorksheet.getSheetId())const { offsetX, offsetY, sheetViewStartRow, sheetViewStartColumn } = scrollStateconsole.log(scrollState) // sheetViewStartRow: 9, sheetViewStartColumn: 3, offsetX: 0, offsetY: 0Types: IScrollState · Nullable
Package: @univerjs/sheets-ui · Type definitions
FWorkbook.isCellEditing
Check if the current active cell is in editing state
isCellEditing(): booleanReturns
True if the current active cell is in editing state, false otherwise
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const isEditing = fWorkbook.isCellEditing()console.log(isEditing)Package: @univerjs/sheets-ui · Type definitions
FWorkbook.showSelection
Set selection visible.
showSelection(): FWorkbookReturns
FWorkbook instance for chaining
Examples
const fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.showSelection()Types: FWorkbook
Package: @univerjs/sheets-ui · Type definitions
FWorkbook.startEditing
Start the editing process of the current active cell
startEditing(): booleanReturns
Whether the editing process is started successfully
Examples
const fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.startEditing()Package: @univerjs/sheets-ui · Type definitions
FWorkbook.transparentSelection
Set selection invisible, Unlike disableSelection, selection still works, you just can not see them.
transparentSelection(): FWorkbookReturns
FWorkbook instance for chaining
Examples
const fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.transparentSelection()Types: FWorkbook
Package: @univerjs/sheets-ui · Type definitions
@univerjs-pro/range-preprocess
FWorkbook.getPreprocessRanges
Get all preprocess range information
getPreprocessRanges(responseDataMode?: string): Record<string, ITableJson[]>Parameters
responseDataMode— Optional. The response data mode.
Returns
All preprocess range information
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const allTableInfo = fWorkbook.getPreprocessRanges()console.log('debugger allTableInfo', allTableInfo)Types: ITableJson · Record
Package: @univerjs-pro/range-preprocess · Type definitions
@univerjs-pro/sheets-pivot
FWorkbook.addPivotTable
Add a pivot table to the Workbook.
addPivotTable(sourceInfo: IUnitRangeName & { subUnitId: string; }, positionType: PositionType, anchorCellInfo: IPivotCellPositionInfo): Promise<FPivotTable | undefined>Parameters
sourceInfo— Required. The source data range info of the pivot table.positionType— Required. whether new a sheet or insert a pivot table to the existing sheet.anchorCellInfo— Required. The target cell info of the pivot table.
Returns
A promise that resolves to the added pivot table instance.
Examples
// should ensure the sheet range A1:G9 is not emptyconst fWorkbook = univerAPI.getActiveWorkbook()const unitId = fWorkbook.getId()const fWorksheet = fWorkbook.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')const subUnitId = fWorksheet.getSheetId()const sheetName = fWorksheet.getSheetName()const sourceInfo = { unitId, subUnitId, sheetName, range: { startRow: 0, endRow: 8, startColumn: 0, endColumn: 6, },}const anchorCellInfo = { unitId, subUnitId, row: 0, col: 8,}const fPivotTable = await fWorkbook.addPivotTable( sourceInfo, univerAPI.Enum.PositionTypeEnum.Existing, anchorCellInfo,)await fPivotTable?.addField(1, univerAPI.Enum.PivotTableFiledAreaEnum.Row, 0)await fPivotTable?.addField(1, univerAPI.Enum.PivotTableFiledAreaEnum.Value, 0)Types: FPivotTable · Promise · IUnitRangeName · PositionType · IPivotCellPositionInfo
Package: @univerjs-pro/sheets-pivot · Type definitions
FWorkbook.getPivotTableByCell
Get the pivot table id by the cell.
getPivotTableByCell(unitId: string, subUnitId: string, row: number, col: number): FPivotTable | undefinedParameters
unitId— Required. The unit id of workbook.subUnitId— Required. The sheet id, which pivot table belongs to.row— Required. The checked row.col— Required. The checked column.
Returns
The pivot table instance or undefined.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const unitId = fWorkbook.getId()const fWorksheet = fWorkbook.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')const subUnitId = fWorksheet.getSheetId()const fPivotTable = fWorkbook.getPivotTableByCell(unitId, subUnitId, 0, 8)if (fPivotTable) { fPivotTable.addField(1, univerAPI.Enum.PivotTableFiledAreaEnum.Row, 0)}Types: FPivotTable
Package: @univerjs-pro/sheets-pivot · Type definitions
FWorkbook.getPivotTableById
Get the pivot table by the pivot table id.
getPivotTableById(pivotTableId: string): FPivotTable | undefinedParameters
pivotTableId— Required. The pivot table id.
Returns
The pivot table instance or undefined.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const mockId = 'abc123456'const fPivotTable = fWorkbook.getPivotTableById(mockId)if (fPivotTable) { fPivotTable.addField(1, univerAPI.Enum.PivotTableFiledAreaEnum.Row, 0)}Types: FPivotTable
Package: @univerjs-pro/sheets-pivot · Type definitions
@univerjs-pro/sheets-pivot-chart
FWorkbook.getPivotChartById
Returns a PivotChart in this workbook by its stable identifier.
getPivotChartById(pivotChartId: string): FSheetPivotChart | nullParameters
pivotChartId— Required. The identifier returned byFSheetPivotChart.getId().
Returns
A live facade, or null if it is absent from this workbook.
Examples
import '@univerjs-pro/sheets-pivot-chart/facade'const fWorkbook = univerAPI.getActiveWorkbook()const fPivotChart = fWorkbook.getPivotChartById('pivot-chart-1')console.log(fPivotChart?.getInfo())Types: FSheetPivotChart
Package: @univerjs-pro/sheets-pivot-chart · Type definitions
@univerjs-pro/sheets-print
FWorkbook.closePrintDialog
Close print preview dialog.
closePrintDialog(): voidExamples
const fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.openPrintDialog()// Close print dialog after 3 secondssetTimeout(() => { fWorkbook.closePrintDialog()}, 3000)Package: @univerjs-pro/sheets-print · Type definitions
FWorkbook.openPrintDialog
Open print preview dialog.
openPrintDialog(): voidExamples
const fWorkbook = univerAPI.getActiveWorkbook()fWorkbook.openPrintDialog()Package: @univerjs-pro/sheets-print · Type definitions
FWorkbook.print
Using current print config and render config to print.
print(): voidExamples
const fWorkbook = univerAPI.getActiveWorkbook()// Update print layout config by defaultfWorkbook.updatePrintConfig({})// Update print render config by defaultfWorkbook.updatePrintRenderConfig({})// Start printfWorkbook.print()Package: @univerjs-pro/sheets-print · Type definitions
FWorkbook.saveScreenshotToClipboard
Save screenshot of current range to clipboard.
This API is only available with a license. Without a license, usage is restricted, and save operations will return false.
We use the Clipboard API to save the image to the clipboard, which may fail in an insecure network environment or in some unsupported browsers. A successful save will return true.
saveScreenshotToClipboard(): Promise<boolean>Returns
- The result of saving the screenshot to the clipboard.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const result = await fWorkbook.saveScreenshotToClipboard()console.log(result) // true or falseTypes: Promise
Package: @univerjs-pro/sheets-print · Type definitions
FWorkbook.updatePrintConfig
Update print config, include print area, page-setting, scale, freeze, margin, and etc.
updatePrintConfig(config: ISheetPrintLayoutConfig): FWorkbookParameters
config— Required. The print layout config.
Returns
- The current workbook instance for chaining.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()const fWorksheet = fWorkbook.getSheetByName('Sheet1')if (!fWorksheet) throw new Error('fWorksheet is not available')const subUnitId = fWorksheet.getSheetId()// Update print layout configfWorkbook.updatePrintConfig({ area: univerAPI.Enum.PrintArea.CurrentSheet, // print current sheet subUnitIds: [subUnitId], paperSize: univerAPI.Enum.PrintPaperSize.A4, // A4 paper size scale: univerAPI.Enum.PrintScale.FitPage, // fit content to page freeze: [univerAPI.Enum.PrintFreeze.Row], // freeze row headers margin: univerAPI.Enum.PrintPaperMargin.Normal, // normal margin // ... other settings})// Start printfWorkbook.print()Types: FWorkbook · ISheetPrintLayoutConfig
Package: @univerjs-pro/sheets-print · Type definitions
FWorkbook.updatePrintRenderConfig
Update print render config, include print header-footer setting, alignment, gridline, and etc.
updatePrintRenderConfig(config: ISheetPrintRenderConfig): FWorkbookParameters
config— Required. The print render config.
Returns
- The current workbook instance for chaining.
Examples
const fWorkbook = univerAPI.getActiveWorkbook()// Update print layout config by defaultfWorkbook.updatePrintConfig({})// Update print render configfWorkbook.updatePrintRenderConfig({ gridlines: true, // show gridlines hAlign: univerAPI.Enum.PrintAlign.Middle, // horizontal align middle vAlign: univerAPI.Enum.PrintAlign.Middle, // vertical align middle headerFooter: [ // the array of header and footer elements to include, here is page numbers and worksheet name univerAPI.Enum.PrintHeaderFooter.PageSize, univerAPI.Enum.PrintHeaderFooter.WorksheetTitle, ], // ... other settings})// Start printfWorkbook.print()Types: FWorkbook · ISheetPrintRenderConfig
Package: @univerjs-pro/sheets-print · Type definitions
How is this guide?