API Reference

Worksheet

Packages@univerjs/sheets, @univerjs/sheets-conditional-formatting, @univerjs/sheets-drawing-ui, @univerjs-pro/sheets-sparkline, @univerjs/sheets-table, @univerjs/sheets-ui, @univerjs/sheets-thread-comment, @univerjs-pro/sheets-shape, @univerjs/sheets-drawing, @univerjs/sheets-data-validation, @univerjs-pro/sheets-chart, @univerjs/sheets-filter, @univerjs/sheets-note, @univerjs-pro/sheets-pivot, @univerjs/sheets-hyper-link, @univerjs/sheets-sort, @univerjs-pro/sheets-outline

A Facade API object bounded to a worksheet. It provides a set of methods to interact with the worksheet.

This class should not be instantiated directly. Use factory methods on univerAPI instead.

Overview

@univerjs/sheets

MethodDescription
activateActivates this sheet
appendRowAppends a row to the bottom of the current data region in the sheet
autoFitRowMake certain row wrap and auto height
cancelFreezeCancels the frozen state of the current sheet
clearClears the sheet of content and formatting information
clearContentsClears the sheet of contents, while preserving formatting information
clearFormatsClears the sheet of formatting, while preserving contents
deleteColumnDeletes the column at the given column position
deleteColumnsDeletes a number of columns starting at the given column position
deleteColumnsByPointsDeletes the columns specified by the given column points
deleteRowDeletes the row at the given row position
deleteRowsDeletes a number of rows starting at the given row position
deleteRowsByPointsDeletes the rows specified by the given row points
dispose-
equalToJudge whether provided FWorksheet is equal to current
getActiveCellReturns the active cell in this sheet
getActiveRangeReturns the selected range in the active sheet, or null if there is no active range
getCellMergeDataGet the merged cell data of the specified row and column
getColumnCustomMetadataGet custom metadata of column
getColumnDefaultStyleGet the default style of the worksheet column
getColumnWidthGets the width in pixels of the given column
getCustomMetadataGet custom metadata of worksheet
getDataRangeReturns a Range corresponding to the dimensions in which data is present
getDefaultStyleGet the default style of the worksheet
getDefinedNamesGet all the defined names in the worksheet
getFreezeGet the freeze state of the current sheet
getFrozenColumnRangeGet freezed columns
getFrozenColumnsGet the number of frozen columns
getFrozenRowRangeGet freezed rows
getFrozenRowsGet the number of frozen rows
getGridLinesColorGet the color of the gridlines in the sheet
getIndexGets the position of the sheet in its parent spreadsheet
getInjectGet the injector instance
getLastColumnReturns the column index of the last column that contains content
getLastColumns-
getLastRowReturns the row index of the last row that contains content
getLastRows-
getMaxColumnsReturns the current number of columns in the sheet, regardless of content
getMaxRowsReturns the current number of rows in the sheet, regardless of content
getMergeDataGet all merged cells in the current worksheet
getMergedRangesGet all merged cells in the current sheet
getRange-
getRowCustomMetadataGet custom metadata of row
getRowDefaultStyleGet the default style of the worksheet row
getRowHeightGets the height in pixels of the given row
getSelectionGet the current selection of the worksheet
getSheetGet the worksheet instance
getSheetIdGet the worksheet id
getSheetNameGet the worksheet name
getTabColorGet the tab color of the sheet
getWorkbookGet the workbook instance
getWorksheetPermissionGet the WorksheetPermission instance for managing worksheet-level permissions
hasHiddenGridLinesReturns true if the sheet's gridlines are hidden; otherwise returns false
hideColumnHides the column or columns in the given range
hideColumnsHides one or more consecutive columns starting at the given index
hideRowHides the rows in the given range
hideRowsHides one or more consecutive rows starting at the given index
hideSheetHides this sheet
insertColumnAfterInserts a column after the given column position
insertColumnBeforeInserts a column before the given column position
insertColumnsInserts one or more consecutive blank columns in a sheet starting at the specified location
insertColumnsAfterInserts a given number of columns after the given column position
insertColumnsBeforeInserts a number of columns before the given column position
insertDefinedNameInsert a defined name for worksheet
insertRowAfterInserts a row after the given row position
insertRowBeforeInserts a row before the given row position
insertRowsInserts one or more consecutive blank rows in a sheet starting at the specified location
insertRowsAfterInserts a number of rows after the given row position
insertRowsBeforeInserts a number of rows before the given row position
isSheetHiddenReturns true if the sheet is currently hidden
moveColumnsMoves the columns selected by the given range to the position indicated by the destinationIndex
moveRowsMoves the rows selected by the given range to the position indicated by the destinationIndex
onBeforeCellDataChange-
onCellDataChange-
setActiveRangeSets the active selection region for this sheet
setActiveSelectionSets the active selection region for this sheet
setColumnCountSets the number of columns in the worksheet
setColumnCustomSet custom properties for given columns
setColumnCustomMetadataSet custom metadata of column
setColumnDefaultStyleSet the default style of the worksheet row
setColumnWidthSets the width of the given column in pixels
setColumnWidthsSets the width of the given columns in pixels
setCustomMetadataSet custom metadata of worksheet
setDefaultStyleSet the default style of the worksheet
setFreezeSets the frozen state of the current sheet
setFrozenColumns-
setFrozenRows-
setGridLinesColorSet the color of the gridlines in the sheet
setHiddenGridlinesHides or reveals the sheet gridlines
setNameSets the sheet name
setRangesAutoHeightSets the height of the given ranges to auto
setRowAutoHeightSets the height of the given rows to auto
setRowCountSets the number of rows in the worksheet
setRowCustomSet custom properties for given rows
setRowCustomMetadataSet custom metadata of row
setRowDefaultStyleSet the default style of the worksheet column
setRowHeightSets the row height of the given row in pixels
setRowHeightsSets the height of the given rows in pixels
setRowHeightsForcedSets the height of the given rows in pixels
setTabColorSets the sheet tab color
showColumnsShow one or more consecutive columns starting at the given index
showRowsScrolling sheet to make specific rows visible
showSheetShows this sheet
unhideColumnShow the column in the given range
unhideRowMake the row in the given range visible

@univerjs/sheets-conditional-formatting

@univerjs/sheets-data-validation

@univerjs/sheets-drawing

@univerjs/sheets-drawing-ui

@univerjs/sheets-filter

MethodDescription
getFilter-
MethodDescription
getUrlGenerate a hyperlink URL for the current worksheet

@univerjs/sheets-note

MethodDescription
getNotes-

@univerjs/sheets-sort

MethodDescription
sort-

@univerjs/sheets-table

@univerjs/sheets-thread-comment

MethodDescription
clearComments-
getCommentById-
getComments-
onCommentedSubscribe to comment events

@univerjs/sheets-ui

@univerjs-pro/sheets-chart

MethodDescription
chartsReturns the worksheet chart collection facade

@univerjs-pro/sheets-outline

MethodDescription
addColumnOutlineAdd a column outline group to the current worksheet
addRowOutlineAdd a row outline group to the current worksheet
clearDimensionOutlinesClear outline groups in a row or column range
getDimensionOutlinesGet outline groups on the current worksheet
removeDimensionOutlineRemove a row or column outline group from the current worksheet
setDimensionOutlineCollapsedCollapse or expand an existing row or column outline group

@univerjs-pro/sheets-pivot

MethodDescription
getPivotTableByCell-

@univerjs-pro/sheets-shape

MethodDescription
getShapes-
insertShape-

@univerjs-pro/sheets-sparkline

APIs

Range & Selection

getActiveRange

Returns the selected range in the active sheet, or null if there is no active range.

Signature

TypeScript
getActiveRange(): FRange | null

Returns

  • FRange — the active range

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Get the currently active rangeconst activeRange = fWorksheet.getActiveRange();if (activeRange) {  console.log('Active range:', activeRange.getA1Notation());}
Source: @univerjs/sheets

getRange

Signature

TypeScript
getRange(rowOrA1Notation: IRange | number | string, column?: number, numRows?: number, numColumns?: number): FRange

Parameters

  • rowOrA1Notation string | number | IRangeNo description
  • column number (optional)No description
  • numRows number (optional)No description
  • numColumns number (optional)No description

Returns

  • FRange — See signature above.
Source: @univerjs/sheets

getSelection

Get the current selection of the worksheet.

Signature

TypeScript
getSelection(): FSelection | null

Returns

  • FSelection — return the current selections of the worksheet or null if there is no selection.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();const selection = fWorksheet.getSelection();console.log(selection);
Source: @univerjs/sheets

Cell Data

getCellMergeData

Get the merged cell data of the specified row and column.

Signature

TypeScript
getCellMergeData(row: number, column: number): FRange | undefined

Parameters

  • row numberNo description
  • column numberNo description

Returns

  • FRange — The merged cell data, or undefined if the cell is not merged

Examples

TypeScript
const fWorkSheet = univerAPI.getActiveWorkbook().getActiveSheet();const merge = fWorkSheet.getCellMergeData(0, 0);if (merge) {  console.log('Merged range:', merge.getA1Notation());}
Source: @univerjs/sheets

Row & Column

addFloatDomToColumnHeader

Signature

TypeScript
addFloatDomToColumnHeader(column: number, layer: IFICanvasFloatDom, domLayout: IDOMAnchor, id?: string): Nullable<{        id: string;        dispose: () => void;    }>

Parameters

  • column numberNo description
  • layer IFICanvasFloatDomNo description
  • domLayout IDOMAnchorNo description
  • id string (optional)No description

