Worksheet

GitHubEdit on GitHub
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-labs/sheets-mcp, @univerjs/sheets-note, @univerjs-pro/sheets-pivot, @univerjs-labs/sheets-node-screenshot, @univerjs/sheets-hyper-link, @univerjs/sheets-sort
CORE

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
getUrl-

@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

@univerjs-pro/sheets-pivot

MethodDescription
getPivotTableByCell-

@univerjs-pro/sheets-shape

@univerjs-pro/sheets-sparkline

@univerjs-labs/sheets-mcp

@univerjs-labs/sheets-node-screenshot

MethodDescription
getScreenshotOnNode-

APIs

Range & Selection

getActiveRange

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

Signature

getActiveRange(): FRange | null

Returns

  • FRange — the active range

Examples

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

getRange

Signature

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

getSelection(): FSelection | null

Returns

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

Examples

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

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

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

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

appendRow(rowContents: CellValue[]): FWorksheet

Parameters

  • rowContents CellValue[]No description

Returns

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

Examples

// 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

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

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

autoResizeColumn

Signature

autoResizeColumn(columnPosition: number): FWorksheet

Parameters

  • columnPosition numberNo description

Returns

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

autoResizeColumns

Signature

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

Parameters

  • startColumn numberNo description
  • numColumns numberNo description

Returns

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

autoResizeRows

Signature

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

Parameters

  • startRow numberNo description
  • numRows numberNo description

Returns

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

customizeColumnHeader

Signature

customizeColumnHeader(cfg: IColumnsHeaderCfgParam): void

Parameters

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

customizeRowHeader

Signature

customizeRowHeader(cfg: IRowsHeaderCfgParam): void

Parameters

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

deleteColumn

Deletes the column at the given column position.

Signature

deleteColumn(columnPosition: number): FWorksheet

Parameters

  • columnPosition numberNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

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

deleteColumns

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

Signature

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

Parameters

  • columnPosition numberNo description
  • howMany numberNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

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

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

Parameters

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

Returns

  • FWorksheet — This sheet, for chaining

Examples

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

deleteRow(rowPosition: number): FWorksheet

Parameters

  • rowPosition numberNo description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

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

deleteRows

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

Signature

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

Parameters

  • rowPosition numberNo description
  • howMany numberNo description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

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

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

Parameters

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

Returns

  • FWorksheet — This sheet, for chaining.

Examples

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

getColumnCustomMetadata(index: number): CustomData | undefined

Parameters

  • index numberNo description

Returns

  • CustomData — custom metadata

Examples

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

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

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 0
const rawColStyle = fWorksheet.getColumnDefaultStyle(0, true);
console.log(rawColStyle);
Source: @univerjs/sheets

getColumnWidth

Gets the width in pixels of the given column.

Signature

getColumnWidth(columnPosition: number): number

Parameters

  • columnPosition numberNo description

Returns

  • number — The width of the column in pixels

Examples

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorksheet = fWorkbook.getActiveSheet();

// Set the long text value in cell A1
const 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 text
fWorksheet.autoResizeColumn(0);

// Get the width of the column A
console.log(fWorksheet.getColumnWidth(0));
Source: @univerjs/sheets

getFrozenColumnRange

Get freezed columns

Signature

getFrozenColumnRange(): IColumnRange

Returns

  • IColumnRange — The range of the frozen columns.

Examples

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

getFrozenColumns

Get the number of frozen columns.

Signature

getFrozenColumns(): number

Returns

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

Examples

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

getFrozenRowRange

Get freezed rows.

Signature

getFrozenRowRange(): IRowRange

Returns

  • IRowRange — The range of the frozen rows.

Examples

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

getFrozenRows

Get the number of frozen rows.

Signature

getFrozenRows(): number

Returns

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

Examples

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

getGridLinesColor

Get the color of the gridlines in the sheet.

Signature

getGridLinesColor(): string | undefined

