Class: FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:37
Represents a worksheet facade api instance. Which provides a set of methods to interact with the worksheet.
Extends
Extended by
FWorksheetDataValidationMixin
FWorksheetLegacy
FWorksheetFilter
FWorksheetHyperlinkMixin
FWorksheetSort
FWorksheetCommentMixin
FWorksheetSkeletonMixin
FWorksheetChartMixin
FWorksheetSparklineMixin
Constructors
new FWorksheet()
new FWorksheet(
_fWorkbook,
_workbook,
_worksheet,
_injector,
_selectionManagerService,
_logService,
_commandService): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:38
Parameters
Parameter | Type |
---|---|
_fWorkbook | FWorkbook |
_workbook | Workbook |
_worksheet | Worksheet |
_injector | Injector |
_selectionManagerService | SheetsSelectionsService |
_logService | ILogService |
_commandService | ICommandService |
Returns
Overrides
Properties
Property | Modifier | Type | Default value | Description | Inherited from | Defined in |
---|---|---|---|---|---|---|
_commandService | readonly | ICommandService | undefined | - | - | submodules/univer/packages/sheets/src/facade/f-worksheet.ts:45 |
_disposed | protected | boolean | false | - | FBaseInitialable ._disposed | submodules/univer/packages/core/src/shared/lifecycle.ts:96 |
_fWorkbook | readonly | FWorkbook | undefined | - | - | submodules/univer/packages/sheets/src/facade/f-worksheet.ts:39 |
_injector | readonly | Injector | undefined | - | FBaseInitialable ._injector | submodules/univer/packages/sheets/src/facade/f-worksheet.ts:42 |
_logService | readonly | ILogService | undefined | - | - | submodules/univer/packages/sheets/src/facade/f-worksheet.ts:44 |
_selectionManagerService | readonly | SheetsSelectionsService | undefined | - | - | submodules/univer/packages/sheets/src/facade/f-worksheet.ts:43 |
_workbook | readonly | Workbook | undefined | - | - | submodules/univer/packages/sheets/src/facade/f-worksheet.ts:40 |
_worksheet | readonly | Worksheet | undefined | - | - | submodules/univer/packages/sheets/src/facade/f-worksheet.ts:41 |
setActiveSelection | public | (range : FRange ) => FWorksheet | undefined | Sets the active selection region for this sheet. Param The range to set as the active selection. | - | submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1076 |
Methods
_initialize()
_initialize(injector): void
Defined in: submodules/univer/packages/core/src/facade/f-base.ts:66
Parameters
Parameter | Type |
---|---|
injector | Injector |
Returns
void
Inherited from
activate()
activate(): FWorksheet
Defined in: submodules/univer/packages/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
Current sheet, for chaining.
addEvent()
addEvent(event, callback): IDisposable
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:76
Add an event listener
Parameters
Parameter | Type | Description |
---|---|---|
event | keyof IEventParamConfig | key of event |
callback | (params ) => void | callback when event triggered |
Returns
The Disposable instance, for remove the listener
Example
univerAPI.addEvent(univerAPI.event.UnitCreated, (params) => {
console.log('unit created', params);
});
cancelFreeze()
cancelFreeze(): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1100
Cancels the frozen state of the current sheet.
Returns
True if the command was successful, false otherwise.
clear()
clear(options?): FWorksheet
Defined in: submodules/univer/packages/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
Parameter | Type | Description |
---|---|---|
options ? | IFacadeClearOptions | Options for clearing the sheet. If not provided, the contents and formatting are cleared both. |
Returns
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 });
clearContents()
clearContents(): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1586
Clears the sheet of contents, while preserving formatting information.
Returns
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();
clearFormats()
clearFormats(): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1617
Clears the sheet of formatting, while preserving contents.
Returns
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();
deleteColumn()
deleteColumn(columnPosition): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:807
Deletes the column at the given column position.
Parameters
Parameter | Type | Description |
---|---|---|
columnPosition | number | The position of the column, starting at 0 for the first column. |
Returns
This sheet, for chaining.
deleteColumns()
deleteColumns(columnPosition, howMany): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:817
Deletes a number of columns starting at the given column position.
Parameters
Parameter | Type | Description |
---|---|---|
columnPosition | number | The position of the first column to delete, starting at 0 for the first column. |
howMany | number | The number of columns to delete. |
Returns
This sheet, for chaining.
deleteRow()
deleteRow(rowPosition): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:436
Deletes the row at the given row position.
Parameters
Parameter | Type | Description |
---|---|---|
rowPosition | number | The position of the row, starting at 0 for the first row. |
Returns
This sheet, for chaining.
deleteRows()
deleteRows(rowPosition, howMany): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:446
Deletes a number of rows starting at the given row position.
Parameters
Parameter | Type | Description |
---|---|---|
rowPosition | number | The position of the first row to delete, starting at 0 for the first row. |
howMany | number | The number of rows to delete. |
Returns
This sheet, for chaining.
dispose()
dispose(): void
Defined in: submodules/univer/packages/core/src/shared/lifecycle.ts:109
Returns
void
Inherited from
disposeWithMe()
disposeWithMe(disposable): IDisposable
Defined in: submodules/univer/packages/core/src/shared/lifecycle.ts:99
Parameters
Parameter | Type |
---|---|
disposable | DisposableLike |
Returns
Inherited from
FBaseInitialable
.disposeWithMe
ensureNotDisposed()
protected ensureNotDisposed(): void
Defined in: submodules/univer/packages/core/src/shared/lifecycle.ts:103
Returns
void
Inherited from
FBaseInitialable
.ensureNotDisposed
equalTo()
equalTo(other): boolean
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1732
Judge whether provided FWorksheet is equal to current.
Parameters
Parameter | Type | Description |
---|---|---|
other | FWorksheet | the 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'
fireEvent()
protected fireEvent<T>(event, params): undefined | boolean
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:91
Fire an event, used in internal only.
Type Parameters
Type Parameter |
---|
T extends keyof IEventParamConfig |
Parameters
Parameter | Type | Description |
---|---|---|
event | T | {string} key of event |
params | IEventParamConfig [T ] | {any} params of event |
Returns
undefined
| boolean
should cancel
Example
this.fireEvent(univerAPI.event.UnitCreated, params);
getActiveRange()
getActiveRange(): null | FRange
Defined in: submodules/univer/packages/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
getCellMergeData()
getCellMergeData(row, column): undefined | FRange
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1038
Get the merged cell data of the specified row and column.
Parameters
Parameter | Type | Description |
---|---|---|
row | number | The row index. |
column | number | The column index. |
Returns
undefined
| FRange
The merged cell data, or undefined if the cell is not merged.
getColumnCustomMetadata()
getColumnCustomMetadata(index): CustomData
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1847
Get custom metadata of column
Parameters
Parameter | Type | Description |
---|---|---|
index | number | column index |
Returns
custom metadata
Example
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
const custom = fWorkSheet.getColumnCustomMetadata(0);
getColumnDefaultStyle()
getColumnDefaultStyle(index, keepRaw?):
| string
| Nullable<IStyleData>
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:172
Get the default style of the worksheet column
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
index | number | undefined | The column index |
keepRaw ? | boolean | false | If 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
getDataRange()
getDataRange(): FRange
Defined in: submodules/univer/packages/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
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
getDefaultStyle()
getDefaultStyle():
| string
| Nullable<IStyleData>
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:152
Get the default style of the worksheet
Returns
| string
| Nullable
<IStyleData
>
Default style of the worksheet.
getDefinedNames()
getDefinedNames(): FDefinedName[]
Defined in: submodules/univer/packages/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();
getFreeze()
getFreeze(): IFreeze
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1114
Get the freeze state of the current sheet.
Returns
The freeze state of the current sheet.
Deprecated
use getRowFreezeStatus
and getColumnFreezeStatus
instead.
getFrozenColumnRange()
getFrozenColumnRange(): IColumnRange
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1255
Get freezed columns
Returns
The range of the frozen columns.
getFrozenColumns()
getFrozenColumns(): number
Defined in: submodules/univer/packages/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.
getFrozenRowRange()
getFrozenRowRange(): IRowRange
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1243
Get freezed rows.
Returns
The range of the frozen rows.
getFrozenRows()
getFrozenRows(): number
Defined in: submodules/univer/packages/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.
getGridLinesColor()
getGridLinesColor(): undefined | string
Defined in: submodules/univer/packages/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)‘.
getIndex()
getIndex(): number
Defined in: submodules/univer/packages/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
getInject()
getInject(): Injector
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:103
Returns the injector
Returns
The injector
getLastColumn()
getLastColumn(): number
Defined in: submodules/univer/packages/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());
getLastColumns()
getLastColumns(): number
Defined in: submodules/univer/packages/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
getLastRow()
getLastRow(): number
Defined in: submodules/univer/packages/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());
***
### ~~getLastRows()~~
```ts
getLastRows(): number
Defined in: submodules/univer/packages/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
***
### getMaxColumns()
```ts
getMaxColumns(): number
Defined in: submodules/univer/packages/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
getMaxRows()
getMaxRows(): number
Defined in: submodules/univer/packages/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
getMergeData()
getMergeData(): FRange[]
Defined in: submodules/univer/packages/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);
getMergedRanges()
getMergedRanges(): FRange[]
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1027
Get all merged cells in the current sheet
Returns
FRange
[]
all merged cells
getRange()
Call Signature
getRange(row, column): FRange
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:249
Returns a Range object representing a single cell at the specified row and column.
Parameters
Parameter | Type | Description |
---|---|---|
row | number | The row index of the cell. |
column | number | The column index of the cell. |
Returns
A Range object representing the specified cell.
Call Signature
getRange(
row,
column,
numRows): FRange
Defined in: submodules/univer/packages/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
Parameter | Type | Description |
---|---|---|
row | number | The starting row index of the range. |
column | number | The starting column index of the range. |
numRows | number | The number of rows in the range. |
Returns
A Range object representing the specified range.
Call Signature
getRange(
row,
column,
numRows,
numColumns): FRange
Defined in: submodules/univer/packages/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
Parameter | Type | Description |
---|---|---|
row | number | The starting row index of the range. |
column | number | The starting column index of the range. |
numRows | number | The number of rows in the range. |
numColumns | number | The number of columns in the range. |
Returns
A Range object representing the specified range.
Call Signature
getRange(a1Notation): FRange
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:272
Returns a Range object specified by A1 notation.
Parameters
Parameter | Type | Description |
---|---|---|
a1Notation | string | A string representing a range in A1 notation. |
Returns
A Range object representing the specified range.
getRowCustomMetadata()
getRowCustomMetadata(index): CustomData
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1832
Get custom metadata of row
Parameters
Parameter | Type | Description |
---|---|---|
index | number | row index |
Returns
custom metadata
Example
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
const custom = fWorkSheet.getRowCustomMetadata(0);
getRowDefaultStyle()
getRowDefaultStyle(index, keepRaw?):
| string
| Nullable<IStyleData>
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:162
Get the default style of the worksheet row
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
index | number | undefined | The row index |
keepRaw ? | boolean | false | If 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
getSelection()
getSelection(): null | FSelection
Defined in: submodules/univer/packages/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.
getSheet()
getSheet(): Worksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:50
Returns
getSheetId()
getSheetId(): string
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:119
Returns the worksheet id.
Returns
string
The id of the worksheet.
getSheetName()
getSheetName(): string
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:127
Returns the worksheet name.
Returns
string
The name of the worksheet.
getTabColor()
getTabColor(): undefined | string
Defined in: submodules/univer/packages/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());
getWorkbook()
getWorkbook(): Workbook
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:111
Returns the workbook
Returns
The workbook instance.
hasHiddenGridLines()
hasHiddenGridLines(): boolean
Defined in: submodules/univer/packages/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');
}
hideColumn()
hideColumn(column): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:868
Hides the column or columns in the given range.
Parameters
Parameter | Type | Description |
---|---|---|
column | FRange | The column range to hide. |
Returns
This sheet, for chaining.
hideColumns()
hideColumns(columnIndex, numColumns): FWorksheet
Defined in: submodules/univer/packages/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
Parameter | Type | Default value | Description |
---|---|---|---|
columnIndex | number | undefined | The starting index of the columns to hide. |
numColumns | number | 1 | The number of columns to hide. |
Returns
This sheet, for chaining.
hideRow()
hideRow(row): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:497
Hides the rows in the given range.
Parameters
Parameter | Type | Description |
---|---|---|
row | FRange | The row range to hide. |
Returns
This sheet, for chaining.
hideRows()
hideRows(rowIndex, numRows): FWorksheet
Defined in: submodules/univer/packages/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
Parameter | Type | Default value | Description |
---|---|---|---|
rowIndex | number | undefined | The starting index of the rows to hide. |
numRows | number | 1 | The number of rows to hide. |
Returns
This sheet, for chaining.
hideSheet()
hideSheet(): FWorksheet
Defined in: submodules/univer/packages/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
Returns the current worksheet instance for method chaining
Example
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
// hide the active sheet
fWorkSheet.hideSheet();
insertColumnAfter()
insertColumnAfter(afterPosition): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:709
Inserts a column after the given column position.
Parameters
Parameter | Type | Description |
---|---|---|
afterPosition | number | The column after which the new column should be added, starting at 0 for the first column. |
Returns
This sheet, for chaining.
insertColumnBefore()
insertColumnBefore(beforePosition): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:718
Inserts a column before the given column position.
Parameters
Parameter | Type | Description |
---|---|---|
beforePosition | number | The column before which the new column should be added, starting at 0 for the first column. |
Returns
This sheet, for chaining.
insertColumns()
insertColumns(columnIndex, numColumns): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:728
Inserts one or more consecutive blank columns in a sheet starting at the specified location.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
columnIndex | number | undefined | The index indicating where to insert a column, starting at 0 for the first column. |
numColumns | number | 1 | The number of columns to insert. |
Returns
This sheet, for chaining.
insertColumnsAfter()
insertColumnsAfter(afterPosition, howMany): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:738
Inserts a given number of columns after the given column position.
Parameters
Parameter | Type | Description |
---|---|---|
afterPosition | number | The column after which the new column should be added, starting at 0 for the first column. |
howMany | number | The number of columns to insert. |
Returns
This sheet, for chaining.
insertColumnsBefore()
insertColumnsBefore(beforePosition, howMany): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:773
Inserts a number of columns before the given column position.
Parameters
Parameter | Type | Description |
---|---|---|
beforePosition | number | The column before which the new column should be added, starting at 0 for the first column. |
howMany | number | The number of columns to insert. |
Returns
This sheet, for chaining.
insertDefinedName()
insertDefinedName(name, formulaOrRefString): void
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1751
Parameters
Parameter | Type |
---|---|
name | string |
formulaOrRefString | string |
Returns
void
insertRowAfter()
insertRowAfter(afterPosition): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:338
Inserts a row after the given row position.
Parameters
Parameter | Type | Description |
---|---|---|
afterPosition | number | The row after which the new row should be added, starting at 0 for the first row. |
Returns
This sheet, for chaining.
insertRowBefore()
insertRowBefore(beforePosition): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:347
Inserts a row before the given row position.
Parameters
Parameter | Type | Description |
---|---|---|
beforePosition | number | The row before which the new row should be added, starting at 0 for the first row. |
Returns
This sheet, for chaining.
insertRows()
insertRows(rowIndex, numRows): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:357
Inserts one or more consecutive blank rows in a sheet starting at the specified location.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
rowIndex | number | undefined | The index indicating where to insert a row, starting at 0 for the first row. |
numRows | number | 1 | The number of rows to insert. |
Returns
This sheet, for chaining.
insertRowsAfter()
insertRowsAfter(afterPosition, howMany): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:367
Inserts a number of rows after the given row position.
Parameters
Parameter | Type | Description |
---|---|---|
afterPosition | number | The row after which the new rows should be added, starting at 0 for the first row. |
howMany | number | The number of rows to insert. |
Returns
This sheet, for chaining.
insertRowsBefore()
insertRowsBefore(beforePosition, howMany): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:402
Inserts a number of rows before the given row position.
Parameters
Parameter | Type | Description |
---|---|---|
beforePosition | number | The row before which the new rows should be added, starting at 0 for the first row. |
howMany | number | The number of rows to insert. |
Returns
This sheet, for chaining.
isSheetHidden()
isSheetHidden(): boolean
Defined in: submodules/univer/packages/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.
moveColumns()
moveColumns(columnSpec, destinationIndex): FWorksheet
Defined in: submodules/univer/packages/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
Parameter | Type | Description |
---|---|---|
columnSpec | FRange | A range spanning the columns that should be moved. |
destinationIndex | number | The 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
This sheet, for chaining.
moveRows()
moveRows(rowSpec, destinationIndex): FWorksheet
Defined in: submodules/univer/packages/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
Parameter | Type | Description |
---|---|---|
rowSpec | FRange | A range spanning the rows that should be moved. |
destinationIndex | number | The 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
This sheet, for chaining.
onBeforeCellDataChange()
onBeforeCellDataChange(callback): IDisposable
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1415
Subscribe to the cell data change event.
Parameters
Parameter | Type | Description |
---|---|---|
callback | (cellValue ) => void | The callback function to be executed before the cell data changes. |
Returns
- 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();
onCellDataChange()
onCellDataChange(callback): IDisposable
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1383
Subscribe to the cell data change event.
Parameters
Parameter | Type | Description |
---|---|---|
callback | (cellValue ) => void | The callback function to be executed when the cell data changes. |
Returns
- 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();
setActiveRange()
setActiveRange(range): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1061
Sets the active selection region for this sheet.
Parameters
Parameter | Type | Description |
---|---|---|
range | FRange | The range to set as the active selection. |
Returns
This sheet, for chaining.
setColumnCustom()
setColumnCustom(custom): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:999
Set custom properties for given columns.
Parameters
Parameter | Type | Description |
---|---|---|
custom | IObjectArrayPrimitiveType <CustomData > | The custom properties to set. |
Returns
This sheet, for chaining.
setColumnCustomMetadata()
setColumnCustomMetadata(index, custom): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1816
Set custom metadata of column
Parameters
Parameter | Type | Description |
---|---|---|
index | number | column index |
custom | CustomData | custom metadata |
Returns
Example
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
fWorkSheet.setColumnCustomMetadata(0, { key: 'value' });
setColumnDefaultStyle()
setColumnDefaultStyle(index, style): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:199
Set the default style of the worksheet row
Parameters
Parameter | Type | Description |
---|---|---|
index | number | The row index |
style | | string | Nullable <IStyleData > | The style name or style data |
Returns
This sheet, for chaining.
setColumnWidth()
setColumnWidth(columnPosition, width): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:959
Sets the width of the given column in pixels.
Parameters
Parameter | Type | Description |
---|---|---|
columnPosition | number | The position of the given column to set. |
width | number | The width in pixels to set it to. |
Returns
This sheet, for chaining.
setColumnWidths()
setColumnWidths(
startColumn,
numColumns,
width): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:970
Sets the width of the given columns in pixels.
Parameters
Parameter | Type | Description |
---|---|---|
startColumn | number | The starting column position to change. |
numColumns | number | The number of columns to change. |
width | number | The width in pixels to set it to. |
Returns
This sheet, for chaining.
setCustomMetadata()
setCustomMetadata(custom): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1784
Set custom metadata of worksheet
Parameters
Parameter | Type | Description |
---|---|---|
custom | CustomData | custom metadata |
Returns
Example
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
fWorkSheet.setCustomMetadata({ key: 'value' });
setDefaultStyle()
setDefaultStyle(style): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:181
Set the default style of the worksheet
Parameters
Parameter | Type | Description |
---|---|---|
style | string | default style |
Returns
This sheet, for chaining.
setFreeze()
setFreeze(freeze): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1085
Sets the frozen state of the current sheet.
Parameters
Parameter | Type | Description |
---|---|---|
freeze | IFreeze | the 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
True if the command was successful, false otherwise.
Deprecated
use setFrozenRows
and setFrozenColumns
instead.
setFrozenColumns()
Call Signature
setFrozenColumns(columns): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1123
Set the number of frozen columns.
Parameters
Parameter | Type | Description |
---|---|---|
columns | number | The number of columns to freeze. To unfreeze all columns, set this value to 0. |
Returns
Call Signature
setFrozenColumns(startColumn, endColumn): FWorksheet
Defined in: submodules/univer/packages/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
Parameter | Type | Description |
---|---|---|
startColumn | number | The start column of the range to freeze. |
endColumn | number | The end column of the range to freeze. |
Returns
This FWorksheet instance.
Example
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
// freeze the first too columns.
fWorkSheet.setFrozenColumns(0, 2);
setFrozenRows()
Call Signature
setFrozenRows(rows): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1172
Set the number of frozen rows.
Parameters
Parameter | Type | Description |
---|---|---|
rows | number | The number of rows to freeze. To unfreeze all rows, set this value to 0. |
Returns
Call Signature
setFrozenRows(startColumn, endColumn): FWorksheet
Defined in: submodules/univer/packages/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
Parameter | Type |
---|---|
startColumn | number |
endColumn | number |
Returns
Example
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
// freeze the first too rows.
fWorkSheet.setFrozenRows(0, 2);
setGridLinesColor()
setGridLinesColor(color): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1313
Set the color of the gridlines in the sheet.
Parameters
Parameter | Type | Description |
---|---|---|
color | undefined | string | The color to set for the gridlines.Undefined or null to reset to the default color. |
Returns
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');
setHiddenGridlines()
setHiddenGridlines(hidden): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1292
Hides or reveals the sheet gridlines.
Parameters
Parameter | Type | Description |
---|---|---|
hidden | boolean | If true , hide gridlines in this sheet; otherwise show the gridlines. |
Returns
Returns the current worksheet instance for method chaining
Example
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
// hide the gridlines
fWorkSheet.setHiddenGridlines(true);
setName()
setName(name): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1495
Sets the sheet name.
Parameters
Parameter | Type | Description |
---|---|---|
name | string | The new name for the sheet. |
Returns
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');
setRowCustom()
setRowCustom(custom): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:680
Set custom properties for given rows.
Parameters
Parameter | Type | Description |
---|---|---|
custom | IObjectArrayPrimitiveType <CustomData > | The custom properties to set. |
Returns
This sheet, for chaining.
setRowCustomMetadata()
setRowCustomMetadata(index, custom): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1800
Set custom metadata of row
Parameters
Parameter | Type | Description |
---|---|---|
index | number | row index |
custom | CustomData | custom metadata |
Returns
Example
const fWorkbook = univerAPI.getActiveWorkbook();
const fWorkSheet = fWorkbook.getActiveSheet();
fWorkSheet.setRowCustomMetadata(0, { key: 'value' });
setRowDefaultStyle()
setRowDefaultStyle(index, style): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:223
Set the default style of the worksheet column
Parameters
Parameter | Type | Description |
---|---|---|
index | number | The column index |
style | | string | Nullable <IStyleData > | The style name or style data |
Returns
This sheet, for chaining.
setRowHeight()
setRowHeight(rowPosition, height): FWorksheet
Defined in: submodules/univer/packages/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
Parameter | Type | Description |
---|---|---|
rowPosition | number | The row position to change. |
height | number | The height in pixels to set it to. |
Returns
This sheet, for chaining.
setRowHeights()
setRowHeights(
startRow,
numRows,
height): FWorksheet
Defined in: submodules/univer/packages/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
Parameter | Type | Description |
---|---|---|
startRow | number | The starting row position to change. |
numRows | number | The number of rows to change. |
height | number | The height in pixels to set it to. |
Returns
This sheet, for chaining.
setRowHeightsForced()
setRowHeightsForced(
startRow,
numRows,
height): FWorksheet
Defined in: submodules/univer/packages/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
Parameter | Type | Description |
---|---|---|
startRow | number | The starting row position to change. |
numRows | number | The number of rows to change. |
height | number | The height in pixels to set it to. |
Returns
This sheet, for chaining.
setTabColor()
setTabColor(color): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1342
Sets the sheet tab color.
Parameters
Parameter | Type | Description |
---|---|---|
color | string | A color code in CSS notation (like ‘#ffffff’ or ‘white’), or null to reset the tab color. |
Returns
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');
showColumns()
showColumns(columnIndex, numColumns): FWorksheet
Defined in: submodules/univer/packages/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
Parameter | Type | Default value | Description |
---|---|---|---|
columnIndex | number | undefined | The starting index of the columns to unhide. |
numColumns | number | 1 | The number of columns to unhide. |
Returns
This sheet, for chaining.
showRows()
showRows(rowIndex, numRows): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:561
Scrolling sheet to make specific rows visible.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
rowIndex | number | undefined | The starting index of the rows |
numRows | number | 1 | The number of rows |
Returns
This sheet, for chaining.
showSheet()
showSheet(): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:1466
Shows this sheet. Has no effect if the sheet is already visible.
Returns
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();
unhideColumn()
unhideColumn(column): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:913
Show the column in the given range.
Parameters
Parameter | Type | Description |
---|---|---|
column | FRange | The range to unhide, if hidden. |
Returns
This sheet, for chaining.
unhideRow()
unhideRow(row): FWorksheet
Defined in: submodules/univer/packages/sheets/src/facade/f-worksheet.ts:541
Make the row in the given range visible.
Parameters
Parameter | Type | Description |
---|---|---|
row | FRange | The range to unhide, if hidden. |
Returns
This sheet, for chaining.
extend()
static extend(source): void
Defined in: submodules/univer/packages/core/src/facade/f-base.ts:68
Parameters
Parameter | Type |
---|---|
source | any |
Returns
void