Returns

  • Nullable<{ id: string; dispose: () => void; }> — See signature above.
Source: @univerjs/sheets-drawing-ui

appendRow

Appends a row to the bottom of the current data region in the sheet. If a cell's content begins with =, it's interpreted as a formula.

Signature

TypeScript
appendRow(rowContents: CellValue[]): FWorksheet

Parameters

  • rowContents CellValue[]No description

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining.

Examples

TypeScript
// Appends a new row with 4 columns to the bottom of the current// data region in the sheet containing the values in the array.const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();fWorkSheet.appendRow([1, 'Hello Univer', true, '=A1']);
Source: @univerjs/sheets

autoFitRow

Make certain row wrap and auto height.

Signature

TypeScript
autoFitRow(rowPosition: number, auto: BooleanNumber = BooleanNumber.TRUE): FWorksheet

Parameters

  • rowPosition numberNo description
  • auto BooleanNumber (optional)No description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

TypeScript
const fWorkSheet = univerAPI.getActiveWorkbook().getActiveSheet();fWorkSheet.autoFitRow(24);
Source: @univerjs/sheets

autoResizeColumns

Signature

TypeScript
autoResizeColumns(startColumn: number, numColumns?: number): FWorksheet

Parameters

  • startColumn numberNo description
  • numColumns number (optional) — Number of columns. Defaults to 1.

Returns

  • FWorksheet — See signature above.
Source: @univerjs/sheets-ui

autoResizeRows

Signature

TypeScript
autoResizeRows(startRow: number, numRows?: number): FWorksheet

Parameters

  • startRow numberNo description
  • numRows number (optional) — Number of rows. Defaults to 1.

Returns

  • FWorksheet — See signature above.
Source: @univerjs/sheets-ui

customizeColumnHeader

Signature

TypeScript
customizeColumnHeader(cfg: IColumnsHeaderCfgParam): void

Parameters

  • cfg IColumnsHeaderCfgParamNo description
Source: @univerjs/sheets-ui

customizeRowHeader

Signature

TypeScript
customizeRowHeader(cfg: IRowsHeaderCfgParam): void

Parameters

  • cfg IRowsHeaderCfgParamNo description
Source: @univerjs/sheets-ui

deleteColumn

Deletes the column at the given column position.

Signature

TypeScript
deleteColumn(columnPosition: number): FWorksheet

Parameters

  • columnPosition numberNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Delete column CfWorksheet.deleteColumn(2);// Delete column AfWorksheet.deleteColumn(0);
Source: @univerjs/sheets

deleteColumns

Deletes a number of columns starting at the given column position.

Signature

TypeScript
deleteColumns(columnPosition: number, howMany: number): FWorksheet

Parameters

  • columnPosition numberNo description
  • howMany numberNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Delete 3 columns at column index 2 (columns C, D, E)fWorksheet.deleteColumns(2, 3);// Delete 1 column at column index 0 (column A)fWorksheet.deleteColumns(0, 1);
Source: @univerjs/sheets

deleteColumnsByPoints

Deletes the columns specified by the given column points. Each point can be a single column index or a tuple representing a range of columns.

Signature

TypeScript
deleteColumnsByPoints(columnPoints: Array<number | [number, number]>): FWorksheet

Parameters

  • columnPoints (number | [number, number])[]No description

Returns

  • FWorksheet — This sheet, for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Delete columns at index 2, and range from index 4 to 6 (columns C, E-G)fWorksheet.deleteColumnsByPoints([2, [4, 6]]);
Source: @univerjs/sheets

deleteRow

Deletes the row at the given row position.

Signature

TypeScript
deleteRow(rowPosition: number): FWorksheet

Parameters

  • rowPosition numberNo description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Delete the third rowfWorksheet.deleteRow(2);// Delete the first rowfWorksheet.deleteRow(0);
Source: @univerjs/sheets

deleteRows

Deletes a number of rows starting at the given row position.

Signature

TypeScript
deleteRows(rowPosition: number, howMany: number): FWorksheet

Parameters

  • rowPosition numberNo description
  • howMany numberNo description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Delete 3 rows at row index 2 (rows 3-5)fWorksheet.deleteRows(2, 3);// Delete 1 row at row index 0 (first row)fWorksheet.deleteRows(0, 1);
Source: @univerjs/sheets

deleteRowsByPoints

Deletes the rows specified by the given row points. Each point can be a single row index or a tuple representing a range of rows.

Signature

TypeScript
deleteRowsByPoints(rowPoints: Array<number | [number, number]>): FWorksheet

Parameters

  • rowPoints (number | [number, number])[]No description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Delete rows at index 2, and range from index 4 to 6 (rows 3, 5-7)fWorksheet.deleteRowsByPoints([2, [4, 6]]);
Source: @univerjs/sheets

getColumnCustomMetadata

Get custom metadata of column

Signature

TypeScript
getColumnCustomMetadata(index: number): CustomData | undefined

Parameters

  • index numberNo description

Returns

  • CustomData — custom metadata

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();const custom = fWorkSheet.getColumnCustomMetadata(0);console.log(custom);
Source: @univerjs/sheets

getColumnDefaultStyle

Get the default style of the worksheet column

Signature

TypeScript
getColumnDefaultStyle(index: number, keepRaw: boolean = false): Nullable<IStyleData> | string

Parameters

  • index numberNo description
  • keepRaw boolean (optional)No description

Returns

  • string | Nullable<IStyleData> — The default style of the worksheet column name or style data

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Get default style for column 0 (A)const colStyle = fWorksheet.getColumnDefaultStyle(0);console.log(colStyle);// Get raw style data for column 0const rawColStyle = fWorksheet.getColumnDefaultStyle(0, true);console.log(rawColStyle);
Source: @univerjs/sheets

getColumnWidth

Gets the width in pixels of the given column.

Signature

TypeScript
getColumnWidth(columnPosition: number): number

Parameters

  • columnPosition numberNo description

Returns

  • number — The width of the column in pixels

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();// Set the long text value in cell A1const fRange = fWorksheet.getRange('A1');fRange.setValue('Whenever it is a damp, drizzly November in my soul...');// Set the column A to a width which fits the textfWorksheet.autoResizeColumns(0);// Get the width of the column Aconsole.log(fWorksheet.getColumnWidth(0));
Source: @univerjs/sheets

getFrozenColumnRange

Get freezed columns

Signature

TypeScript
getFrozenColumnRange(): IColumnRange

Returns

  • IColumnRange — The range of the frozen columns.

Examples

TypeScript
const fWorkSheet = univerAPI.getActiveWorkbook().getActiveSheet();// Get the range of the frozen columnsconst frozenColumns = fWorkSheet.getFrozenColumnRange();console.log(frozenColumns);
Source: @univerjs/sheets

getFrozenColumns

Get the number of frozen columns.

Signature

TypeScript
getFrozenColumns(): number

Returns

  • number — The number of frozen columns, returns 0 if no columns are frozen.

Examples

TypeScript
const fWorkSheet = univerAPI.getActiveWorkbook().getActiveSheet();// Get the number of frozen columnsconst frozenColumns = fWorkSheet.getFrozenColumns();console.log(frozenColumns);
Source: @univerjs/sheets

getFrozenRowRange

Get freezed rows.

Signature

TypeScript
getFrozenRowRange(): IRowRange

Returns

  • IRowRange — The range of the frozen rows.

Examples

TypeScript
const fWorkSheet = univerAPI.getActiveWorkbook().getActiveSheet();// Get the range of the frozen rowsconst frozenRows = fWorkSheet.getFrozenRowRange();console.log(frozenRows);
Source: @univerjs/sheets

getFrozenRows

Get the number of frozen rows.

Signature

TypeScript
getFrozenRows(): number

Returns

  • number — The number of frozen rows. returns 0 if no rows are frozen.

Examples

TypeScript
const fWorkSheet = univerAPI.getActiveWorkbook().getActiveSheet();// Get the number of frozen rowsconst frozenRows = fWorkSheet.getFrozenRows();console.log(frozenRows);
Source: @univerjs/sheets

getGridLinesColor

Get the color of the gridlines in the sheet.

Signature

TypeScript
getGridLinesColor(): string | undefined

Returns

  • string — The color of the gridlines in the sheet or undefined. The default color is 'rgb(214, 216, 219)'.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();// get the gridlines color of the sheetconsole.log(fWorkSheet.getGridLinesColor());
Source: @univerjs/sheets

getLastColumn

Returns the column index of the last column that contains content.

Signature

TypeScript
getLastColumn(): number

Returns

  • number — the column index of the last column that contains content.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();// Assume the sheet is a empty sheetconst cellRange = fWorkSheet.getRange('J50');cellRange.setValue('Hello World');console.log(fWorkSheet.getLastColumn()); // 9
Source: @univerjs/sheets

getLastColumns

Deprecated — use getLastColumn instead.Returns the column index of the last column that contains content.

Signature

TypeScript
getLastColumns(): number

Returns

  • number — the column index of the last column that contains content.
Source: @univerjs/sheets

getLastRow

Returns the row index of the last row that contains content.

Signature

TypeScript
getLastRow(): number

Returns

  • number — the row index of the last row that contains content.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();// Assume the sheet is a empty sheetconst cellRange = fWorkSheet.getRange('J50');cellRange.setValue('Hello World');console.log(fWorkSheet.getLastRow()); // 49
Source: @univerjs/sheets

getLastRows

Deprecated — use getLastRow instead.Returns the row index of the last row that contains content.

Signature

TypeScript
getLastRows(): number

Returns

  • number — the row index of the last row that contains content.