Returns

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

Examples

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

getLastColumn

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

Signature

getLastColumn(): number

Returns

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

Examples

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
// Assume the sheet is a empty sheet
const 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

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

getLastRow(): number

Returns

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

Examples

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
// Assume the sheet is a empty sheet
const 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

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

getMaxColumns(): number

Returns

  • number — The maximum columns count of the sheet

Examples

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

getMaxRows(): number

Returns

  • number — The maximum rows count of the sheet

Examples

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

getRowCustomMetadata(index: number): CustomData | undefined

Parameters

  • index numberNo description

Returns

  • CustomData — custom metadata

Examples

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

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

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 0
const rawRowStyle = fWorksheet.getRowDefaultStyle(0, true);
console.log(rawRowStyle);
Source: @univerjs/sheets

getRowHeight

Gets the height in pixels of the given row.

Signature

getRowHeight(rowPosition: number): number

Parameters

  • rowPosition numberNo description

Returns

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

Examples

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 bold
const fRange = fWorksheet.getRange('A1');
fRange.setValue('Hello, Univer!').setFontSize(30).setFontWeight('bold');

// Get the height of the first row
console.log(fWorksheet.getRowHeight(0));
Source: @univerjs/sheets

getTabColor

Get the tab color of the sheet.

Signature

getTabColor(): string | undefined

Returns

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

Examples

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

hideColumn

Hides the column or columns in the given range.

Signature

hideColumn(column: FRange): FWorksheet

Parameters

  • column FRangeNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();
// Hide columns C, D, E
const column1 = fWorksheet.getRange('C:E');
fWorksheet.hideColumn(column1);
// Hide column A
const 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

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

Parameters

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

Returns

  • FWorksheet — This sheet, for chaining

Examples

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

hideRow

Hides the rows in the given range.

Signature

hideRow(row: FRange): FWorksheet

Parameters

  • row FRangeNo description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

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

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

Parameters

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

Returns

  • FWorksheet — This sheet, for chaining.

Examples

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

insertColumnAfter(afterPosition: number): FWorksheet

Parameters

  • afterPosition numberNo description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

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

insertColumnBefore

Inserts a column before the given column position.

Signature

insertColumnBefore(beforePosition: number): FWorksheet

Parameters

  • beforePosition numberNo description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

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

insertColumns

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

Signature

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

Parameters

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

Returns

  • FWorksheet — This sheet, for chaining

Examples

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

insertColumnsAfter

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

Signature

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

Parameters

  • afterPosition numberNo description
  • howMany numberNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

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

insertColumnsBefore

Inserts a number of columns before the given column position.

Signature

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

Parameters

  • beforePosition numberNo description
  • howMany numberNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

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

insertRowAfter

Inserts a row after the given row position.

Signature

insertRowAfter(afterPosition: number): FWorksheet

Parameters

  • afterPosition numberNo description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

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

insertRowBefore

Inserts a row before the given row position.

Signature

insertRowBefore(beforePosition: number): FWorksheet

Parameters

  • beforePosition numberNo description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

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

insertRows

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

Signature

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

Parameters

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

Returns

  • FWorksheet — This sheet, for chaining.

Examples

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

insertRowsAfter

Inserts a number of rows after the given row position.

Signature

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

Parameters

  • afterPosition numberNo description
  • howMany numberNo description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

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

insertRowsBefore

Inserts a number of rows before the given row position.

Signature

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

Parameters

  • beforePosition numberNo description
  • howMany numberNo description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();
// Insert 3 rows before the third row
fWorksheet.insertRowsBefore(2, 3);
// Insert 1 row before the first row
fWorksheet.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

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

Parameters

  • columnSpec FRangeNo description
  • destinationIndex numberNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

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

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

Parameters

  • rowSpec FRangeNo description
  • destinationIndex numberNo description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

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

setColumnAutoWidth

Signature

