@univerjs/sheets-sort v0.5.4


Class: FWorksheetSort

Defined in: sheets-sort/src/facade/f-worksheet.ts:40

Represents a worksheet facade api instance. Which provides a set of methods to interact with the worksheet.

Extends

Implements

Constructors

new FWorksheetSort()

new FWorksheetSort(
   _fWorkbook, 
   _workbook, 
   _worksheet, 
   _injector, 
   _selectionManagerService, 
   _logService, 
   _commandService): FWorksheetSort

Defined in: sheets/src/facade/f-worksheet.ts:38

Parameters

ParameterType
_fWorkbookFWorkbook
_workbookWorkbook
_worksheetWorksheet
_injectorInjector
_selectionManagerServiceSheetsSelectionsService
_logServiceILogService
_commandServiceICommandService

Returns

FWorksheetSort

Inherited from

FWorksheet.constructor

Properties

PropertyModifierTypeDefault valueDescriptionInherited fromDefined in
_commandServicereadonlyICommandServiceundefined-FWorksheet._commandServicesheets/src/facade/f-worksheet.ts:45
_disposedprotectedbooleanfalse-FWorksheet._disposedcore/src/shared/lifecycle.ts:96
_fWorkbookreadonlyFWorkbookundefined-FWorksheet._fWorkbooksheets/src/facade/f-worksheet.ts:39
_injectorreadonlyInjectorundefined-FWorksheet._injectorsheets/src/facade/f-worksheet.ts:42
_logServicereadonlyILogServiceundefined-FWorksheet._logServicesheets/src/facade/f-worksheet.ts:44
_selectionManagerServicereadonlySheetsSelectionsServiceundefined-FWorksheet._selectionManagerServicesheets/src/facade/f-worksheet.ts:43
_workbookreadonlyWorkbookundefined-FWorksheet._workbooksheets/src/facade/f-worksheet.ts:40
_worksheetreadonlyWorksheetundefined-FWorksheet._worksheetsheets/src/facade/f-worksheet.ts:41
setActiveSelectionpublic(range: FRange) => FWorksheetundefinedSets the active selection region for this sheet. Param The range to set as the active selection.FWorksheet.setActiveSelectionsheets/src/facade/f-worksheet.ts:1076

Methods

_initialize()

_initialize(injector): void

Defined in: core/src/facade/f-base.ts:66

Parameters

ParameterType
injectorInjector

Returns

void

Inherited from

FWorksheet._initialize


activate()

activate(): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1509

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

Returns

FWorksheet

Current sheet, for chaining.

Inherited from

FWorksheet.activate


addEvent()

addEvent(event, callback): IDisposable

Defined in: sheets/src/facade/f-worksheet.ts:76

Add an event listener

Parameters

ParameterTypeDescription
eventkeyof IEventParamConfigkey of event
callback(params) => voidcallback when event triggered

Returns

IDisposable

The Disposable instance, for remove the listener

Example

univerAPI.addEvent(univerAPI.event.UnitCreated, (params) => {
    console.log('unit created', params);
});

Inherited from

FWorksheet.addEvent


cancelFreeze()

cancelFreeze(): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1100

Cancels the frozen state of the current sheet.

Returns

FWorksheet

True if the command was successful, false otherwise.

Inherited from

FWorksheet.cancelFreeze


clear()

clear(options?): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1546

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

Parameters

ParameterTypeDescription
options?IFacadeClearOptionsOptions for clearing the sheet. If not provided, the contents and formatting are cleared both.

Returns

FWorksheet

Returns the current worksheet instance for method chaining

Example

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 });

Inherited from

FWorksheet.clear


clearContents()

clearContents(): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1586

Clears the sheet of contents, while preserving formatting information.

Returns

FWorksheet

Returns the current worksheet instance for method chaining

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
// clear the sheet of content only
fWorkSheet.clearContents();

Inherited from

FWorksheet.clearContents


clearFormats()

clearFormats(): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1617

Clears the sheet of formatting, while preserving contents.

Returns

FWorksheet

Returns the current worksheet instance for method chaining

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
// clear the sheet of formatting only
fWorkSheet.clearFormats();

Inherited from

FWorksheet.clearFormats


deleteColumn()

deleteColumn(columnPosition): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:807

Deletes the column at the given column position.

Parameters

ParameterTypeDescription
columnPositionnumberThe position of the column, starting at 0 for the first column.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.deleteColumn


deleteColumns()

deleteColumns(columnPosition, howMany): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:817

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

Parameters

ParameterTypeDescription
columnPositionnumberThe position of the first column to delete, starting at 0 for the first column.
howManynumberThe number of columns to delete.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.deleteColumns