Source: @univerjs/sheets

getMaxColumns

Returns the current number of columns in the sheet, regardless of content.

Signature

TypeScript
getMaxColumns(): number

Returns

  • number — The maximum columns count of the sheet

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();const totalColumns = fWorksheet.getMaxColumns();console.log(`Sheet has ${totalColumns} columns`);
Source: @univerjs/sheets

getMaxRows

Returns the current number of rows in the sheet, regardless of content.

Signature

TypeScript
getMaxRows(): number

Returns

  • number — The maximum rows count of the sheet

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();const totalRows = fWorksheet.getMaxRows();console.log(`Sheet has ${totalRows} rows`);
Source: @univerjs/sheets

getRowCustomMetadata

Get custom metadata of row

Signature

TypeScript
getRowCustomMetadata(index: number): CustomData | undefined

Parameters

  • index numberNo description

Returns

  • CustomData — custom metadata

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();const custom = fWorkSheet.getRowCustomMetadata(0);console.log(custom);
Source: @univerjs/sheets

getRowDefaultStyle

Get the default style of the worksheet row

Signature

TypeScript
getRowDefaultStyle(index: number, keepRaw: boolean = false): Nullable<IStyleData> | string

Parameters

  • index numberNo description
  • keepRaw boolean (optional)No description

Returns

  • string | Nullable<IStyleData> — The default style of the worksheet row name or style data

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Get default style for row 0 (1)const rowStyle = fWorksheet.getRowDefaultStyle(0);console.log(rowStyle);// Get raw style data for row 0const rawRowStyle = fWorksheet.getRowDefaultStyle(0, true);console.log(rawRowStyle);
Source: @univerjs/sheets

getRowHeight

Gets the height in pixels of the given row.

Signature

TypeScript
getRowHeight(rowPosition: number): number

Parameters

  • rowPosition numberNo description

Returns

  • number — The height in pixels of the given row.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();// Set the value of the cell A1 to 'Hello, Univer!', set the font size to 30 and font weight to boldconst fRange = fWorksheet.getRange('A1');fRange.setValue('Hello, Univer!').setFontSize(30).setFontWeight('bold');// Get the height of the first rowconsole.log(fWorksheet.getRowHeight(0));
Source: @univerjs/sheets

getTabColor

Get the tab color of the sheet.

Signature

TypeScript
getTabColor(): string | undefined

Returns

  • string — The tab color of the sheet or undefined. The default color is css style property 'unset'.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();// get the tab color of the sheetconsole.log(fWorkSheet.getTabColor());
Source: @univerjs/sheets

hideColumn

Hides the column or columns in the given range.

Signature

TypeScript
hideColumn(column: FRange): FWorksheet

Parameters

  • column FRangeNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Hide columns C, D, Econst column1 = fWorksheet.getRange('C:E');fWorksheet.hideColumn(column1);// Hide column Aconst column2 = fWorksheet.getRange('A:A');fWorksheet.hideColumn(column2);
Source: @univerjs/sheets

hideColumns

Hides one or more consecutive columns starting at the given index. Use 0-index for this method

Signature

TypeScript
hideColumns(columnIndex: number, numColumn: number = 1): FWorksheet

Parameters

  • columnIndex numberNo description
  • numColumn number (optional)No description

Returns

  • FWorksheet — This sheet, for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Hide columns C, D, EfWorksheet.hideColumns(2, 3);// Hide column AfWorksheet.hideColumns(0, 1);
Source: @univerjs/sheets

hideRow

Hides the rows in the given range.

Signature

TypeScript
hideRow(row: FRange): FWorksheet

Parameters

  • row FRangeNo description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Hide 3 rows starting from row index 1 (rows 2-4)const row1 = fWorksheet.getRange('2:4');fWorksheet.hideRow(row1);// Hide single row at index 0 (first row)const row2 = fWorksheet.getRange('1:1');fWorksheet.hideRow(row2);
Source: @univerjs/sheets

hideRows

Hides one or more consecutive rows starting at the given index. Use 0-index for this method

Signature

TypeScript
hideRows(rowIndex: number, numRow: number = 1): FWorksheet

Parameters

  • rowIndex numberNo description
  • numRow number (optional)No description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Hide 3 rows starting from row index 1 (rows 2-4)fWorksheet.hideRows(1, 3);// Hide single row at index 0 (first row)fWorksheet.hideRows(0);
Source: @univerjs/sheets

insertColumnAfter

Inserts a column after the given column position.

Signature

TypeScript
insertColumnAfter(afterPosition: number): FWorksheet

Parameters

  • afterPosition numberNo description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Insert a column after column CfWorksheet.insertColumnAfter(2);// Insert a column after column AfWorksheet.insertColumnAfter(0);
Source: @univerjs/sheets

insertColumnBefore

Inserts a column before the given column position.

Signature

TypeScript
insertColumnBefore(beforePosition: number): FWorksheet

Parameters

  • beforePosition numberNo description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Insert a column before column CfWorksheet.insertColumnBefore(2);// Insert a column before column AfWorksheet.insertColumnBefore(0);
Source: @univerjs/sheets

insertColumns

Inserts one or more consecutive blank columns in a sheet starting at the specified location.

Signature

TypeScript
insertColumns(columnIndex: number, numColumns: number = 1): FWorksheet

Parameters

  • columnIndex numberNo description
  • numColumns number (optional)No description

Returns

  • FWorksheet — This sheet, for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Insert 3 columns before column CfWorksheet.insertColumns(2, 3);// Insert 1 column before column AfWorksheet.insertColumns(0);
Source: @univerjs/sheets

insertColumnsAfter

Inserts a given number of columns after the given column position.

Signature

TypeScript
insertColumnsAfter(afterPosition: number, howMany: number): FWorksheet

Parameters

  • afterPosition numberNo description
  • howMany numberNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Insert 3 columns after column CfWorksheet.insertColumnsAfter(2, 3);// Insert 1 column after column AfWorksheet.insertColumnsAfter(0, 1);
Source: @univerjs/sheets

insertColumnsBefore

Inserts a number of columns before the given column position.

Signature

TypeScript
insertColumnsBefore(beforePosition: number, howMany: number): FWorksheet

Parameters

  • beforePosition numberNo description
  • howMany numberNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Insert 3 columns before column CfWorksheet.insertColumnsBefore(2, 3);// Insert 1 column before column AfWorksheet.insertColumnsBefore(0, 1);
Source: @univerjs/sheets

insertRowAfter

Inserts a row after the given row position.

Signature

TypeScript
insertRowAfter(afterPosition: number): FWorksheet

Parameters

  • afterPosition numberNo description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Insert a row after the third rowfWorksheet.insertRowAfter(2);// Insert a row after the first rowfWorksheet.insertRowAfter(0);
Source: @univerjs/sheets

insertRowBefore

Inserts a row before the given row position.

Signature

TypeScript
insertRowBefore(beforePosition: number): FWorksheet

Parameters

  • beforePosition numberNo description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Insert a row before the third rowfWorksheet.insertRowBefore(2);// Insert a row before the first rowfWorksheet.insertRowBefore(0);
Source: @univerjs/sheets

insertRows

Inserts one or more consecutive blank rows in a sheet starting at the specified location.

Signature

TypeScript
insertRows(rowIndex: number, numRows: number = 1): FWorksheet

Parameters

  • rowIndex numberNo description
  • numRows number (optional)No description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Insert 3 rows before the third rowfWorksheet.insertRows(2, 3);// Insert 1 row before the first rowfWorksheet.insertRows(0);
Source: @univerjs/sheets

insertRowsAfter

Inserts a number of rows after the given row position.

Signature

TypeScript
insertRowsAfter(afterPosition: number, howMany: number): FWorksheet

Parameters

  • afterPosition numberNo description
  • howMany numberNo description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Insert 3 rows after the third rowfWorksheet.insertRowsAfter(2, 3);// Insert 1 row after the first rowfWorksheet.insertRowsAfter(0, 1);
Source: @univerjs/sheets

insertRowsBefore

Inserts a number of rows before the given row position.

Signature

TypeScript
insertRowsBefore(beforePosition: number, howMany: number): FWorksheet

Parameters

  • beforePosition numberNo description
  • howMany numberNo description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Insert 3 rows before the third rowfWorksheet.insertRowsBefore(2, 3);// Insert 1 row before the first rowfWorksheet.insertRowsBefore(0, 1);
Source: @univerjs/sheets

moveColumns

Moves the columns selected by the given range to the position indicated by the destinationIndex. The columnSpec itself does not have to exactly represent an entire column or group of columns to move—it selects all columns that the range spans.

Signature

TypeScript
moveColumns(columnSpec: FRange, destinationIndex: number): FWorksheet

Parameters

  • columnSpec FRangeNo description
  • destinationIndex numberNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Move columns C, D, E to column index 2 (columns B, C, D)const columnSpec1 = fWorksheet.getRange('C:E');fWorksheet.moveColumns(columnSpec1, 1);// Move column F to column index 0 (column A)const columnSpec2 = fWorksheet.getRange('F:F');fWorksheet.moveColumns(columnSpec2, 0);
Source: @univerjs/sheets

moveRows

Moves the rows selected by the given range to the position indicated by the destinationIndex. The rowSpec itself does not have to exactly represent an entire row or group of rows to move—it selects all rows that the range spans.

Signature

TypeScript
moveRows(rowSpec: FRange, destinationIndex: number): FWorksheet