setColumnAutoWidth(columnPosition: number, numColumn: number): FWorksheet

Parameters

  • columnPosition numberNo description
  • numColumn numberNo description

Returns

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

setColumnCount

Sets the number of columns in the worksheet.

Signature

setColumnCount(columnCount: number): FWorksheet

Parameters

  • columnCount numberNo description

Returns

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

Examples

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();

// Set the number of columns in the worksheet to 10
fWorkSheet.setColumnCount(10);
Source: @univerjs/sheets

setColumnCustom

Set custom properties for given columns.

Signature

setColumnCustom(custom: IObjectArrayPrimitiveType<CustomData>): FWorksheet

Parameters

  • custom IObjectArrayPrimitiveType<CustomData>No description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

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

setColumnCustomMetadata

Set custom metadata of column

Signature

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

Parameters

  • index numberNo description
  • custom CustomDataNo description

Returns

  • FWorksheet — Current worksheet, for chaining.

Examples

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

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

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

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

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

Parameters

  • columnPosition numberNo description
  • width numberNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

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

setColumnWidths

Sets the width of the given columns in pixels.

Signature

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

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

setFrozenColumns

Signature

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

Parameters

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

Returns

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

setFrozenRows

Signature

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

setGridLinesColor(color: string | undefined): FWorksheet

Parameters

  • color stringNo description

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining

Examples

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

setRowAutoHeight

Sets the height of the given rows to auto.

Signature

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

Parameters

  • startRow numberNo description
  • numRows numberNo description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

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

setRowCount

Sets the number of rows in the worksheet.

Signature

setRowCount(rowCount: number): FWorksheet

Parameters

  • rowCount numberNo description

Returns

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

Examples

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();

// Set the number of rows in the worksheet to 40
fWorkSheet.setRowCount(40);
Source: @univerjs/sheets

setRowCustom

Set custom properties for given rows.

Signature

setRowCustom(custom: IObjectArrayPrimitiveType<CustomData>): FWorksheet

Parameters

  • custom IObjectArrayPrimitiveType<CustomData>No description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

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

setRowCustomMetadata

Set custom metadata of row

Signature

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

Parameters

  • index numberNo description
  • custom CustomDataNo description

Returns

  • FWorksheet — Current worksheet, for chaining.

Examples

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

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

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

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

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

Parameters

  • rowPosition numberNo description
  • height numberNo description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();
// Set the height of the second row to 30 pixels
fWorksheet.setRowHeight(1, 30);
// Set the height of the first row to 20 pixels
fWorksheet.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

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

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

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

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

setTabColor

Sets the sheet tab color.

Signature

setTabColor(color: string): FWorksheet

Parameters

  • color stringNo description

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining

Examples

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

showColumns

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

Signature

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

Parameters

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

Returns

  • FWorksheet — This sheet, for chaining

Examples

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

showRows

Scrolling sheet to make specific rows visible.

Signature

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

Parameters

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

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

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

unhideColumn(column: FRange): FWorksheet

Parameters

  • column FRangeNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

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

unhideRow

Make the row in the given range visible.

Signature

unhideRow(row: FRange): FWorksheet

Parameters

  • row FRangeNo description

Returns

  • FWorksheet — This sheet, for chaining.

Examples

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

hideSheet(): FWorksheet

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining

Examples

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

showSheet

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

Signature

showSheet(): FWorksheet

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining

Examples

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

Charts & Drawings

connectShapes

Signature

async connectShapes(connectParams: IConnectShapesParams): Promise<boolean>

Parameters

  • connectParams IConnectShapesParamsNo description

Returns

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

deleteImages

Signature

deleteImages(sheetImages: FOverGridImage[]): FWorksheet

Parameters

  • sheetImages FOverGridImage[]No description

Returns

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

getActiveImages

Signature

getActiveImages(): FOverGridImage[]

Returns

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

getCharts

Signature

