@univerjscoreclassesWorksheet

@univerjs/core v0.5.0-beta.1Docs


Class: Worksheet

The model of a Worksheet.

Constructors

new Worksheet()

new Worksheet(
   unitId, 
   snapshot, 
   _styles): Worksheet

Parameters

ParameterType
unitIdstring
snapshotPartial<IWorksheetData>
_stylesStyles

Returns

Worksheet

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:81

Properties

PropertyModifierTypeDefined in
_cellDataprotectedObjectMatrix<ICellData>packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:72
_columnManagerprotectedColumnManagerpackages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:75
_rowManagerprotectedRowManagerpackages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:74
_sheetIdprotectedstringpackages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:70
_snapshotprotectedIWorksheetDatapackages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:71
_spanModelprotectedSpanModelpackages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:79
_viewModelreadonlySheetViewModelpackages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:77
unitIdreadonlystringpackages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:82

Methods

__interceptViewModel()

__interceptViewModel(callback): void

Internal

Parameters

ParameterType
callback(viewModel) => void

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:103


cellHasValue()

cellHasValue(value): boolean

Parameters

ParameterType
valueICellData

Returns

boolean

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:809


clone()

clone(): Worksheet

Returns WorkSheet Clone Object

Returns

Worksheet

WorkSheet Clone Object

Deprecated

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:353


getBlankCellDocumentModel()

getBlankCellDocumentModel(cell): IDocumentLayoutObject

Only used for cell edit, and no need to rotate text when edit cell content!

Parameters

ParameterType
cellNullable<ICellData>

Returns

IDocumentLayoutObject

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:1111


getCell()

getCell(row, col): Nullable<ICellDataForSheetInterceptor>

Get cellData, includes cellData, customRender, markers, dataValidate, etc.

WARNING: All sheet CELL_CONTENT interceptors will be called in this method, cause performance issue. example: this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT);

Parameters

ParameterType
rownumber
colnumber

Returns

Nullable<ICellDataForSheetInterceptor>

ICellDataForSheetInterceptor

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:477


getCellDocumentModelWithFormula()

getCellDocumentModelWithFormula(cell): Nullable<IDocumentLayoutObject>

Parameters

ParameterType
cellICellData

Returns

Nullable<IDocumentLayoutObject>

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:1150


getCellInfoInMergeData()

getCellInfoInMergeData(row, column): ISelectionCell

Get cell info with merge data

Parameters

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

Returns

ISelectionCell

  • The cell info with merge data

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:423


getCellMatrix()

getCellMatrix(): ObjectMatrix<Nullable<ICellData>>

Returns WorkSheet Cell Data Matrix

Returns

ObjectMatrix<Nullable<ICellData>>

WorkSheet Cell Data Matrix

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:218


getCellMatrixPrintRange()

getCellMatrixPrintRange(): null | {
  endColumn: number;
  endRow: number;
  startColumn: number;
  startRow: number;
}

Get worksheet printable cell range.

Returns

null | { endColumn: number; endRow: number; startColumn: number; startRow: number; }

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:227


getCellRaw()

getCellRaw(row, col): Nullable<ICellData>

Parameters

ParameterType
rownumber
colnumber

Returns

Nullable<ICellData>

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:513


getCellStyleOnly()

getCellStyleOnly(row, col): Nullable<ICellDataForSheetInterceptor>

Get cellData only use effect on style interceptor

Parameters

ParameterTypeDescription
rownumberThe row index of the cell.
colnumberThe column index of the cell.

Returns

Nullable<ICellDataForSheetInterceptor>

The cell data only use effect on style interceptor

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:505


getCellValueOnly()

getCellValueOnly(row, col): Nullable<ICellDataForSheetInterceptor>

Get cellData only use effect on value interceptor

Parameters

ParameterType
rownumber
colnumber

Returns

Nullable<ICellDataForSheetInterceptor>

The cell data only use effect on value interceptor

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:491


getColumnCount()

getColumnCount(): number

Returns

number

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:655


getColumnManager()

getColumnManager(): ColumnManager

Returns Column Manager

Returns

ColumnManager

Column Manager

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:336


getColumnStyle()

getColumnStyle(column, keepRaw?): string | Nullable<IStyleData>

Get the style of the column.

Parameters

ParameterTypeDefault valueDescription
columnnumberundefinedThe column index
keepRaw?booleanfalseIf true, return the raw style data, otherwise return the style data object

Returns

string | Nullable<IStyleData>

The style of the column

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:130


getColumnWidth()

getColumnWidth(columnPosition): number

Gets the width in pixels of the given column.

Parameters

ParameterTypeDescription
columnPositionnumbercolumn index

Returns

number

Gets the width in pixels of the given column.

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:701


getColVisible()

getColVisible(col): boolean

Parameters

ParameterType
colnumber

Returns

boolean

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:752


getConfig()

getConfig(): IWorksheetData

Returns WorkSheet Configures

Returns

IWorksheetData

WorkSheet Configures

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:613


getDefaultCellStyle()