Parameters

  • rowSpec FRangeNo description
  • destinationIndex numberNo description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Move 3 rows at row index 2 (rows 3-5) to row index 0const rowSpec1 = fWorksheet.getRange('3:5');fWorksheet.moveRows(rowSpec1, 0);// Move 1 row at row index 0 (first row) to row index 2const rowSpec2 = fWorksheet.getRange('1:1');fWorksheet.moveRows(rowSpec2, 2);
Source: @univerjs/sheets

setColumnCount

Sets the number of columns in the worksheet.

Signature

TypeScript
setColumnCount(columnCount: number): FWorksheet

Parameters

  • columnCount numberNo description

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();// Set the number of columns in the worksheet to 10fWorkSheet.setColumnCount(10);
Source: @univerjs/sheets

setColumnCustom

Set custom properties for given columns.

Signature

TypeScript
setColumnCustom(custom: IObjectArrayPrimitiveType<CustomData>): FWorksheet

Parameters

  • custom IObjectArrayPrimitiveType<CustomData>No description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

TypeScript
const fWorkSheet = univerAPI.getActiveWorkbook().getActiveSheet();fWorkSheet.setColumnCustom({ 0: { key: 'value' } });
Source: @univerjs/sheets

setColumnCustomMetadata

Set custom metadata of column

Signature

TypeScript
setColumnCustomMetadata(index: number, custom: CustomData | undefined): FWorksheet

Parameters

  • index numberNo description
  • custom CustomDataNo description

Returns

  • FWorksheet — Current worksheet, for chaining.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();fWorkSheet.setColumnCustomMetadata(0, { key: 'value' });
Source: @univerjs/sheets

setColumnDefaultStyle

Set the default style of the worksheet row

Signature

TypeScript
setColumnDefaultStyle(index: number, style: string | Nullable<IStyleData>): FWorksheet

Parameters

  • index numberNo description
  • style string | Nullable<IStyleData>No description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();fWorksheet.setColumnDefaultStyle(0, 'default');// or// fWorksheet.setColumnDefaultStyle(0, {fs: 12, ff: 'Arial'});
Source: @univerjs/sheets

setColumnHeaderHeight

Signature

TypeScript
setColumnHeaderHeight(height: number): FWorksheet

Parameters

  • height numberNo description

Returns

  • FWorksheet — See signature above.
Source: @univerjs/sheets-ui

setColumnWidth

Sets the width of the given column in pixels.

Signature

TypeScript
setColumnWidth(columnPosition: number, width: number): FWorksheet

Parameters

  • columnPosition numberNo description
  • width numberNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Set width of column B to 100 pixelsfWorksheet.setColumnWidth(1, 100);
Source: @univerjs/sheets

setColumnWidths

Sets the width of the given columns in pixels.

Signature

TypeScript
setColumnWidths(startColumn: number, numColumn: number, width: number): FWorksheet

Parameters

  • startColumn numberNo description
  • numColumn numberNo description
  • width numberNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Set width of columns B-D (index 1-3) to 100 pixelsfWorksheet.setColumnWidths(1, 3, 100);
Source: @univerjs/sheets

setFrozenColumns

Signature

TypeScript
setFrozenColumns(...args: [number] | [number, number]): FWorksheet

Parameters

  • args [number, number] | [number]No description

Returns

  • FWorksheet — See signature above.
Source: @univerjs/sheets

setFrozenRows

Signature

TypeScript
setFrozenRows(...args: [number] | [number, number]): FWorksheet

Parameters

  • args [number, number] | [number]No description

Returns

  • FWorksheet — See signature above.
Source: @univerjs/sheets

setGridLinesColor

Set the color of the gridlines in the sheet.

Signature

TypeScript
setGridLinesColor(color: string | undefined): FWorksheet

Parameters

  • color stringNo description

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining

Examples

TypeScript
const fWorkSheet = univerAPI.getActiveWorkbook().getActiveSheet();// set the gridlines color to redfWorkSheet.setGridLinesColor('#ff0000');
Source: @univerjs/sheets

setRowAutoHeight

Sets the height of the given rows to auto.

Signature

TypeScript
setRowAutoHeight(startRow: number, numRows: number): FWorksheet

Parameters

  • startRow numberNo description
  • numRows numberNo description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();fWorksheet.setRowAutoHeight(1, 10);
Source: @univerjs/sheets

setRowCount

Sets the number of rows in the worksheet.

Signature

TypeScript
setRowCount(rowCount: number): FWorksheet

Parameters

  • rowCount numberNo description

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();// Set the number of rows in the worksheet to 40fWorkSheet.setRowCount(40);
Source: @univerjs/sheets

setRowCustom

Set custom properties for given rows.

Signature

TypeScript
setRowCustom(custom: IObjectArrayPrimitiveType<CustomData>): FWorksheet

Parameters

  • custom IObjectArrayPrimitiveType<CustomData>No description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

TypeScript
const fWorkSheet = univerAPI.getActiveWorkbook().getActiveSheet();fWorkSheet.setRowCustom({ 0: { key: 'value' } });
Source: @univerjs/sheets

setRowCustomMetadata

Set custom metadata of row

Signature

TypeScript
setRowCustomMetadata(index: number, custom: CustomData | undefined): FWorksheet

Parameters

  • index numberNo description
  • custom CustomDataNo description

Returns

  • FWorksheet — Current worksheet, for chaining.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();fWorkSheet.setRowCustomMetadata(0, { key: 'value' });
Source: @univerjs/sheets

setRowDefaultStyle

Set the default style of the worksheet column

Signature

TypeScript
setRowDefaultStyle(index: number, style: string | Nullable<IStyleData>): FWorksheet

Parameters

  • index numberNo description
  • style string | Nullable<IStyleData>No description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();fWorksheet.setRowDefaultStyle(0, 'default');// or// fWorksheet.setRowDefaultStyle(0, {fs: 12, ff: 'Arial'});
Source: @univerjs/sheets

setRowHeaderWidth

Signature

TypeScript
setRowHeaderWidth(width: number): FWorksheet

Parameters

  • width numberNo description

Returns

  • FWorksheet — See signature above.
Source: @univerjs/sheets-ui

setRowHeight

Sets the row height of the given row in pixels. By default, rows grow to fit cell contents. If you want to force rows to a specified height, use setRowHeightsForced(startRow, numRows, height).

Signature

TypeScript
setRowHeight(rowPosition: number, height: number): FWorksheet

Parameters

  • rowPosition numberNo description
  • height numberNo description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Set the height of the second row to 30 pixelsfWorksheet.setRowHeight(1, 30);// Set the height of the first row to 20 pixelsfWorksheet.setRowHeight(0, 20);
Source: @univerjs/sheets

setRowHeights

Sets the height of the given rows in pixels. By default, rows grow to fit cell contents. If you want to force rows to a specified height, use setRowHeightsForced(startRow, numRows, height).

Signature

TypeScript
setRowHeights(startRow: number, numRows: number, height: number): FWorksheet

Parameters

  • startRow numberNo description
  • numRows numberNo description
  • height numberNo description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();fWorksheet.setRowHeights(1, 10, 30);
Source: @univerjs/sheets

setRowHeightsForced

Sets the height of the given rows in pixels. By default, rows grow to fit cell contents. When you use setRowHeightsForced, rows are forced to the specified height even if the cell contents are taller than the row height.

Signature

TypeScript
setRowHeightsForced(startRow: number, numRows: number, height: number): FWorksheet

Parameters

  • startRow numberNo description
  • numRows numberNo description
  • height numberNo description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();fWorksheet.setRowHeightsForced(1, 10, 30);
Source: @univerjs/sheets

setTabColor

Sets the sheet tab color.

Signature

TypeScript
setTabColor(color: string): FWorksheet

Parameters

  • color stringNo description

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();// set the tab color to redfWorkSheet.setTabColor('#ff0000');
Source: @univerjs/sheets

showColumns

Show one or more consecutive columns starting at the given index. Use 0-index for this method

Signature

TypeScript
showColumns(columnIndex: number, numColumns: number = 1): FWorksheet

Parameters

  • columnIndex numberNo description
  • numColumns number (optional)No description

Returns

  • FWorksheet — This sheet, for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Unhide columns C, D, EfWorksheet.showColumns(2, 3);// Unhide column AfWorksheet.showColumns(0, 1);
Source: @univerjs/sheets

showRows

Scrolling sheet to make specific rows visible.

Signature

TypeScript
showRows(rowIndex: number, numRows: number = 1): FWorksheet

Parameters

  • rowIndex numberNo description
  • numRows number (optional)No description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Show 3 rows starting from row index 1 (rows 2-4)fWorksheet.showRows(1, 3);// Show single row at index 0 (first row)fWorksheet.showRows(0);
Source: @univerjs/sheets

unhideColumn

Show the column in the given range.

Signature

TypeScript
unhideColumn(column: FRange): FWorksheet

Parameters

  • column FRangeNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Unhide columns C, D, Econst column1 = fWorksheet.getRange('C:E');fWorksheet.unhideColumn(column1);// Unhide column Aconst column2 = fWorksheet.getRange('A:A');fWorksheet.unhideColumn(column2);
Source: @univerjs/sheets

unhideRow

Make the row in the given range visible.

Signature

TypeScript
unhideRow(row: FRange): FWorksheet

Parameters

  • row FRangeNo description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Unhide 3 rows starting from row index 1 (rows 2-4)const row1 = fWorksheet.getRange('2:4');fWorksheet.unhideRow(row1);// Unhide single row at index 0 (first row)const row2 = fWorksheet.getRange('1:1');fWorksheet.unhideRow(row2);
Source: @univerjs/sheets

Visibility & Protection

hideSheet