getCharts(): FChart[]

Returns

  • FChart[] — See signature above.
Source: @univerjs-pro/sheets-chart

getImageById

Signature

getImageById(id: string): FOverGridImage | null

Parameters

  • id stringNo description

Returns

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

getImages

Signature

getImages(): FOverGridImage[]

Returns

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

getShapes

Signature

getShapes(): FShape[]

Returns

  • FShape[] — See signature above.
Source: @univerjs-pro/sheets-shape

insertChart

Signature

async insertChart(chartBuildInfo: IChartBuilderInfo): Promise<FChart>

Parameters

  • chartBuildInfo IChartBuilderInfoNo description

Returns

  • Promise<FChart> — See signature above.
Source: @univerjs-pro/sheets-chart

insertImage

Signature

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

insertImages(sheetImages: ISheetImage[]): FWorksheet

Parameters

  • sheetImages ISheetImage[]No description

Returns

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

insertShape

Signature

async insertShape(shapeBuilderInfo: IShapeBuilderInfo): Promise<boolean>

Parameters

  • shapeBuilderInfo IShapeBuilderInfoNo description

Returns

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

newChart

Signature

newChart(fChart?: FChart): FChartBuilderBase

Parameters

  • fChart FChart (optional)No description

Returns

  • FChartBuilderBase — See signature above.
Source: @univerjs-pro/sheets-chart

newOverGridImage

Signature

newOverGridImage(): FOverGridImageBuilder

Returns

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

newShape

Signature

newShape(existingShape?: FShape): FShape

Parameters

  • existingShape FShape (optional)No description

Returns

  • FShape — See signature above.
Source: @univerjs-pro/sheets-shape

registerChartTheme

Signature

registerChartTheme(themeName: string, theme: IEchartTheme): void

Parameters

  • themeName stringNo description
  • theme IEchartThemeNo description
Source: @univerjs-pro/sheets-chart

removeChart

Signature

removeChart(chart: FChart): Promise<boolean>

Parameters

  • chart FChartNo description

Returns

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

removeShape

Signature

removeShape(shape: FShape): Promise<boolean>

Parameters

  • shape FShapeNo description

Returns

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

saveCellImagesAsync

Signature

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

updateChart

Signature

updateChart(chartBuilder: IChartBuilderInfo): void

Parameters

  • chartBuilder IChartBuilderInfoNo description
Source: @univerjs-pro/sheets-chart

updateImages

Signature

updateImages(sheetImages: ISheetImage[]): FWorksheet

Parameters

  • sheetImages ISheetImage[]No description

Returns

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

updateShape

Signature

async updateShape(shapeBuilderInfo: IShapeBuilderInfo): Promise<boolean>

Parameters

  • shapeBuilderInfo IShapeBuilderInfoNo description

Returns

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

Filter & Sort

getFilter

Signature

getFilter(): FFilter | null

Returns

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

resetFilter

Signature

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

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

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

activate(): FWorksheet

Returns

  • FWorksheet — Current sheet, for chaining.

Examples

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

addConditionalFormattingRule

Signature

addConditionalFormattingRule(rule: IConditionFormattingRule): FWorksheet

Parameters

  • rule IConditionFormattingRuleNo description

Returns

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

addFloatDomToPosition

Signature

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

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

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

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

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

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

cancelFreeze(): FWorksheet

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

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

clear

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

Signature

clear(options?: IFacadeClearOptions): FWorksheet

Parameters

  • options IFacadeClearOptions (optional)No description

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining

Examples

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

clearConditionalFormatRules

Signature

clearConditionalFormatRules(): FWorksheet

Returns

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

clearContents

Clears the sheet of contents, while preserving formatting information.

Signature

clearContents(): FWorksheet

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining

Examples

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

clearFormats

Clears the sheet of formatting, while preserving contents.

Signature

clearFormats(): FWorksheet

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining

Examples

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