deleteRow()

deleteRow(rowPosition): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:436

Deletes the row at the given row position.

Parameters

ParameterTypeDescription
rowPositionnumberThe position of the row, starting at 0 for the first row.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.deleteRow


deleteRows()

deleteRows(rowPosition, howMany): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:446

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

Parameters

ParameterTypeDescription
rowPositionnumberThe position of the first row to delete, starting at 0 for the first row.
howManynumberThe number of rows to delete.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.deleteRows


dispose()

dispose(): void

Defined in: core/src/shared/lifecycle.ts:109

Returns

void

Inherited from

FWorksheet.dispose


disposeWithMe()

disposeWithMe(disposable): IDisposable

Defined in: core/src/shared/lifecycle.ts:99

Parameters

ParameterType
disposableDisposableLike

Returns

IDisposable

Inherited from

FWorksheet.disposeWithMe


ensureNotDisposed()

protected ensureNotDisposed(): void

Defined in: core/src/shared/lifecycle.ts:103

Returns

void

Inherited from

FWorksheet.ensureNotDisposed


equalTo()

equalTo(other): boolean

Defined in: sheets/src/facade/f-worksheet.ts:1732

Judge whether provided FWorksheet is equal to current.

Parameters

ParameterTypeDescription
otherFWorksheetthe FWorksheet to compare with.

Returns

boolean

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

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
const fWorkSheet2 = fWorkbook.getSheetByName('Sheet1');
console.log(fWorkSheet.equals(fWorkSheet2)); // true, if the active sheet is 'Sheet1'

Inherited from

FWorksheet.equalTo


fireEvent()

protected fireEvent<T>(event, params): undefined | boolean

Defined in: sheets/src/facade/f-worksheet.ts:91

Fire an event, used in internal only.

Type Parameters

Type Parameter
T extends keyof IEventParamConfig

Parameters

ParameterTypeDescription
eventT{string} key of event
paramsIEventParamConfig[T]{any} params of event

Returns

undefined | boolean

should cancel

Example

this.fireEvent(univerAPI.event.UnitCreated, params);

Inherited from

FWorksheet.fireEvent


getActiveRange()

getActiveRange(): null | FRange

Defined in: sheets/src/facade/f-worksheet.ts:1052

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

Returns

null | FRange

the active range

Inherited from

FWorksheet.getActiveRange


getCellMergeData()

getCellMergeData(row, column): undefined | FRange

Defined in: sheets/src/facade/f-worksheet.ts:1038

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

Parameters

ParameterTypeDescription
rownumberThe row index.
columnnumberThe column index.

Returns

undefined | FRange

The merged cell data, or undefined if the cell is not merged.

Inherited from

FWorksheet.getCellMergeData


getColumnCustomMetadata()

getColumnCustomMetadata(index): CustomData

Defined in: sheets/src/facade/f-worksheet.ts:1847

Get custom metadata of column

Parameters

ParameterTypeDescription
indexnumbercolumn index

Returns

CustomData

custom metadata

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
const custom = fWorkSheet.getColumnCustomMetadata(0);

Inherited from

FWorksheet.getColumnCustomMetadata


getColumnDefaultStyle()

getColumnDefaultStyle(index, keepRaw?): 
  | string
| Nullable<IStyleData>

Defined in: sheets/src/facade/f-worksheet.ts:172

Get the default style of the worksheet column

Parameters

ParameterTypeDefault valueDescription
indexnumberundefinedThe column index
keepRaw?booleanfalseIf true, return the raw style data maybe the style name or style data, otherwise return the data from col manager

Returns

| string | Nullable<IStyleData>

The default style of the worksheet column name or style data

Inherited from

FWorksheet.getColumnDefaultStyle


getDataRange()

getDataRange(): FRange

Defined in: sheets/src/facade/f-worksheet.ts:1652

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.getLastColumns(), Sheet.getLastRows()).

Returns

FRange

The range of the data in the sheet.

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
// the sheet is a empty sheet
const cellRange = fWorkSheet.getRange(200, 10, 1, 1);
cellRange.setValue('Hello World');
console.log(fWorkSheet.getDataRange().getA1Notation()); // A1:J200

Inherited from

FWorksheet.getDataRange


getDefaultStyle()

getDefaultStyle(): 
  | string
| Nullable<IStyleData>

Defined in: sheets/src/facade/f-worksheet.ts:152

Get the default style of the worksheet

Returns

| string | Nullable<IStyleData>

Default style of the worksheet.

Inherited from