Hides this sheet. Has no effect if the sheet is already hidden. If this method is called on the only visible sheet, it throws an exception.

Signature

TypeScript
hideSheet(): FWorksheet

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();// hide the active sheetfWorkSheet.hideSheet();
Source: @univerjs/sheets

showSheet

Shows this sheet. Has no effect if the sheet is already visible.

Signature

TypeScript
showSheet(): FWorksheet

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheets = fWorkbook.getSheets();// show the last sheetfWorkSheets[fWorkSheets.length - 1].showSheet();
Source: @univerjs/sheets

Charts & Drawings

deleteImages

Signature

TypeScript
deleteImages(sheetImages: FOverGridImage[]): FWorksheet

Parameters

  • sheetImages FOverGridImage[]No description

Returns

  • FWorksheet — See signature above.
Source: @univerjs/sheets-drawing

getActiveImages

Signature

TypeScript
getActiveImages(): FOverGridImage[]

Returns

  • FOverGridImage[] — See signature above.
Source: @univerjs/sheets-drawing

charts

Returns the worksheet chart collection facade.

Signature

TypeScript
readonly charts: FWorksheetCharts

Returns

  • FWorksheetCharts — Worksheet-scoped chart collection APIs.
Source: @univerjs-pro/sheets-chart

getDrawingGroupChildren

Signature

TypeScript
getDrawingGroupChildren(groupId: string, recursive?: boolean): ISheetDrawing[]

Parameters

  • groupId string — The group drawing id.
  • recursive boolean (optional) — Whether to return all descendants.

Returns

  • ISheetDrawing[] — The child drawings in the group.
Source: @univerjs/sheets-drawing

getDrawingParentGroup

Signature

TypeScript
getDrawingParentGroup(drawingId: string): ISheetDrawing | null

Parameters

  • drawingId string — The child drawing id.

Returns

  • ISheetDrawing | null — The parent group drawing, or null if the drawing is not grouped.
Source: @univerjs/sheets-drawing

getImageById

Signature

TypeScript
getImageById(id: string): FOverGridImage | null

Parameters

  • id stringNo description

Returns

  • FOverGridImage — See signature above.
Source: @univerjs/sheets-drawing

getImages

Signature

TypeScript
getImages(): FOverGridImage[]

Returns

  • FOverGridImage[] — See signature above.
Source: @univerjs/sheets-drawing

groupDrawings

Signature

TypeScript
groupDrawings(drawingIds: string[], groupId?: string): string | null

Parameters

  • drawingIds string[] — Drawing ids to group on the current sheet.
  • groupId string (optional) — Optional id for the new group drawing.

Returns

  • string | null — The group drawing id, or null when grouping cannot be completed.
Source: @univerjs/sheets-drawing

getShapes

Returns all shapes and connectors on this worksheet.

Signature

TypeScript
getShapes(): Array<FSheetShape | FConnectorShape>

Returns

  • Array<FSheetShape | FConnectorShape> — Live worksheet shape facades.
Source: @univerjs-pro/sheets-shape

getShape

Returns a worksheet shape by its stable identifier.

Signature

TypeScript
getShape(shapeId: string): FSheetShape | FConnectorShape | null

Parameters

  • shapeId string — The shape identifier.

Returns

  • FSheetShape | FConnectorShape | null — The live shape facade, or null when it does not exist.
Source: @univerjs-pro/sheets-shape

insertImage

Signature

TypeScript
async insertImage(url: IFBlobSource | string, column?: number, row?: number, offsetX?: number, offsetY?: number): Promise<boolean>

Parameters

  • url anyNo description
  • column number (optional)No description
  • row number (optional)No description
  • offsetX number (optional)No description
  • offsetY number (optional)No description

Returns

  • Promise<boolean> — See signature above.
Source: @univerjs/sheets-drawing

insertImages

Signature

TypeScript
insertImages(sheetImages: ISheetImage[]): FWorksheet

Parameters

  • sheetImages ISheetImage[]No description

Returns

  • FWorksheet — See signature above.
Source: @univerjs/sheets-drawing

isDrawingGrouped

Signature

TypeScript
isDrawingGrouped(drawingId: string): boolean

Parameters

  • drawingId string — The drawing id.

Returns

  • booleantrue if the drawing has a parent group.
Source: @univerjs/sheets-drawing

insertShape

Inserts a shape or connector into this worksheet.

Signature

TypeScript
insertShape(input: IShapeCreateInput): FSheetShape | FConnectorShape | null

Parameters

  • input IShapeCreateInput — Common shape creation input.

Returns

  • FSheetShape | FConnectorShape | null — A live worksheet shape facade, or null when creation fails.
Source: @univerjs-pro/sheets-shape

newOverGridImage

Signature

TypeScript
newOverGridImage(): FOverGridImageBuilder

Returns

  • FOverGridImageBuilder — See signature above.
Source: @univerjs/sheets-drawing

saveCellImagesAsync

Signature

TypeScript
async saveCellImagesAsync(options?: ISaveCellImagesOptions, ranges?: FRange[]): Promise<boolean>

Parameters

  • options ISaveCellImagesOptions (optional)No description
  • ranges FRange[] (optional)No description

Returns

  • Promise<boolean> — See signature above.
Source: @univerjs/sheets-drawing-ui

ungroupDrawings

Signature

TypeScript
ungroupDrawings(groupIds: string[]): boolean

Parameters

  • groupIds string[] — Group drawing ids to ungroup.

Returns

  • booleantrue if the operation succeeds.
Source: @univerjs/sheets-drawing

updateImages

Signature

TypeScript
updateImages(sheetImages: ISheetImage[]): FWorksheet

Parameters

  • sheetImages ISheetImage[]No description

Returns

  • FWorksheet — See signature above.
Source: @univerjs/sheets-drawing

Filter & Sort

getFilter

Signature

TypeScript
getFilter(): FFilter | null

Returns

  • FFilter — See signature above.
Source: @univerjs/sheets-filter

resetFilter

Signature

TypeScript
resetFilter(tableId: string, column: number): Promise<boolean>

Parameters

  • tableId stringNo description
  • column numberNo description

Returns

  • Promise<boolean> — See signature above.
Source: @univerjs/sheets-table

setTableFilter

Signature

TypeScript
setTableFilter(tableId: string, column: number, filter: ITableFilterItem): Promise<boolean>

Parameters

  • tableId stringNo description
  • column numberNo description
  • filter ITableFilterItemNo description

Returns

  • Promise<boolean> — See signature above.
Source: @univerjs/sheets-table

sort

Signature

TypeScript
sort(colIndex: number, asc = true): FWorksheet

Parameters

  • colIndex numberNo description
  • asc boolean (optional)No description

Returns

  • FWorksheet — See signature above.
Source: @univerjs/sheets-sort

Miscellaneous

activate

Activates this sheet. Does not alter the sheet itself, only the parent's notion of the active sheet.

Signature

TypeScript
activate(): FWorksheet

Returns

  • FWorksheet — Current sheet, for chaining.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheets = fWorkbook.getSheets();// activate the last sheetfWorkSheets[fWorkSheets.length - 1].activate();
Source: @univerjs/sheets

addConditionalFormattingRule

Signature

TypeScript
addConditionalFormattingRule(rule: IConditionFormattingRule): FWorksheet

Parameters

  • rule IConditionFormattingRuleNo description

Returns

  • FWorksheet — See signature above.
Source: @univerjs/sheets-conditional-formatting

addFloatDomToPosition

Signature

TypeScript
addFloatDomToPosition(layer: IFICanvasFloatDom, id?: string): Nullable<{        id: string;        dispose: () => void;    }>

Parameters

  • layer IFICanvasFloatDomNo description
  • id string (optional)No description

Returns

  • Nullable<{ id: string; dispose: () => void; }> — See signature above.
Source: @univerjs/sheets-drawing-ui

addFloatDomToRange

Signature

TypeScript
addFloatDomToRange(fRange: FRange, layer: IFICanvasFloatDom, domLayout: IDOMAnchor, id?: string): Nullable<{        id: string;        dispose: () => void;    }>

Parameters

  • fRange FRangeNo description
  • layer IFICanvasFloatDomNo description
  • domLayout IDOMAnchorNo description
  • id string (optional)No description

Returns

  • Nullable<{ id: string; dispose: () => void; }> — See signature above.
Source: @univerjs/sheets-drawing-ui

addSparkline

Signature

TypeScript
addSparkline(sourceRanges: IRange[], targetRanges: IRange[], type: SparklineTypeEnum.LINE_CHART): FSparkline | undefined

Parameters

  • sourceRanges IRange[]No description
  • targetRanges IRange[]No description
  • type SparklineTypeEnum.LINE_CHARTNo description

Returns

  • FSparkline — See signature above.
Source: @univerjs-pro/sheets-sparkline

addTable

Signature

TypeScript
addTable(tableName: string, rangeInfo: ITableRange, tableId?: string, options?: ITableOptions): Promise<boolean> | boolean

Parameters

  • tableName stringNo description
  • rangeInfo ITableRangeNo description
  • tableId string (optional)No description
  • options ITableOptions (optional)No description

Returns

  • boolean | Promise<boolean> — See signature above.
Source: @univerjs/sheets-table

addTableTheme

Signature

TypeScript
addTableTheme(tableId: string, themeStyleJSON: IRangeThemeStyleJSON): Promise<boolean>

Parameters

  • tableId stringNo description
  • themeStyleJSON IRangeThemeStyleJSONNo description

Returns

  • Promise<boolean> — See signature above.
Source: @univerjs/sheets-table

batchUpdateFloatDoms