composeSparkline

Signature

composeSparkline(ranges: IRange[]): void

Parameters

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

createConditionalFormattingRule

Signature

createConditionalFormattingRule(): FConditionalFormattingBuilder

Returns

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

deleteConditionalFormattingRule

Signature

deleteConditionalFormattingRule(cfId: string): FWorksheet

Parameters

  • cfId stringNo description

Returns

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

dispose

Signature

dispose(): void
Source: @univerjs/sheets

equalTo

Judge whether provided FWorksheet is equal to current.

Signature

equalTo(other: FWorksheet): boolean

Parameters

  • other FWorksheetNo description

Returns

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

Examples

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

getActiveCell(): FRange | null

Returns

  • FRange — The active cell

Examples

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

getAllDataValidationErrorAsync

Signature

async getAllDataValidationErrorAsync(): Promise<IDataValidationError[]>

Returns

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

getAllFloatDoms

Signature

getAllFloatDoms(): IFCanvasFloatDomResult[]

Returns

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

getAllSubSparkline

Signature

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

Returns

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

getConditionalFormattingRules

Signature

getConditionalFormattingRules(): IConditionFormattingRule[]

Returns

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

getCustomMetadata

Get custom metadata of worksheet

Signature

getCustomMetadata(): CustomData | undefined

Returns

  • CustomData — custom metadata

Examples

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

getDataRange(): FRange

Returns

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

Examples

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

getDataValidation

Signature

getDataValidation(ruleId: string): Nullable<FDataValidation>

Parameters

  • ruleId stringNo description

Returns

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

getDataValidations

Signature

getDataValidations(): FDataValidation[]

Returns

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

getDefaultStyle

Get the default style of the worksheet.

Signature

getDefaultStyle(): Nullable<IStyleData> | string

Returns

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

Examples

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

getDefinedNames(): FDefinedName[]

Returns

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

Examples

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

getFloatDomById

Signature

getFloatDomById(id: string): Nullable<IFCanvasFloatDomResult>

Parameters

  • id stringNo description

Returns

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

getFormulaUsages

Signature

async getFormulaUsages(): Promise<IFormulaUsage[]>

Returns

  • Promise<IFormulaUsage[]> — See signature above.
Source: @univerjs-labs/sheets-mcp

getFormulaUsagesAsA1

Signature

async getFormulaUsagesAsA1(): Promise<IFormulaUsageAsA1[]>

Returns

  • Promise<IFormulaUsageAsA1[]> — See signature above.
Source: @univerjs-labs/sheets-mcp

getFreeze

Get the freeze state of the current sheet.

Signature

getFreeze(): IFreeze

Returns

  • IFreeze — The freeze state of the current sheet

Examples

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

getIndex

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

Signature

getIndex(): number

Returns

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

Examples

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

getInject

Get the injector instance.

Signature

getInject(): Injector

Returns

  • Injector — The injector instance.

Examples

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

getMergeData(): FRange[]

Returns

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

Examples

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

getMergedRanges

Get all merged cells in the current sheet

Signature

getMergedRanges(): FRange[]

Returns

  • FRange[] — all merged cells

Examples

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

getPivotTableByCell

Signature

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

Parameters

  • row numberNo description
  • col numberNo description

Returns

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

getScreenshotOnNode

Signature

async getScreenshotOnNode(options?: INodeWorksheetScreenshotOptions): Promise<string | false>

Parameters

  • options INodeWorksheetScreenshotOptions (optional)No description

Returns

  • Promise<string | false> — See signature above.
Source: @univerjs-labs/sheets-node-screenshot

getScrollState

Signature

getScrollState(): IScrollState

Returns

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

getSheet

Get the worksheet instance.

Signature

getSheet(): Worksheet

Returns

  • Worksheet — The worksheet instance.

Examples

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

getSheetId

Get the worksheet id.

Signature

getSheetId(): string