FWorksheet.getDefaultStyle


getDefinedNames()

getDefinedNames(): FDefinedName[]

Defined in: sheets/src/facade/f-worksheet.ts:1769

Get all the defined names in the worksheet.

Returns

FDefinedName[]

All the defined names in the worksheet

Example

// The code below gets all the defined names in the worksheet
const activeSpreadsheet = univerAPI.getActiveWorkbook();
const sheet1 = activeSpreadsheet.getSheetByName('Sheet1');
const definedNames = sheet1.getDefinedNames();

Inherited from

FWorksheet.getDefinedNames


getFreeze()

getFreeze(): IFreeze

Defined in: sheets/src/facade/f-worksheet.ts:1114

Get the freeze state of the current sheet.

Returns

IFreeze

The freeze state of the current sheet.

Deprecated

use getRowFreezeStatus and getColumnFreezeStatus instead.

Inherited from

FWorksheet.getFreeze


getFrozenColumnRange()

getFrozenColumnRange(): IColumnRange

Defined in: sheets/src/facade/f-worksheet.ts:1255

Get freezed columns

Returns

IColumnRange

The range of the frozen columns.

Inherited from

FWorksheet.getFrozenColumnRange


getFrozenColumns()

getFrozenColumns(): number

Defined in: sheets/src/facade/f-worksheet.ts:1219

Get the number of frozen columns.

Returns

number

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

Inherited from

FWorksheet.getFrozenColumns


getFrozenRowRange()

getFrozenRowRange(): IRowRange

Defined in: sheets/src/facade/f-worksheet.ts:1243

Get freezed rows.

Returns

IRowRange

The range of the frozen rows.

Inherited from

FWorksheet.getFrozenRowRange


getFrozenRows()

getFrozenRows(): number

Defined in: sheets/src/facade/f-worksheet.ts:1231

Get the number of frozen rows.

Returns

number

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

Inherited from

FWorksheet.getFrozenRows


getGridLinesColor()

getGridLinesColor(): undefined | string

Defined in: sheets/src/facade/f-worksheet.ts:1326

Get the color of the gridlines in the sheet.

Returns

undefined | string

The color of the gridlines in the sheet or undefined. The default color is ‘rgb(214, 216, 219)’.

Inherited from

FWorksheet.getGridLinesColor


getIndex()

getIndex(): number

Defined in: sheets/src/facade/f-worksheet.ts:1526

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

Returns

number

The position of the sheet in its parent spreadsheet.

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
// get the position of the active sheet
const position = fWorkSheet.getIndex();
console.log(position); // 0

Inherited from

FWorksheet.getIndex


getInject()

getInject(): Injector

Defined in: sheets/src/facade/f-worksheet.ts:103

Returns the injector

Returns

Injector

The injector

Inherited from

FWorksheet.getInject


getLastColumn()

getLastColumn(): number

Defined in: sheets/src/facade/f-worksheet.ts:1685

Returns

number

the last column of the sheet that contains content.

Deprecated

use getLastColumn instead. Returns the position of the last column that has content. Same as getLastColumns.

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
const fRange = fWorkSheet.getRange(100, 20, 1, 1);
console.log(fWorkSheet.getLastColumn());

Inherited from

FWorksheet.getLastColumn


getLastColumns()

getLastColumns(): number

Defined in: sheets/src/facade/f-worksheet.ts:1669

Returns the position of the last column that has content.

Returns

number

the last column of the sheet that contains content.

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
const fRange = fWorkSheet.getRange(100, 20, 1, 1);
console.log(fWorkSheet.getLastColumns()); // 20

Inherited from

FWorksheet.getLastColumns


getLastRow()

getLastRow(): number

Defined in: sheets/src/facade/f-worksheet.ts:1716

Returns the position of the last row that has content, same as getLastRows().

Returns

number

the last row of the sheet that contains content.

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
const fRange = fWorkSheet.getRange(100,1,1,1);
fRange.setValue('Hello World');
console.log(fWorkSheet.getLastRow());
 
#### Inherited from
 