Signature

TypeScript
batchUpdateFloatDoms(updates: Array<{ id: string; config: Partial<Omit<IFCanvasFloatDomResult, 'id'>> }>): this

Parameters

  • updates { id: string; config: Partial<Omit<IFCanvasFloatDomResult, "id">>; }[]No description

Returns

  • this — See signature above.
Source: @univerjs/sheets-drawing-ui

cancelFreeze

Cancels the frozen state of the current sheet.

Signature

TypeScript
cancelFreeze(): FWorksheet

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Cancel freezefWorksheet.cancelFreeze();
Source: @univerjs/sheets

clear

Clears the sheet of content and formatting information.Or Optionally clears only the contents or only the formatting.

Signature

TypeScript
clear(options?: IFacadeClearOptions): FWorksheet

Parameters

  • options IFacadeClearOptions (optional)No description

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();// clear the sheet of content and formatting informationfWorkSheet.clear();// clear the sheet of content onlyfWorkSheet.clear({ contentsOnly: true });
Source: @univerjs/sheets

clearConditionalFormatRules

Signature

TypeScript
clearConditionalFormatRules(): FWorksheet

Returns

  • FWorksheet — See signature above.
Source: @univerjs/sheets-conditional-formatting

clearContents

Clears the sheet of contents, while preserving formatting information.

Signature

TypeScript
clearContents(): FWorksheet

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();// clear the sheet of content onlyfWorkSheet.clearContents();
Source: @univerjs/sheets

clearFormats

Clears the sheet of formatting, while preserving contents.

Signature

TypeScript
clearFormats(): FWorksheet

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();// clear the sheet of formatting onlyfWorkSheet.clearFormats();
Source: @univerjs/sheets

composeSparkline

Signature

TypeScript
composeSparkline(ranges: IRange[]): void

Parameters

  • ranges IRange[]No description
Source: @univerjs-pro/sheets-sparkline

deleteConditionalFormattingRule

Signature

TypeScript
deleteConditionalFormattingRule(cfId: string): FWorksheet

Parameters

  • cfId stringNo description

Returns

  • FWorksheet — See signature above.
Source: @univerjs/sheets-conditional-formatting

dispose

Signature

TypeScript
dispose(): void
Source: @univerjs/sheets

equalTo

Judge whether provided FWorksheet is equal to current.

Signature

TypeScript
equalTo(other: FWorksheet): boolean

Parameters

  • other FWorksheetNo description

Returns

  • boolean — true if the FWorksheet is equal to the current FWorksheet, false otherwise.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const sheets = fWorkbook.getSheets();const fWorkSheet = fWorkbook.getActiveSheet();console.log(fWorkSheet.equalTo(sheets[0])); // true, if the active sheet is the first sheet.
Source: @univerjs/sheets

getActiveCell

Returns the active cell in this sheet.

Signature

TypeScript
getActiveCell(): FRange | null

Returns

  • FRange — The active cell

Examples

TypeScript
const fWorkSheet = univerAPI.getActiveWorkbook().getActiveSheet();console.log(fWorkSheet.getActiveCell().getA1Notation());
Source: @univerjs/sheets

getAllDataValidationErrorAsync

Signature

TypeScript
async getAllDataValidationErrorAsync(): Promise<IDataValidationError[]>

Returns

  • Promise<IDataValidationError[]> — See signature above.
Source: @univerjs/sheets-data-validation

getAllFloatDoms

Signature

TypeScript
getAllFloatDoms(): IFCanvasFloatDomResult[]

Returns

  • IFCanvasFloatDomResult[] — See signature above.
Source: @univerjs/sheets-drawing-ui

getAllSubSparkline

Signature

TypeScript
getAllSubSparkline(): Map<string, ISparklineGroup> | undefined

Returns

  • Map<string, ISparklineGroup> — See signature above.
Source: @univerjs-pro/sheets-sparkline

getConditionalFormattingRules

Signature

TypeScript
getConditionalFormattingRules(): IConditionFormattingRule[]

Returns

  • IConditionFormattingRule[] — See signature above.
Source: @univerjs/sheets-conditional-formatting

getCustomMetadata

Get custom metadata of worksheet

Signature

TypeScript
getCustomMetadata(): CustomData | undefined

Returns

  • CustomData — custom metadata

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();const custom = fWorkSheet.getCustomMetadata();console.log(custom);
Source: @univerjs/sheets

getDataRange

Returns a Range corresponding to the dimensions in which data is present. This is functionally equivalent to creating a Range bounded by A1 and (Sheet.getLastColumn(), Sheet.getLastRow()).

Signature

TypeScript
getDataRange(): FRange

Returns

  • FRange — The range of the data in the sheet.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();// Assume the sheet is a empty sheetconst cellRange = fWorkSheet.getRange('J50');cellRange.setValue('Hello World');console.log(fWorkSheet.getDataRange().getA1Notation()); // A1:J50
Source: @univerjs/sheets

getDataValidation

Signature

TypeScript
getDataValidation(ruleId: string): Nullable<FDataValidation>

Parameters

  • ruleId stringNo description

Returns

  • Nullable<FDataValidation> — See signature above.
Source: @univerjs/sheets-data-validation

getDataValidations

Signature

TypeScript
getDataValidations(): FDataValidation[]

Returns

  • FDataValidation[] — See signature above.
Source: @univerjs/sheets-data-validation

getDefaultStyle

Get the default style of the worksheet.

Signature

TypeScript
getDefaultStyle(): Nullable<IStyleData> | string

Returns

  • string | Nullable<IStyleData> — Default style of the worksheet.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();const defaultStyle = fWorksheet.getDefaultStyle();console.log(defaultStyle);
Source: @univerjs/sheets

getDefinedNames

Get all the defined names in the worksheet.

Signature

TypeScript
getDefinedNames(): FDefinedName[]

Returns

  • FDefinedName[] — All the defined names in the worksheet

Examples

TypeScript
// The code below gets all the defined names in the worksheetconst fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();const definedNames = fWorksheet.getDefinedNames();console.log(definedNames, definedNames[0]?.getFormulaOrRefString());
Source: @univerjs/sheets

getFloatDomById

Signature

TypeScript
getFloatDomById(id: string): Nullable<IFCanvasFloatDomResult>

Parameters

  • id stringNo description

Returns

  • Nullable<IFCanvasFloatDomResult> — See signature above.
Source: @univerjs/sheets-drawing-ui

getFreeze

Get the freeze state of the current sheet.

Signature

TypeScript
getFreeze(): IFreeze

Returns

  • IFreeze — The freeze state of the current sheet

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Get the freeze state of the current sheetconst freeze = fWorksheet.getFreeze();console.log(freeze);
Source: @univerjs/sheets

getIndex

Gets the position of the sheet in its parent spreadsheet. Starts at 0.

Signature

TypeScript
getIndex(): number

Returns

  • number — The position of the sheet in its parent spreadsheet.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();// get the position of the active sheetconst position = fWorkSheet.getIndex();console.log(position);
Source: @univerjs/sheets

getInject

Get the injector instance.

Signature

TypeScript
getInject(): Injector

Returns

  • Injector — The injector instance.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();const injector = fWorksheet.getInject();console.log(injector);
Source: @univerjs/sheets

getMergeData

Get all merged cells in the current worksheet

Signature

TypeScript
getMergeData(): FRange[]

Returns

  • FRange[] — All the merged cells in the worksheet

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Get all merged ranges in the sheetconst mergedData = fWorksheet.getMergeData();// Process each merged rangemergedData.forEach(range => {  console.log(range.getA1Notation());});
Source: @univerjs/sheets

getMergedRanges

Get all merged cells in the current sheet

Signature

TypeScript
getMergedRanges(): FRange[]

Returns

  • FRange[] — all merged cells

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Get all merged ranges in the sheetconst mergedRanges = fWorksheet.getMergedRanges();// Process each merged rangemergedRanges.forEach(range => {  console.log(range.getA1Notation());});
Source: @univerjs/sheets

Outline

addColumnOutline

Add a column outline group to the current worksheet.

The column index is zero-based. The group covers numColumns columns starting at startColumn, so addColumnOutline(0, 3) groups columns A to C. Invalid groups are ignored and will not be added, including negative ranges, zero or negative column counts, ranges outside the worksheet, crossing groups, and groups that exceed the maximum outline depth.

Signature

TypeScript
addColumnOutline(startColumn: number, numColumns: number): FWorksheet

Parameters

  • startColumn number — The zero-based start column index of the outline group.
  • numColumns number — The number of columns included in the outline group.

Returns

  • FWorksheet — The current worksheet instance, allowing chained facade calls.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();// Group columns B to E.fWorksheet.addColumnOutline(1, 4);
Source: @univerjs-pro/sheets-outline

addRowOutline

Add a row outline group to the current worksheet.

The row index is zero-based. The group covers numRows rows starting at startRow, so addRowOutline(1, 3) groups rows 2 to 4. Invalid groups are ignored and will not be added, including negative ranges, zero or negative row counts, ranges outside the worksheet, crossing groups, and groups that exceed the maximum outline depth.

Signature

TypeScript
addRowOutline(startRow: number, numRows: number): FWorksheet

Parameters

  • startRow number — The zero-based start row index of the outline group.
  • numRows number — The number of rows included in the outline group.

Returns

  • FWorksheet — The current worksheet instance, allowing chained facade calls.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();// Group rows 2 to 6.fWorksheet.addRowOutline(1, 5);
Source: @univerjs-pro/sheets-outline

clearDimensionOutlines

Clear outline groups in a row or column range.