Returns

  • string — The id of the worksheet.

Examples

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

getSheetName

Get the worksheet name.

Signature

getSheetName(): string

Returns

  • string — The name of the worksheet.

Examples

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

getSizeUsages

Signature

getSizeUsages(options?: IGetSizeUsagesOptions): ISizeUsageGrouped

Parameters

  • options IGetSizeUsagesOptions (optional)No description

Returns

  • ISizeUsageGrouped — See signature above.
Source: @univerjs-labs/sheets-mcp

getSizeUsagesAsA1

Signature

getSizeUsagesAsA1(options?: IGetSizeUsagesOptions): ISizeUsageGroupedAsA1

Parameters

  • options IGetSizeUsagesOptions (optional)No description

Returns

  • ISizeUsageGroupedAsA1 — See signature above.
Source: @univerjs-labs/sheets-mcp

getSkeleton

Signature

getSkeleton(): Nullable<SpreadsheetSkeleton>

Returns

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

getSparklineByCell

Signature

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

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

Parameters

  • row numberNo description
  • col numberNo description

Returns

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

getStyleUsages

Signature

getStyleUsages(options?: IGetStyleUsagesOptions): IStyleUsage[]

Parameters

  • options IGetStyleUsagesOptions (optional)No description

Returns

  • IStyleUsage[] — See signature above.
Source: @univerjs-labs/sheets-mcp

getStyleUsagesAsA1

Signature

getStyleUsagesAsA1(options?: IGetStyleUsagesOptions): IStyleUsageAsA1[]

Parameters

  • options IGetStyleUsagesOptions (optional)No description

Returns

  • IStyleUsageAsA1[] — See signature above.
Source: @univerjs-labs/sheets-mcp

getSubTableInfos

Signature

getSubTableInfos(): ITableInfoWithUnitId[]

Returns

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

getTableByCell

Signature

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

Parameters

  • row numberNo description
  • column numberNo description

Returns

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

getUrl

Signature

getUrl(): string

Returns

  • string — See signature above.
Source: @univerjs/sheets-hyper-link

getValidatorStatus

Signature

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

Returns

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

getValidatorStatusAsync

Signature

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

Returns

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

getVisibleRange

Signature

getVisibleRange(): IRange | null

Returns

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

getVisibleRangesOfAllViewports

Signature

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

getWorkbook(): Workbook

Returns

  • Workbook — The workbook instance.

Examples

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

getWorksheetPermission(): FWorksheetPermission

Returns

  • FWorksheetPermission — - The WorksheetPermission instance.

Examples

const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();
const permission = fWorksheet.getWorksheetPermission();

// Set worksheet to read-only mode
await permission.setMode('readOnly');

// Check if a specific cell can be edited
const canEdit = permission.canEditCell(0, 0);

// Protect multiple ranges at once
const range1 = fWorksheet.getRange('A1:B10');
const range2 = fWorksheet.getRange('D1:E10');
await permission.protectRanges([
  { ranges: [range1], options: { name: 'Range 1', allowEdit: false } },
  { ranges: [range2], options: { name: 'Range 2', allowEdit: false } }
]);

// Subscribe to permission changes
permission.permission$.subscribe(snapshot => {
  console.log('Worksheet permissions changed:', snapshot);
});
Source: @univerjs/sheets

getZoom

Signature

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

hasHiddenGridLines(): boolean

Returns

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

Examples

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

highlightRanges

Signature

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

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

Parameters

  • name stringNo description
  • formulaOrRefString stringNo description

Examples

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

isSheetHidden

Returns true if the sheet is currently hidden.

Signature

isSheetHidden(): boolean

Returns

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

Examples

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

moveConditionalFormattingRule

Signature

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

newConditionalFormattingRule(): FConditionalFormattingBuilder

Returns

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

newConnector

Signature

newConnector(existingShape?: FShape): FConnectorShape