[`FWorksheet`](../../../sheets/facade/classes/FWorksheet.md).[`getLastRow`](../../../sheets/facade/classes/FWorksheet.md#getlastrow)
 
***
 
### ~~getLastRows()~~
 
```ts
getLastRows(): number

Defined in: sheets/src/facade/f-worksheet.ts:1701

Returns

number

the last row of the sheet that contains content.

Deprecated

use getLastRow instead. Returns the position of the last row that has content.

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
const fRange = fWorkSheet.getRange(100,1,1,1);
fRange.setValue('Hello World');
console.log(fWorkSheet.getLastRows()); // 100
 
#### Inherited from
 
[`FWorksheet`](../../../sheets/facade/classes/FWorksheet.md).[`getLastRows`](../../../sheets/facade/classes/FWorksheet.md#getlastrows)
 
***
 
### getMaxColumns()
 
```ts
getMaxColumns(): number

Defined in: sheets/src/facade/f-worksheet.ts:321

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

Returns

number

The maximum columns count of the sheet

Inherited from

FWorksheet.getMaxColumns


getMaxRows()

getMaxRows(): number

Defined in: sheets/src/facade/f-worksheet.ts:329

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

Returns

number

The maximum rows count of the sheet

Inherited from

FWorksheet.getMaxRows


getMergeData()

getMergeData(): FRange[]

Defined in: sheets/src/facade/f-worksheet.ts:1866

Get all merged cells in the current worksheet

Returns

FRange[]

All the merged cells in the worksheet

Example

const workbook = univerAPI.getActiveWorkbook();
const worksheet = workbook.getActiveSheet();
const rangeFirst = worksheet.getRange(0, 0, 2, 2);
const mergeFirst = rangeFirst.merge();
const rangeSecond = worksheet.getRange(5, 0, 2, 2);
const mergeSecond = rangeSecond.merge();
const mergeData = worksheet.getMergeData();
console.log('debugger', mergeData);

Inherited from

FWorksheet.getMergeData


getMergedRanges()

getMergedRanges(): FRange[]

Defined in: sheets/src/facade/f-worksheet.ts:1027

Get all merged cells in the current sheet

Returns

FRange[]

all merged cells

Inherited from

FWorksheet.getMergedRanges


getRange()

Call Signature

getRange(row, column): FRange

Defined in: sheets/src/facade/f-worksheet.ts:249

Returns a Range object representing a single cell at the specified row and column.

Parameters
ParameterTypeDescription
rownumberThe row index of the cell.
columnnumberThe column index of the cell.
Returns

FRange

A Range object representing the specified cell.

Inherited from

FWorksheet.getRange

Call Signature

getRange(
   row, 
   column, 
   numRows): FRange

Defined in: sheets/src/facade/f-worksheet.ts:257

Returns a Range object representing a range starting at the specified row and column, with the specified number of rows.

Parameters
ParameterTypeDescription
rownumberThe starting row index of the range.
columnnumberThe starting column index of the range.
numRowsnumberThe number of rows in the range.
Returns

FRange

A Range object representing the specified range.

Inherited from

FWorksheet.getRange

Call Signature

getRange(
   row, 
   column, 
   numRows, 
   numColumns): FRange

Defined in: sheets/src/facade/f-worksheet.ts:266

Returns a Range object representing a range starting at the specified row and column, with the specified number of rows and columns.

Parameters
ParameterTypeDescription
rownumberThe starting row index of the range.
columnnumberThe starting column index of the range.
numRowsnumberThe number of rows in the range.
numColumnsnumberThe number of columns in the range.
Returns

FRange

A Range object representing the specified range.

Inherited from

FWorksheet.getRange

Call Signature

getRange(a1Notation): FRange

Defined in: sheets/src/facade/f-worksheet.ts:272

Returns a Range object specified by A1 notation.

Parameters
ParameterTypeDescription
a1NotationstringA string representing a range in A1 notation.
Returns

FRange

A Range object representing the specified range.

Inherited from

FWorksheet.getRange


getRowCustomMetadata()

getRowCustomMetadata(index): CustomData

Defined in: sheets/src/facade/f-worksheet.ts:1832

Get custom metadata of row

Parameters

ParameterTypeDescription
indexnumberrow index

Returns

CustomData

custom metadata

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
const custom = fWorkSheet.getRowCustomMetadata(0);

Inherited from

FWorksheet.getRowCustomMetadata


getRowDefaultStyle()

getRowDefaultStyle(index, keepRaw?): 
  | string
| Nullable<IStyleData>

Defined in: sheets/src/facade/f-worksheet.ts:162

Get the default style of the worksheet row

Parameters

ParameterTypeDefault valueDescription
indexnumberundefinedThe row index
keepRaw?booleanfalseIf true, return the raw style data maybe the style name or style data, otherwise return the data from row manager

Returns

| string | Nullable<IStyleData>

The default style of the worksheet row name or style data

Inherited from

FWorksheet.getRowDefaultStyle


getSelection()

getSelection(): null | FSelection

Defined in: sheets/src/facade/f-worksheet.ts:135

Represents the selection ranges info of the worksheet.

Returns

null | FSelection

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

Inherited from

FWorksheet.getSelection


getSheet()

getSheet(): Worksheet

Defined in: sheets/src/facade/f-worksheet.ts:50

Returns

Worksheet

Inherited from

FWorksheet.getSheet


getSheetId()

getSheetId(): string

Defined in: sheets/src/facade/f-worksheet.ts:119

Returns the worksheet id.

Returns

string

The id of the worksheet.

Inherited from

FWorksheet.getSheetId


getSheetName()

getSheetName(): string

Defined in: sheets/src/facade/f-worksheet.ts:127

Returns the worksheet name.

Returns

string

The name of the worksheet.

Inherited from

FWorksheet.getSheetName


getTabColor()

getTabColor(): undefined | string

Defined in: sheets/src/facade/f-worksheet.ts:1363

Get the tab color of the sheet.

Returns

undefined | string

The tab color of the sheet or undefined. The default color is css style property ‘unset’.

Example

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

Inherited from

FWorksheet.getTabColor


getWorkbook()

getWorkbook(): Workbook

Defined in: sheets/src/facade/f-worksheet.ts:111

Returns the workbook

Returns

Workbook

The workbook instance.

Inherited from

FWorksheet.getWorkbook


hasHiddenGridLines()

hasHiddenGridLines(): boolean

Defined in: sheets/src/facade/f-worksheet.ts:1276

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

Returns

boolean

True if the sheet’s gridlines are hidden; otherwise false.

Example

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

Inherited from

FWorksheet.hasHiddenGridLines


hideColumn()

hideColumn(column): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:868

Hides the column or columns in the given range.

Parameters

ParameterTypeDescription
columnFRangeThe column range to hide.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.hideColumn


hideColumns()

hideColumns(columnIndex, numColumns): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:888

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

Parameters

ParameterTypeDefault valueDescription
columnIndexnumberundefinedThe starting index of the columns to hide.
numColumnsnumber1The number of columns to hide.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.hideColumns


hideRow()

hideRow(row): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:497

Hides the rows in the given range.

Parameters

ParameterTypeDescription
rowFRangeThe row range to hide.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.hideRow


hideRows()

hideRows(rowIndex, numRows): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:517

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

Parameters

ParameterTypeDefault valueDescription
rowIndexnumberundefinedThe starting index of the rows to hide.
numRowsnumber1The number of rows to hide.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.hideRows


hideSheet()

hideSheet(): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1438

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.

Returns

FWorksheet

Returns the current worksheet instance for method chaining

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
// hide the active sheet
fWorkSheet.hideSheet();

Inherited from

FWorksheet.hideSheet


insertColumnAfter()

insertColumnAfter(afterPosition): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:709

Inserts a column after the given column position.

Parameters

ParameterTypeDescription
afterPositionnumberThe column after which the new column should be added, starting at 0 for the first column.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.insertColumnAfter


insertColumnBefore()

insertColumnBefore(beforePosition): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:718

Inserts a column before the given column position.

Parameters

ParameterTypeDescription
beforePositionnumberThe column before which the new column should be added, starting at 0 for the first column.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.insertColumnBefore


insertColumns()

insertColumns(columnIndex, numColumns): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:728

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

Parameters

ParameterTypeDefault valueDescription
columnIndexnumberundefinedThe index indicating where to insert a column, starting at 0 for the first column.
numColumnsnumber1The number of columns to insert.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.insertColumns


insertColumnsAfter()

insertColumnsAfter(afterPosition, howMany): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:738

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

Parameters

ParameterTypeDescription
afterPositionnumberThe column after which the new column should be added, starting at 0 for the first column.
howManynumberThe number of columns to insert.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.insertColumnsAfter


insertColumnsBefore()

insertColumnsBefore(beforePosition, howMany): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:773

Inserts a number of columns before the given column position.

Parameters

ParameterTypeDescription
beforePositionnumberThe column before which the new column should be added, starting at 0 for the first column.
howManynumberThe number of columns to insert.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.insertColumnsBefore


insertDefinedName()

insertDefinedName(name, formulaOrRefString): void

Defined in: sheets/src/facade/f-worksheet.ts:1751

Parameters

ParameterType
namestring
formulaOrRefStringstring

Returns

void

Inherited from

FWorksheet.insertDefinedName


insertRowAfter()

insertRowAfter(afterPosition): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:338

Inserts a row after the given row position.

Parameters

ParameterTypeDescription
afterPositionnumberThe row after which the new row should be added, starting at 0 for the first row.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.insertRowAfter


insertRowBefore()

insertRowBefore(beforePosition): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:347

Inserts a row before the given row position.

Parameters

ParameterTypeDescription
beforePositionnumberThe row before which the new row should be added, starting at 0 for the first row.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.insertRowBefore


insertRows()

insertRows(rowIndex, numRows): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:357

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

Parameters

ParameterTypeDefault valueDescription
rowIndexnumberundefinedThe index indicating where to insert a row, starting at 0 for the first row.
numRowsnumber1The number of rows to insert.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.insertRows


insertRowsAfter()

insertRowsAfter(afterPosition, howMany): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:367

Inserts a number of rows after the given row position.

Parameters

ParameterTypeDescription
afterPositionnumberThe row after which the new rows should be added, starting at 0 for the first row.
howManynumberThe number of rows to insert.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.insertRowsAfter


insertRowsBefore()

insertRowsBefore(beforePosition, howMany): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:402

Inserts a number of rows before the given row position.

Parameters

ParameterTypeDescription
beforePositionnumberThe row before which the new rows should be added, starting at 0 for the first row.
howManynumberThe number of rows to insert.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.insertRowsBefore


isSheetHidden()

isSheetHidden(): boolean

Defined in: sheets/src/facade/f-worksheet.ts:1479

Returns true if the sheet is currently hidden.

Returns

boolean

True if the sheet is hidden; otherwise, false.

Inherited from

FWorksheet.isSheetHidden


moveColumns()

moveColumns(columnSpec, destinationIndex): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:840

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.

Parameters

ParameterTypeDescription
columnSpecFRangeA range spanning the columns that should be moved.
destinationIndexnumberThe index that the columns should be moved to. Note that this index is based on the coordinates before the columns are moved. Existing data is shifted right to make room for the moved columns while the source columns are removed from the grid. Therefore, the data may end up at a different index than originally specified. Use 0-index for this method.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.moveColumns


moveRows()

moveRows(rowSpec, destinationIndex): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:469

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.

Parameters

ParameterTypeDescription
rowSpecFRangeA range spanning the rows that should be moved.
destinationIndexnumberThe index that the rows should be moved to. Note that this index is based on the coordinates before the rows are moved. Existing data is shifted down to make room for the moved rows while the source rows are removed from the grid. Therefore, the data may end up at a different index than originally specified. Use 0-index for this method.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.moveRows


onBeforeCellDataChange()

onBeforeCellDataChange(callback): IDisposable

Defined in: sheets/src/facade/f-worksheet.ts:1415

Subscribe to the cell data change event.

Parameters

ParameterTypeDescription
callback(cellValue) => voidThe callback function to be executed before the cell data changes.

Returns

IDisposable

  • A disposable object to unsubscribe from the event.

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
// subscribe to the cell data change event
const disposable = fWorkSheet.onBeforeCellDataChange((cellValue) => {
  console.log(cellValue.toArray());
});
// unsubscribe from the event
disposable.dispose();

Inherited from

FWorksheet.onBeforeCellDataChange


onCellDataChange()

onCellDataChange(callback): IDisposable

Defined in: sheets/src/facade/f-worksheet.ts:1383

Subscribe to the cell data change event.

Parameters

ParameterTypeDescription
callback(cellValue) => voidThe callback function to be executed when the cell data changes.

Returns

IDisposable

  • A disposable object to unsubscribe from the event.

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
// subscribe to the cell data change event
const disposable = fWorkSheet.onCellDataChange((cellValue) => {
 console.log(cellValue.toArray());
});
// unsubscribe from the event
disposable.dispose();

Inherited from

FWorksheet.onCellDataChange


setActiveRange()

setActiveRange(range): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1061

Sets the active selection region for this sheet.

Parameters

ParameterTypeDescription
rangeFRangeThe range to set as the active selection.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.setActiveRange


setColumnCustom()

setColumnCustom(custom): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:999

Set custom properties for given columns.

Parameters

ParameterTypeDescription
customIObjectArrayPrimitiveType<CustomData>The custom properties to set.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.setColumnCustom


setColumnCustomMetadata()

setColumnCustomMetadata(index, custom): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1816

Set custom metadata of column

Parameters

ParameterTypeDescription
indexnumbercolumn index
customCustomDatacustom metadata

Returns

FWorksheet

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
fWorkSheet.setColumnCustomMetadata(0, { key: 'value' });

Inherited from

FWorksheet.setColumnCustomMetadata


setColumnDefaultStyle()

setColumnDefaultStyle(index, style): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:199

Set the default style of the worksheet row

Parameters

ParameterTypeDescription
indexnumberThe row index
style| string | Nullable<IStyleData>The style name or style data

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.setColumnDefaultStyle


setColumnWidth()

setColumnWidth(columnPosition, width): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:959

Sets the width of the given column in pixels.

Parameters

ParameterTypeDescription
columnPositionnumberThe position of the given column to set.
widthnumberThe width in pixels to set it to.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.setColumnWidth


setColumnWidths()

setColumnWidths(
   startColumn, 
   numColumns, 
   width): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:970

Sets the width of the given columns in pixels.

Parameters

ParameterTypeDescription
startColumnnumberThe starting column position to change.
numColumnsnumberThe number of columns to change.
widthnumberThe width in pixels to set it to.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.setColumnWidths


setCustomMetadata()

setCustomMetadata(custom): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1784

Set custom metadata of worksheet

Parameters

ParameterTypeDescription
customCustomDatacustom metadata

Returns

FWorksheet

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
fWorkSheet.setCustomMetadata({ key: 'value' });

Inherited from

FWorksheet.setCustomMetadata


setDefaultStyle()

setDefaultStyle(style): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:181

Set the default style of the worksheet

Parameters

ParameterTypeDescription
stylestringdefault style

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.setDefaultStyle


setFreeze()

setFreeze(freeze): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1085

Sets the frozen state of the current sheet.

Parameters

ParameterTypeDescription
freezeIFreezethe scrolling viewport start range and count of freezed rows and columns. that means if you want to freeze the first 3 rows and 2 columns, you should set freeze as { startRow: 3, startColumn: 2, xSplit: 2, ySplit: 3 }

Returns

FWorksheet

True if the command was successful, false otherwise.

Deprecated

use setFrozenRows and setFrozenColumns instead.

Inherited from

FWorksheet.setFreeze


setFrozenColumns()

Call Signature

setFrozenColumns(columns): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1123

Set the number of frozen columns.

Parameters
ParameterTypeDescription
columnsnumberThe number of columns to freeze. To unfreeze all columns, set this value to 0.
Returns

FWorksheet

Inherited from

FWorksheet.setFrozenColumns

Call Signature

setFrozenColumns(startColumn, endColumn): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1140

Set freeze column, then the range from startColumn to endColumn will be fixed. e.g. setFrozenColumns(0, 2) will fix the column range from 0 to 2. e.g. setFrozenColumns(2, 3) will fix the column range from 2 to 3, And column from 0 to 1 will be invisible.

Parameters
ParameterTypeDescription
startColumnnumberThe start column of the range to freeze.
endColumnnumberThe end column of the range to freeze.
Returns

FWorksheet

This FWorksheet instance.

Example
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
// freeze the first too columns.
fWorkSheet.setFrozenColumns(0, 2);
Inherited from

FWorksheet.setFrozenColumns


setFrozenRows()

Call Signature

setFrozenRows(rows): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1172

Set the number of frozen rows.

Parameters
ParameterTypeDescription
rowsnumberThe number of rows to freeze. To unfreeze all rows, set this value to 0.
Returns

FWorksheet

Inherited from

FWorksheet.setFrozenRows

Call Signature

setFrozenRows(startColumn, endColumn): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1188

Set freeze row, then the range from startRow to endRow will be fixed. e.g. setFrozenRows(0, 2) will fix the row range from 0 to 2. e.g. setFrozenRows(2, 3) will fix the row range from 2 to 3, And row from 0 to 1 will be invisible.

Parameters
ParameterType
startColumnnumber
endColumnnumber
Returns

FWorksheet

Example
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
// freeze the first too rows.
fWorkSheet.setFrozenRows(0, 2);
Inherited from

FWorksheet.setFrozenRows


setGridLinesColor()

setGridLinesColor(color): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1313

Set the color of the gridlines in the sheet.

Parameters

ParameterTypeDescription
colorundefined | stringThe color to set for the gridlines.Undefined or null to reset to the default color.

Returns

FWorksheet

Returns the current worksheet instance for method chaining

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
// set the gridlines color to red
fWorkSheet.setGridLinesColor('#ff0000');

Inherited from

FWorksheet.setGridLinesColor


setHiddenGridlines()

setHiddenGridlines(hidden): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1292

Hides or reveals the sheet gridlines.

Parameters

ParameterTypeDescription
hiddenbooleanIf true, hide gridlines in this sheet; otherwise show the gridlines.

Returns

FWorksheet

Returns the current worksheet instance for method chaining

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
// hide the gridlines
fWorkSheet.setHiddenGridlines(true);

Inherited from

FWorksheet.setHiddenGridlines


setName()

setName(name): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1495

Sets the sheet name.

Parameters

ParameterTypeDescription
namestringThe new name for the sheet.

Returns

FWorksheet

Returns the current worksheet instance for method chaining

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
// set the sheet name to 'Sheet1'
fWorkSheet.setName('Sheet1');

Inherited from

FWorksheet.setName


setRowCustom()

setRowCustom(custom): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:680

Set custom properties for given rows.

Parameters

ParameterTypeDescription
customIObjectArrayPrimitiveType<CustomData>The custom properties to set.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.setRowCustom


setRowCustomMetadata()

setRowCustomMetadata(index, custom): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1800

Set custom metadata of row

Parameters

ParameterTypeDescription
indexnumberrow index
customCustomDatacustom metadata

Returns

FWorksheet

Example

const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
fWorkSheet.setRowCustomMetadata(0, { key: 'value' });

Inherited from

FWorksheet.setRowCustomMetadata


setRowDefaultStyle()

setRowDefaultStyle(index, style): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:223

Set the default style of the worksheet column

Parameters

ParameterTypeDescription
indexnumberThe column index
style| string | Nullable<IStyleData>The style name or style data

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.setRowDefaultStyle


setRowHeight()

setRowHeight(rowPosition, height): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:587

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).