The range uses zero-based indexes and is inclusive: [start, end]. Only outline groups on the specified axis whose ranges are fully contained in this range are removed.

Signature

TypeScript
clearDimensionOutlines(axis: DimensionOutlineAxis, start: number, end: number): FWorksheet

Parameters

  • axis DimensionOutlineAxis — The outline axis to clear.
  • start number — The zero-based inclusive start index of the clear range.
  • end number — The zero-based inclusive end index of the clear range.

Returns

  • FWorksheet — The current worksheet instance, allowing chained facade calls.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();// Remove row outline groups fully contained in rows 2 to 10.fWorksheet.clearDimensionOutlines(univerAPI.Enum.DimensionOutlineAxis.ROW, 1, 9);
Source: @univerjs-pro/sheets-outline

getDimensionOutlines

Get outline groups on the current worksheet.

When axis is omitted, both row and column outline groups are returned. The returned array is a snapshot of the current outline data; use command or facade methods to make changes instead of mutating the returned objects directly.

Signature

TypeScript
getDimensionOutlines(axis?: DimensionOutlineAxis): IDimensionOutline[]

Parameters

  • axis DimensionOutlineAxis (optional) — Optional outline axis filter.

Returns

  • IDimensionOutline[] — The outline groups on the current worksheet.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();const rowOutlines = fWorksheet.getDimensionOutlines(univerAPI.Enum.DimensionOutlineAxis.ROW);rowOutlines.forEach((outline) => {  console.log(outline.id, outline.start, outline.end, outline.collapsed);});
Source: @univerjs-pro/sheets-outline

removeDimensionOutline

Remove a row or column outline group from the current worksheet.

Use getDimensionOutlines() to read the current outline ids. Removing a parent outline does not remove unrelated sibling outlines.

Signature

TypeScript
removeDimensionOutline(outlineId: string): FWorksheet

Parameters

  • outlineId string — The id of the outline group to remove.

Returns

  • FWorksheet — The current worksheet instance, allowing chained facade calls.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();const [firstRowOutline] = fWorksheet.getDimensionOutlines(univerAPI.Enum.DimensionOutlineAxis.ROW);if (firstRowOutline) {  fWorksheet.removeDimensionOutline(firstRowOutline.id);}
Source: @univerjs-pro/sheets-outline

setDimensionOutlineCollapsed

Collapse or expand an existing row or column outline group.

Pass true to collapse the group and hide its grouped rows or columns. Pass false to expand it and show the grouped rows or columns again, subject to other nested collapsed groups.

Signature

TypeScript
setDimensionOutlineCollapsed(outlineId: string, collapsed: boolean): FWorksheet

Parameters

  • outlineId string — The id of the outline group to update.
  • collapsed boolean — Whether the outline group should be collapsed.