Parameters

  • existingShape FShape (optional)No description

Returns

  • FConnectorShape — See signature above.
Source: @univerjs-pro/sheets-shape

onBeforeCellDataChange

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

Signature

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

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

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

Parameters

  • callback (params: any) => voidNo description

Returns

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

refreshCanvas

Signature

refreshCanvas(): FWorksheet

Returns

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

removeFloatDom

Signature

removeFloatDom(id: string): this

Parameters

  • id stringNo description

Returns

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

removeTable

Signature

removeTable(tableId: string): Promise<boolean>

Parameters

  • tableId stringNo description

Returns

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

scrollToCell

Signature

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

setActiveRange(range: FRange): FWorksheet

Parameters

  • range FRangeNo description

Returns

  • FWorksheet — This sheet, for chaining

Examples

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

setActiveSelection

Sets the active selection region for this sheet.

Signature

setActiveSelection: (range: FRange) => FWorksheet

Returns

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

Examples

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

setConditionalFormattingRule

Signature

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

setCustomMetadata(custom: CustomData | undefined): FWorksheet

Parameters

  • custom CustomDataNo description

Returns

  • FWorksheet — Current worksheet, for chaining.

Examples

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

setDefaultStyle

Set the default style of the worksheet

Signature

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

Parameters

  • style string | Nullable<IStyleData>No description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

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

setFreeze(freeze: IFreeze): FWorksheet

Parameters

  • freeze IFreezeNo description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

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

setHiddenGridlines

Hides or reveals the sheet gridlines.

Signature

setHiddenGridlines(hidden: boolean): FWorksheet

Parameters

  • hidden booleanNo description

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining

Examples

 ts
const fWorkSheet = univerAPI.getActiveWorkbook().getActiveSheet();
// hide the gridlines
fWorkSheet.setHiddenGridlines(true);
Source: @univerjs/sheets

setName

Sets the sheet name.

Signature

setName(name: string): FWorksheet

Parameters

  • name stringNo description

Returns

  • FWorksheet — Returns the current worksheet instance for method chaining

Examples

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

setRangesAutoHeight(ranges: IRange[]): FWorksheet

Parameters

  • ranges IRange[]No description

Returns

  • FWorksheet — This worksheet instance for chaining

Examples

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

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

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

unComposeSparkline(ranges: IRange[]): void

Parameters

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

updateFloatDom

Signature

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

zoom(zoomRatio: number): FWorksheet

Parameters

  • zoomRatio numberNo description

Returns

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

Comments & Notes

clearComments

Signature

clearComments(): Promise<boolean>

Returns

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

getCommentById

Signature

getCommentById(commentId: string): FThreadComment | undefined

Parameters

  • commentId stringNo description

Returns

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

getComments

Signature

getComments(): FThreadComment[]

Returns

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

getNotes

Signature

getNotes(): ISheetNote[]

Returns

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

onCommented

Subscribe to comment events.

Signature

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

Parameters

  • callback (params: IAddCommentCommandParams) => voidNo description

Returns

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

Table of Contents