getDefaultCellStyle(): string | Nullable<IStyleData>

Get the default style of the worksheet.

Returns

string | Nullable<IStyleData>

Default Style

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:197


getDefaultCellStyleInternal()

getDefaultCellStyleInternal(): Nullable<IStyleData>

Returns

Nullable<IStyleData>

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:201


getFreeze()

getFreeze(): IFreeze

Returns frozen.

Returns

IFreeze

frozen

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:621


getHiddenCols()

getHiddenCols(start?, end?): IRange[]

Parameters

ParameterType
start?number
end?number

Returns

IRange[]

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:756


getHiddenRows()

getHiddenRows(start?, end?): IRange[]

Parameters

ParameterType
start?number
end?number

Returns

IRange[]

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:744


getLastColumnWithContent()

getLastColumnWithContent(): number

Returns the position of the last column that has content.

Returns

number

the position of the last column that has content.

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:805


getLastRowWithContent()

getLastRowWithContent(): number

Returns the position of the last row that has content.

Returns

number

the position of the last row that has content.

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:797


getMatrixWithMergedCells()

getMatrixWithMergedCells(
   row, 
   col, 
   endRow, 
   endCol, 
   isRaw): ObjectMatrix<ICellData & {
  colSpan: number;
  rowSpan: number;
}>

Get cell matrix from a given range and pick out non-first cells of merged cells.

Notice that ICellData here is not after copying. In another word, the object matrix here should be considered as a slice of the original worksheet data matrix.

Parameters

ParameterTypeDefault value
rownumberundefined
colnumberundefined
endRownumberundefined
endColnumberundefined
isRawbooleanfalse

Returns

ObjectMatrix<ICellData & { colSpan: number; rowSpan: number; }>

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:527


getMaxColumns()

getMaxColumns(): number

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

Returns

number

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

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:629


getMaxRows()

getMaxRows(): number

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

Returns

number

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

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:640


getMergeData()

getMergeData(): IRange[]

Get the merged cell list of the sheet.

Returns

IRange[]

merged cell list

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:364


getMergedCell()

getMergedCell(row, col): Nullable<IRange>

Get the merged cell Range of the sheet cell.

Parameters

ParameterTypeDescription
rownumberThe row index of test cell
colnumberThe column index of test cell

Returns

Nullable<IRange>

The merged cell range of the cell, if the cell is not in a merged cell, return null

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:374


getMergedCellRange()

getMergedCellRange(
   startRow, 
   startColumn, 
   endRow, 
   endColumn): IRange[]

Get the merged cell info list which has intersection with the given range.

Parameters

ParameterTypeDescription
startRownumberThe start row index of the range
startColumnnumberThe start column index of the range
endRownumberThe end row index of the range
endColumnnumberThe end column index of the range

Returns

IRange[]

The merged cell info list which has intersection with the given range or empty array if no merged cell in the range

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:386


getName()

getName(): string

Returns the name of the sheet.

Returns

string

name of the sheet

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:344


getRange()

getRange(range)

getRange(range): Range
Parameters
ParameterType
rangeIRange
Returns

Range

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:570

getRange(startRow, startColumn)

getRange(startRow, startColumn): Range
Parameters
ParameterType
startRownumber
startColumnnumber
Returns

Range

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:571

getRange(startRow, startColumn, endRow, endColumn)

getRange(
   startRow, 
   startColumn, 
   endRow, 
   endColumn): Range
Parameters
ParameterType
startRownumber
startColumnnumber
endRownumber
endColumnnumber
Returns

Range

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:572


getRowCount()

getRowCount(): number

Returns

number

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:647


getRowFiltered()

getRowFiltered(row): boolean

Parameters

ParameterType
rownumber

Returns

boolean

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:517


getRowHeight()

getRowHeight(row): number

Gets the height in pixels of the given row.

Parameters

ParameterTypeDescription
rownumberrow index

Returns

number

Gets the height in pixels of the given row.

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:710


getRowManager()

getRowManager(): RowManager

Returns Row Manager

Returns

RowManager

Row Manager

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:313


getRowRawVisible()

getRowRawVisible(row): boolean

Get if the row does not have hidden property. This value won’t affected by features like filter and view.

Parameters

ParameterTypeDescription
rownumberthe row index

Returns

boolean

if the row does not have hidden property

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:740


getRowStyle()

getRowStyle(row, keepRaw?): string | Nullable<IStyleData>

Get the style of the row.

Parameters

ParameterTypeDefault valueDescription
rownumberundefinedThe row index
keepRaw?booleanfalseIf true, return the raw style data, otherwise return the style data object

Returns

string | Nullable<IStyleData>

The style of the row

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:152


getRowVisible()

getRowVisible(row): boolean

Get if the row is visible. It may be affected by features like filter and view.

Parameters

ParameterTypeDescription
rownumberthe row index

Returns

boolean

if the row in visible to the user

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:731


getScrollLeftTopFromSnapshot()

getScrollLeftTopFromSnapshot(): {
  scrollLeft: number;
  scrollTop: number;
}

Returns