Returns

  • FWorksheet — The current worksheet instance, allowing chained facade calls.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();const [firstColumnOutline] = fWorksheet.getDimensionOutlines(univerAPI.Enum.DimensionOutlineAxis.COLUMN);if (firstColumnOutline) {  // Collapse the group.  fWorksheet.setDimensionOutlineCollapsed(firstColumnOutline.id, true);  // Expand it later.  fWorksheet.setDimensionOutlineCollapsed(firstColumnOutline.id, false);}
Source: @univerjs-pro/sheets-outline

getPivotTableByCell

Signature

TypeScript
getPivotTableByCell(row: number, col: number): FPivotTable | undefined

Parameters

  • row numberNo description
  • col numberNo description

Returns

  • FPivotTable — See signature above.
Source: @univerjs-pro/sheets-pivot

getScrollState

Signature

TypeScript
getScrollState(): IScrollState

Returns

  • IScrollState — See signature above.
Source: @univerjs/sheets-ui

getSheet

Get the worksheet instance.

Signature

TypeScript
getSheet(): Worksheet

Returns

  • Worksheet — The worksheet instance.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();const sheet = fWorksheet.getSheet();console.log(sheet);
Source: @univerjs/sheets

getSheetId

Get the worksheet id.

Signature

TypeScript
getSheetId(): string

Returns

  • string — The id of the worksheet.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();const sheetId = fWorksheet.getSheetId();console.log(sheetId);
Source: @univerjs/sheets

getSheetName

Get the worksheet name.

Signature

TypeScript
getSheetName(): string

Returns

  • string — The name of the worksheet.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();const sheetName = fWorksheet.getSheetName();console.log(sheetName);
Source: @univerjs/sheets

getSkeleton

Signature

TypeScript
getSkeleton(): Nullable<SpreadsheetSkeleton>

Returns

  • Nullable<SpreadsheetSkeleton> — See signature above.
Source: @univerjs/sheets-ui

getSparklineByCell

Signature

TypeScript
getSparklineByCell(row: number, col: number): FSparkline | undefined

Parameters

  • row numberNo description
  • col numberNo description

Returns

  • FSparkline — See signature above.
Source: @univerjs-pro/sheets-sparkline

getSparklineGroupByCell

Signature

TypeScript
getSparklineGroupByCell(row: number, col: number): FSparklineGroup | undefined

Parameters

  • row numberNo description
  • col numberNo description

Returns

  • FSparklineGroup — See signature above.
Source: @univerjs-pro/sheets-sparkline

getSubTableInfos

Signature

TypeScript
getSubTableInfos(): ITableInfoWithUnitId[]

Returns

  • ITableInfoWithUnitId[] — See signature above.
Source: @univerjs/sheets-table

getTableByCell

Signature

TypeScript
getTableByCell(row: number, column: number): ITableInfoWithUnitId | undefined

Parameters

  • row numberNo description
  • column numberNo description

Returns

  • any — See signature above.
Source: @univerjs/sheets-table

getUrl

Generate a hyperlink URL for the current worksheet.

Signature

TypeScript
getUrl(): string

Returns

  • string — The generated URL string (e.g. #gid=sheet1).

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorksheet = fWorkbook.getActiveSheet();console.log(fWorksheet.getUrl()); // #gid=...
Source: @univerjs/sheets-hyper-link

getValidatorStatus

Signature

TypeScript
getValidatorStatus(): Promise<ObjectMatrix<Nullable<DataValidationStatus>>>

Returns

  • Promise<ObjectMatrix<Nullable<DataValidationStatus>>> — See signature above.
Source: @univerjs/sheets-data-validation

getValidatorStatusAsync

Signature

TypeScript
getValidatorStatusAsync(): Promise<ObjectMatrix<Nullable<DataValidationStatus>>>

Returns

  • Promise<ObjectMatrix<Nullable<DataValidationStatus>>> — See signature above.
Source: @univerjs/sheets-data-validation

getVisibleRange

Signature

TypeScript
getVisibleRange(): IRange | null

Returns

  • IRange — See signature above.
Source: @univerjs/sheets-ui

getVisibleRangesOfAllViewports

Signature

TypeScript
getVisibleRangesOfAllViewports(): Map<SHEET_VIEWPORT_KEY, IRange> | null

Returns

  • Map<SHEET_VIEWPORT_KEY, IRange> — See signature above.
Source: @univerjs/sheets-ui

getWorkbook

Get the workbook instance.

Signature

TypeScript
getWorkbook(): Workbook

Returns

  • Workbook — The workbook instance.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();const workbook = fWorksheet.getWorkbook();console.log(workbook);
Source: @univerjs/sheets

getWorksheetPermission

Get the WorksheetPermission instance for managing worksheet-level permissions. This is the new permission API that provides worksheet-specific permission control.

Signature

TypeScript
getWorksheetPermission(): FWorksheetPermission

Returns

  • FWorksheetPermission — - The WorksheetPermission instance.

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();const permission = fWorksheet.getWorksheetPermission();// Set worksheet to read-only modeawait permission.setMode('readOnly');// Check if a specific cell can be editedconst canEdit = permission.canEditCell(0, 0);// Protect multiple ranges at onceconst range1 = fWorksheet.getRange('A1:B10');const range2 = fWorksheet.getRange('D1:E10');await permission.protectRanges([  { ranges: [range1], options: { name: 'Range 1', allowViewByOthers: false } },  { ranges: [range2], options: { name: 'Range 2', allowViewByOthers: false } }]);// Subscribe to permission changespermission.permission$.subscribe(snapshot => {  console.log('Worksheet permissions changed:', snapshot);});
Source: @univerjs/sheets

getZoom

Signature

TypeScript
getZoom(): number

Returns

  • number — See signature above.
Source: @univerjs/sheets-ui

hasHiddenGridLines

Returns true if the sheet's gridlines are hidden; otherwise returns false. Gridlines are visible by default.

Signature

TypeScript
hasHiddenGridLines(): boolean

Returns

  • boolean — True if the sheet's gridlines are hidden; otherwise false.

Examples

TypeScript
const fWorkSheet = univerAPI.getActiveWorkbook().getActiveSheet();// check if the gridlines are hiddenif (fWorkSheet.hasHiddenGridLines()) {   console.log('Gridlines are hidden');}
Source: @univerjs/sheets

highlightRanges

Signature

TypeScript
highlightRanges(ranges: FRange[], style?: Nullable<Partial<ISelectionStyle>>, primary?: Nullable<ISelectionCell>): IDisposable

Parameters

  • ranges FRange[]No description
  • style Nullable<Partial<ISelectionStyle>> (optional)No description
  • primary Nullable<ISelectionCell> (optional)No description

Returns

  • IDisposable — See signature above.
Source: @univerjs/sheets-ui

insertDefinedName

Insert a defined name for worksheet.

Signature

TypeScript
insertDefinedName(name: string, formulaOrRefString: string): void

Parameters

  • name stringNo description
  • formulaOrRefString stringNo description

Examples

TypeScript
// The code below inserts a defined nameconst fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();fWorksheet.insertDefinedName('MyDefinedName', 'Sheet1!$A$1');
Source: @univerjs/sheets

isSheetHidden

Returns true if the sheet is currently hidden.

Signature

TypeScript
isSheetHidden(): boolean

Returns

  • boolean — True if the sheet is hidden; otherwise, false.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheets = fWorkbook.getSheets();// check if the last sheet is hiddenconsole.log(fWorkSheets[fWorkSheets.length - 1].isSheetHidden());
Source: @univerjs/sheets

moveConditionalFormattingRule

Signature

TypeScript
moveConditionalFormattingRule(cfId: string, toCfId: string, type: IAnchor['type'] = 'after'): FWorksheet

Parameters

  • cfId stringNo description
  • toCfId stringNo description
  • type IAnchor (optional)No description

Returns

  • FWorksheet — See signature above.
Source: @univerjs/sheets-conditional-formatting

newConditionalFormattingRule

Signature

TypeScript
newConditionalFormattingRule(): FConditionalFormattingBuilder

Returns

  • FConditionalFormattingBuilder — See signature above.
Source: @univerjs/sheets-conditional-formatting

onBeforeCellDataChange

Deprecated — use univerAPI.addEvent(univerAPI.Event.BeforeSheetEditEnd, (params) =&gt; &#123;&#125;) instead

Signature

TypeScript
onBeforeCellDataChange(callback: (cellValue: ObjectMatrix<Nullable<ICellData>>) => void): IDisposable

Parameters

  • callback (cellValue: ObjectMatrix<Nullable<ICellData>>) => voidNo description

Returns

  • IDisposable — See signature above.
Source: @univerjs/sheets

onCellDataChange

Deprecated — use univerAPI.addEvent(univerAPI.Event.SheetValueChanged, (params) =&gt; &#123;&#125;) instead

Signature

TypeScript
onCellDataChange(callback: (cellValue: ObjectMatrix<Nullable<ICellData>>) => void): IDisposable

Parameters

  • callback (cellValue: ObjectMatrix<Nullable<ICellData>>) => voidNo description

Returns

  • IDisposable — See signature above.
Source: @univerjs/sheets

onScroll

Signature

TypeScript
onScroll(callback: (params: Nullable<IViewportScrollState>) => void): IDisposable

Parameters

  • callback (params: any) => voidNo description

Returns

  • IDisposable — See signature above.
Source: @univerjs/sheets-ui

refreshCanvas

Signature

TypeScript
refreshCanvas(): FWorksheet

Returns

  • FWorksheet — See signature above.
Source: @univerjs/sheets-ui

removeFloatDom

Signature

TypeScript
removeFloatDom(id: string): this

Parameters

  • id stringNo description

Returns

  • this — See signature above.
Source: @univerjs/sheets-drawing-ui

removeTable

Signature

TypeScript
removeTable(tableId: string): Promise<boolean>

Parameters

  • tableId stringNo description

Returns

  • Promise<boolean> — See signature above.
Source: @univerjs/sheets-table

scrollToCell

Signature

TypeScript
scrollToCell(row: number, column: number, duration?: number): FWorksheet

Parameters

  • row numberNo description
  • column numberNo description
  • duration number (optional)No description

Returns

  • FWorksheet — See signature above.
Source: @univerjs/sheets-ui

setActiveRange

Sets the active selection region for this sheet.

Signature

TypeScript
setActiveRange(range: FRange): FWorksheet

Parameters

  • range FRangeNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

TypeScript
const fWorkSheet = univerAPI.getActiveWorkbook().getActiveSheet();fWorkSheet.setActiveRange(fWorkSheet.getRange('A10:B10'));
Source: @univerjs/sheets

setActiveSelection

Sets the active selection region for this sheet.

Signature

TypeScript
setActiveSelection: (range: FRange) => FWorksheet

Returns

  • (range: FRange) => FWorksheet — This sheet, for chaining

Examples

TypeScript
const fWorkSheet = univerAPI.getActiveWorkbook().getActiveSheet();fWorkSheet.setActiveSelection(fWorkSheet.getRange('A10:B10'));
Source: @univerjs/sheets

setConditionalFormattingRule

Signature

TypeScript
setConditionalFormattingRule(cfId: string, rule: IConditionFormattingRule): FWorksheet

Parameters

  • cfId stringNo description
  • rule IConditionFormattingRuleNo description

Returns

  • FWorksheet — See signature above.
Source: @univerjs/sheets-conditional-formatting

setCustomMetadata

Set custom metadata of worksheet

Signature

TypeScript
setCustomMetadata(custom: CustomData | undefined): FWorksheet

Parameters

  • custom CustomDataNo description

Returns

  • FWorksheet — Current worksheet, for chaining.

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();fWorkSheet.setCustomMetadata({ key: 'value' });
Source: @univerjs/sheets

setDefaultStyle

Set the default style of the worksheet

Signature

TypeScript
setDefaultStyle(style: string | Nullable<IStyleData>): FWorksheet

Parameters

  • style string | Nullable<IStyleData>No description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();fWorksheet.setDefaultStyle('default');// or// fWorksheet.setDefaultStyle({fs: 12, ff: 'Arial'});
Source: @univerjs/sheets

setFreeze

Deprecated — use setFrozenRows and setFrozenColumns instead.

Sets the frozen state of the current sheet.

Signature

TypeScript
setFreeze(freeze: IFreeze): FWorksheet

Parameters

  • freeze IFreezeNo description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();// Freeze first 3 rows and 2 columnsfWorksheet.setFreeze({  startRow: 3,  startColumn: 2,  xSplit: 2,  ySplit: 3});
Source: @univerjs/sheets

setHiddenGridlines

Hides or reveals the sheet gridlines.

Signature

TypeScript
setHiddenGridlines(hidden: boolean): FWorksheet

Parameters

  • hidden booleanNo description

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining

Examples

TypeScript
 tsconst fWorkSheet = univerAPI.getActiveWorkbook().getActiveSheet();// hide the gridlinesfWorkSheet.setHiddenGridlines(true);
Source: @univerjs/sheets

setName

Sets the sheet name.

Signature

TypeScript
setName(name: string): FWorksheet

Parameters

  • name stringNo description

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining

Examples

TypeScript
const fWorkbook = univerAPI.getActiveWorkbook();const fWorkSheet = fWorkbook.getActiveSheet();// set the sheet name to 'Sheet1'fWorkSheet.setName('NewSheet1');
Source: @univerjs/sheets

setRangesAutoHeight

Sets the height of the given ranges to auto.

Signature

TypeScript
setRangesAutoHeight(ranges: IRange[]): FWorksheet

Parameters

  • ranges IRange[]No description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

TypeScript
const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();const ranges = [{ startRow: 1, endRow: 10, startColumn: 0, endColumn: 10 },{ startRow: 11, endRow: 20, startColumn: 0, endColumn: 10 },]fWorksheet.setRangesAutoHeight(ranges);
Source: @univerjs/sheets

setTableName

Signature

TypeScript
setTableName(tableId: string, tableName: string): Promise<boolean> | boolean

Parameters

  • tableId stringNo description
  • tableName stringNo description

Returns

  • boolean | Promise<boolean> — See signature above.
Source: @univerjs/sheets-table

setTableRange

Signature

TypeScript
setTableRange(tableId: string, rangeInfo: ITableRange): Promise<boolean>

Parameters

  • tableId stringNo description
  • rangeInfo ITableRangeNo description

Returns

  • Promise<boolean> — See signature above.
Source: @univerjs/sheets-table

unComposeSparkline

Signature

TypeScript
unComposeSparkline(ranges: IRange[]): void

Parameters

  • ranges IRange[]No description
Source: @univerjs-pro/sheets-sparkline

updateFloatDom

Signature

TypeScript
updateFloatDom(id: string, config: Partial<Omit<IFCanvasFloatDomResult, 'id'>>): this

Parameters

  • id stringNo description
  • config Partial<Omit<IFCanvasFloatDomResult, "id">>No description

Returns

  • this — See signature above.
Source: @univerjs/sheets-drawing-ui

zoom

Signature

TypeScript
zoom(zoomRatio: number): FWorksheet

Parameters

  • zoomRatio numberNo description

Returns

  • FWorksheet — See signature above.
Source: @univerjs/sheets-ui

Comments & Notes

clearComments

Signature

TypeScript
clearComments(): Promise<boolean>

Returns

  • Promise<boolean> — See signature above.
Source: @univerjs/sheets-thread-comment

getCommentById

Signature

TypeScript
getCommentById(commentId: string): FThreadComment | undefined

Parameters

  • commentId stringNo description

Returns

  • FThreadComment — See signature above.
Source: @univerjs/sheets-thread-comment

getComments

Signature

TypeScript
getComments(): FThreadComment[]

Returns

  • FThreadComment[] — See signature above.
Source: @univerjs/sheets-thread-comment

getNotes

Signature

TypeScript
getNotes(): ISheetNote[]

Returns

  • ISheetNote[] — See signature above.
Source: @univerjs/sheets-note

onCommented

Subscribe to comment events.

Signature

TypeScript
onCommented(callback: (params: IAddCommentCommandParams) => void): IDisposable

Parameters

  • callback (params: IAddCommentCommandParams) => voidNo description

Returns

  • IDisposable — See signature above.
Source: @univerjs/sheets-thread-comment

How is this guide?

© 2026 DreamNum Co., Ltd.