Parameters

ParameterTypeDescription
rowPositionnumberThe row position to change.
heightnumberThe height in pixels to set it to.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.setRowHeight


setRowHeights()

setRowHeights(
   startRow, 
   numRows, 
   height): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:599

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).

Parameters

ParameterTypeDescription
startRownumberThe starting row position to change.
numRowsnumberThe number of rows to change.
heightnumberThe height in pixels to set it to.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.setRowHeights


setRowHeightsForced()

setRowHeightsForced(
   startRow, 
   numRows, 
   height): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:651

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.

Parameters

ParameterTypeDescription
startRownumberThe starting row position to change.
numRowsnumberThe number of rows to change.
heightnumberThe height in pixels to set it to.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.setRowHeightsForced


setTabColor()

setTabColor(color): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1342

Sets the sheet tab color.

Parameters

ParameterTypeDescription
colorstringA color code in CSS notation (like ‘#ffffff’ or ‘white’), or null to reset the tab color.

Returns

FWorksheet

Returns the current worksheet instance for method chaining

Example

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

Inherited from

FWorksheet.setTabColor


showColumns()

showColumns(columnIndex, numColumns): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:933

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

Parameters

ParameterTypeDefault valueDescription
columnIndexnumberundefinedThe starting index of the columns to unhide.
numColumnsnumber1The number of columns to unhide.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.showColumns


showRows()

showRows(rowIndex, numRows): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:561

Scrolling sheet to make specific rows visible.

Parameters

ParameterTypeDefault valueDescription
rowIndexnumberundefinedThe starting index of the rows
numRowsnumber1The number of rows

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.showRows


showSheet()

showSheet(): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:1466

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

Returns

FWorksheet

Returns the current worksheet instance for method chaining

Example

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

Inherited from

FWorksheet.showSheet


sort()

sort(colIndex, asc): FWorksheet

Defined in: sheets-sort/src/facade/f-worksheet.ts:41

Sort the worksheet by the specified column.

Parameters

ParameterTypeDefault valueDescription
colIndexnumberundefinedThe column index to sort by. which starts from 1.
ascbooleantrueThe sort order. true for ascending, false for descending.

Returns

FWorksheet

The worksheet itself for chaining.

Example

const activeSpreadsheet = univerAPI.getActiveWorkbook();
const activeSheet = activeSpreadsheet.getActiveSheet();
activeSheet.sort(1); // Sorts the worksheet by the first column in ascending order.
activeSheet.sort(1, false); // Sorts the worksheet by the first column in descending order.

Implementation of

IFWorksheetSort.sort

Overrides

FWorksheet.sort

unhideColumn()

unhideColumn(column): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:913

Show the column in the given range.

Parameters

ParameterTypeDescription
columnFRangeThe range to unhide, if hidden.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.unhideColumn


unhideRow()

unhideRow(row): FWorksheet

Defined in: sheets/src/facade/f-worksheet.ts:541

Make the row in the given range visible.

Parameters

ParameterTypeDescription
rowFRangeThe range to unhide, if hidden.

Returns

FWorksheet

This sheet, for chaining.

Inherited from

FWorksheet.unhideRow


extend()

static extend(source): void

Defined in: core/src/facade/f-base.ts:68

Parameters

ParameterType
sourceany

Returns

void

Inherited from

FWorksheet.extend