Overview
@univerjs/sheets
@univerjs/sheets-conditional-formatting
@univerjs/sheets-data-validation
@univerjs/sheets-drawing
@univerjs/sheets-drawing-ui
@univerjs/sheets-filter
@univerjs/sheets-hyper-link
@univerjs/sheets-note
@univerjs/sheets-sort
@univerjs/sheets-table
@univerjs/sheets-thread-comment
@univerjs/sheets-ui
@univerjs-pro/sheets-chart
@univerjs-pro/sheets-pivot
@univerjs-pro/sheets-shape
@univerjs-pro/sheets-sparkline
@univerjs-labs/sheets-mcp
@univerjs-labs/sheets-node-screenshot
APIs
Range & Selection
getActiveRange
getRange
getSelection
Cell Data
getCellMergeData
Row & Column
addFloatDomToColumnHeader
appendRow
autoFitRow
autoResizeColumn
autoResizeColumns
autoResizeRows
customizeColumnHeader
customizeRowHeader
deleteColumn
deleteColumns
deleteColumnsByPoints
deleteRow
deleteRows
deleteRowsByPoints
getColumnCustomMetadata
getColumnDefaultStyle
getColumnWidth
getFrozenColumnRange
getFrozenColumns
getFrozenRowRange
getFrozenRows
getGridLinesColor
getLastColumn
getLastColumns
getLastRow
getLastRows
getMaxColumns
getMaxRows
getRowCustomMetadata
getRowDefaultStyle
getRowHeight
getTabColor
hideColumn
hideColumns
hideRow
hideRows
insertColumnAfter
insertColumnBefore
insertColumns
insertColumnsAfter
insertColumnsBefore
insertRowAfter
insertRowBefore
insertRows
insertRowsAfter
insertRowsBefore
moveColumns
moveRows
setColumnAutoWidth
setColumnCount
setColumnCustom
setColumnCustomMetadata
setColumnDefaultStyle
setColumnHeaderHeight
setColumnWidth
setColumnWidths
setFrozenColumns
setFrozenRows
setGridLinesColor
setRowAutoHeight
setRowCount
setRowCustom
setRowCustomMetadata
setRowDefaultStyle
setRowHeaderWidth
setRowHeight
setRowHeights
setRowHeightsForced
setTabColor
showColumns
showRows
unhideColumn
unhideRow
Visibility & Protection
hideSheet
showSheet
Charts & Drawings
connectShapes
deleteImages
getActiveImages
getCharts
getImageById
getImages
getShapes
insertChart
insertImage
insertImages
insertShape
newChart
newOverGridImage
newShape
registerChartTheme
removeChart
removeShape
saveCellImagesAsync
updateChart
updateImages
updateShape
Filter & Sort
getFilter
resetFilter
setTableFilter
sort
Miscellaneous
activate
addConditionalFormattingRule
addFloatDomToPosition
addFloatDomToRange
addSparkline
addTable
addTableTheme
batchUpdateFloatDoms
cancelFreeze
clear
clearConditionalFormatRules
clearContents
clearFormats
composeSparkline
createConditionalFormattingRule
deleteConditionalFormattingRule
dispose
equalTo
getActiveCell
getAllDataValidationErrorAsync
getAllFloatDoms
getAllSubSparkline
getConditionalFormattingRules
getCustomMetadata
getDataRange
getDataValidation
getDataValidations
getDefaultStyle
getDefinedNames
getFloatDomById
getFormulaUsages
getFormulaUsagesAsA1
getFreeze
getIndex
getInject
getMergeData
getMergedRanges
getPivotTableByCell
getScreenshotOnNode
getScrollState
getSheet
getSheetId
getSheetName
getSizeUsages
getSizeUsagesAsA1
getSkeleton
getSparklineByCell
getSparklineGroupByCell
getStyleUsages
getStyleUsagesAsA1
getSubTableInfos
getTableByCell
getUrl
getValidatorStatus
getValidatorStatusAsync
getVisibleRange
getVisibleRangesOfAllViewports
getWorkbook
getWorksheetPermission
getZoom
hasHiddenGridLines
highlightRanges
insertDefinedName
isSheetHidden
moveConditionalFormattingRule
newConditionalFormattingRule
newConnector
onBeforeCellDataChange
onCellDataChange
onScroll
refreshCanvas
removeFloatDom
removeTable
scrollToCell
setActiveRange
setActiveSelection
setConditionalFormattingRule
setCustomMetadata
setDefaultStyle
setFreeze
setHiddenGridlines
setName
setRangesAutoHeight
setTableName
setTableRange
unComposeSparkline
updateFloatDom
zoom
Comments & Notes
clearComments
getCommentById
getComments
getNotes
onCommented
Capalyze