{
  scrollLeft: number;
  scrollTop: number;
}
NameTypeDefined in
scrollLeftnumberpackages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:596
scrollTopnumberpackages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:597

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:594


getSheetId()

getSheetId(): string

Returns the ID of the sheet represented by this object.

Returns

string

ID of the sheet

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:328


getSnapshot()

getSnapshot(): IWorksheetData

Returns

IWorksheetData

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:107


getSpanModel()

getSpanModel(): SpanModel

Returns

SpanModel

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:120


getTabColor()

getTabColor(): Nullable<string>

Gets the sheet tab color, or null if the sheet tab has no color.

Returns

Nullable<string>

the sheet tab color or null

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:689


getUnitId()

getUnitId(): string

Returns the ID of its parent unit.

Returns

string

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:320


getVisibleCols()

getVisibleCols(): IRange[]

Get all visible columns in the sheet.(not include filter & view)

Returns

IRange[]

Visible columns range list

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:777


getVisibleRows()

getVisibleRows(): IRange[]

Get all visible rows in the sheet.(not include filter & view, like getRawVisibleRows)

Returns

IRange[]

Visible rows range list

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:768


getZoomRatio()

getZoomRatio(): number

Return WorkSheetZoomRatio

Returns

number

zoomRatio

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:605


hasHiddenGridlines()

hasHiddenGridlines(): boolean

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

Returns

boolean

Gridlines Hidden Status

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:675


isColumnContainsMergedCell()

isColumnContainsMergedCell(column): boolean

Get if the column contains merged cell

Parameters

ParameterTypeDescription
columnnumberThe column index

Returns

boolean

Is merge cell across column

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:404


isRightToLeft()

isRightToLeft(): BooleanNumber

Returns true if this sheet layout is right-to-left. Returns false if the sheet uses the default left-to-right layout.

Returns

BooleanNumber

true if this sheet layout is right-to-left. Returns false if the sheet uses the default left-to-right layout.

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:786


isRowContainsMergedCell()

isRowContainsMergedCell(row): boolean

Get if the row contains merged cell

Parameters

ParameterTypeDescription
rownumberThe row index

Returns

boolean

Is merge cell across row

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:395


isRowFiltered()

isRowFiltered(row): boolean

Row is filtered out, that means this row is invisible.

Parameters

ParameterType
rownumber

Returns

boolean

is row hidden by filter

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:722


isSheetHidden()

isSheetHidden(): BooleanNumber

isSheetHidden

Returns

BooleanNumber

hidden status of sheet

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:667


iterateByColumn()

iterateByColumn(
   range, 
   skipEmpty, 
skipNonTopLeft): Iterable<Readonly<ICell>, any, any>

Iterate a range column by column. This is pretty similar to iterateByRow but with different order.

Performance intensive.

Parameters

ParameterTypeDefault valueDescription
rangeIRangeundefinedThe iterate range.
skipEmptybooleantrueWhether to skip empty cells, default to be true.
skipNonTopLeftbooleantrueWhether to skip non-top-left cells of merged cells, default to be true. If the parameter is set to false, the iterator will return cells in the top row.

Returns

Iterable<Readonly<ICell>, any, any>

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:896


iterateByRow()

iterateByRow(range, skipEmpty): Iterable<Readonly<ICell>, any, any>

Iterate a range row by row.

Performance intensive.

Parameters

ParameterTypeDefault valueDescription
rangeIRangeundefinedthe iterate range
skipEmptybooleantruewhether to skip empty cells, default to be true

Returns

Iterable<Readonly<ICell>, any, any>

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:825


mixinDefaultStyleToCellRaw()

mixinDefaultStyleToCellRaw(
   row, 
   col, 
   cellRaw, 
   isRowStylePrecedeColumnStyle): void

this function is used to mixin default style to cell raw{number}

Parameters

ParameterTypeDescription
rownumberThe row index
colnumberThe column index
cellRawNullable<ICellData>The cell raw data
isRowStylePrecedeColumnStylebooleanThe priority of row style and column style

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:175


setColumnCount()

setColumnCount(count): void

Parameters

ParameterType
countnumber

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:659


setColumnStyle()

setColumnStyle(column, style): void

Set the style of the column.

Parameters

ParameterTypeDescription
columnnumberThe column index
stylestring | Nullable<IStyleData>The style to be set

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:142


setDefaultCellStyle()

setDefaultCellStyle(style): void

Set Default Style, if the style has been set, all cells style will be base on this style.

Parameters

ParameterTypeDescription
stylestring | Nullable<IStyleData>The style to be set as default style

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:210


setMergeData()

setMergeData(mergeData): void

Set the merge data of the sheet, all the merged cells will be rebuilt.

Parameters

ParameterType
mergeDataIRange[]

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:115


setRowCount()

setRowCount(count): void

Parameters

ParameterType
countnumber

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:651


setRowStyle()

setRowStyle(row, style): void

Set the style of the row.

Parameters

ParameterTypeDescription
rownumber-
stylestring | Nullable<IStyleData>The style to be set

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/worksheet.ts:164