@univerjscoreclassesWorkbook

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


Class: Workbook

Access and create Univer Sheets files

Extends

Constructors

new Workbook()

new Workbook(workbookData, _logService): Workbook

Parameters

ParameterType
workbookDataPartial<IWorkbookData>
_logServiceILogService

Returns

Workbook

Overrides

UnitModel.constructor

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:84

Properties

PropertyModifierTypeDefault valueOverridesInherited fromDefined in
_disposedprotectedbooleanfalse-UnitModel._disposedpackages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:93
activeSheet$readonlyObservable<Nullable<Worksheet>>undefined--packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:48
name$readonlyObservable<string>undefinedUnitModel.name$-packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:75
sheetCreated$readonlyObservable<Worksheet>undefined--packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:41
sheetDisposed$readonlyObservable<Worksheet>undefined--packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:44
typepublicUNIVER_SHEETUniverInstanceType.UNIVER_SHEETUnitModel.type-packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:38

Accessors

name

Get Signature

get name(): string
Returns

string

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:76

Methods

addWorksheet()

addWorksheet(
   id, 
   index, 
   worksheetSnapshot): boolean

Add a Worksheet into Workbook.

Parameters

ParameterType
idstring
indexnumber
worksheetSnapshotPartial<IWorksheetData>

Returns

boolean

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:170


checkSheetName()

checkSheetName(name): boolean

Check if sheet name is unique

Parameters

ParameterTypeDescription
namestringsheet name

Returns

boolean

True if sheet name is unique

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:358


dispose()

dispose(): void

Returns

void

Overrides

UnitModel.dispose

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:113


disposeWithMe()

disposeWithMe(disposable): IDisposable

Parameters

ParameterType
disposableDisposableLike

Returns

IDisposable

Inherited from

UnitModel.disposeWithMe

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:96


ensureActiveSheet()

ensureActiveSheet(): Worksheet

If there is no active sheet, the first sheet would be set active.

Returns

Worksheet

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:228


ensureNotDisposed()

protected ensureNotDisposed(): void

Returns

void

Inherited from

UnitModel.ensureNotDisposed

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:100


generateNewSheetName()

generateNewSheetName(name): string

Automatically generate new sheet name

Parameters

ParameterTypeDescription
namestringsheet name

Returns

string

New sheet name

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:382


getActiveSheet()

getActiveSheet(undefined)

getActiveSheet(): Worksheet

Get the active sheet.

Returns

Worksheet

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:213

getActiveSheet(allowNull)

getActiveSheet(allowNull): Nullable<Worksheet>
Parameters
ParameterType
allowNulltrue
Returns

Nullable<Worksheet>

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:214


getActiveSheetIndex()

getActiveSheetIndex(): number

Returns

number

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:274


getActiveSpreadsheet()

getActiveSpreadsheet(): Workbook

Returns

Workbook

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:193


getConfig()

getConfig(): IWorkbookData

Returns

IWorkbookData

Defined in

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


getHiddenWorksheets()

getHiddenWorksheets(): string[]

Returns

string[]

Defined in

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


getIndexBySheetId()

getIndexBySheetId(sheetId): number

Parameters

ParameterType
sheetIdstring

Returns

number

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:205


getName()

getName(): string

Returns

string

Deprecated

use use name property instead

Defined in

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


getRev()

getRev(): number

Get revision of the unit’s snapshot. Note that revision should start from 1.

Returns

number

Overrides

UnitModel.getRev

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:155


getSheetByIndex()

getSheetByIndex(index): Nullable<Worksheet>

Parameters

ParameterType
indexnumber

Returns

Nullable<Worksheet>

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:331


getSheetBySheetId()

getSheetBySheetId(sheetId): Nullable<Worksheet>

Parameters

ParameterType
sheetIdstring

Returns

Nullable<Worksheet>

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:327


getSheetBySheetName()

getSheetBySheetName(name): Nullable<Worksheet>

Parameters

ParameterType
namestring

Returns

Nullable<Worksheet>

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:318


getSheetIndex()

getSheetIndex(sheet): number

Parameters

ParameterType
sheetWorksheet

Returns

number

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:307


getSheetOrders()

getSheetOrders(): readonly string[]

Returns

readonly string[]

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:185


getSheets()

getSheets(): Worksheet[]

Returns

Worksheet[]

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:286


getSheetSize()

getSheetSize(): number

Returns

number

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:282


getSheetsName()

getSheetsName(): string[]

Returns

string[]

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:292


getSnapshot()

getSnapshot(): IWorkbookData

Get current snapshot reference. Call resourceLoaderService.saveWorkbook to save the data associated with the current plugin if needed.

Returns

IWorkbookData

{IWorkbookData}

Memberof

Workbook

Overrides

UnitModel.getSnapshot

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:137


getStyles()

getStyles(): Styles

Returns

Styles

Defined in

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


getUnhiddenWorksheets()

getUnhiddenWorksheets(): string[]

Returns

string[]

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:342


getUnitId()

getUnitId(): string

Returns

string

Overrides

UnitModel.getUnitId

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:151


getWorksheets()

getWorksheets(): Map<string, Worksheet>

Returns

Map<string, Worksheet>

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:189


incrementRev()

incrementRev(): void

Increment the current revision.

Returns

void

Overrides

UnitModel.incrementRev

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:159


load()

load(config): void

Parameters

ParameterType
configIWorkbookData

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:348


removeSheet()

removeSheet(sheetId): boolean

Parameters

ParameterType
sheetIdstring

Returns

boolean

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:260


save()

save(): IWorkbookData

Create a clone of the current snapshot. Call resourceLoaderService.saveWorkbook to save the data associated with the current plugin if needed.

Returns

IWorkbookData

Memberof

Workbook

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:127


setActiveSheet()

setActiveSheet(worksheet): void

ActiveSheet should not be null! There is at least one sheet in a workbook. You can not delete all sheets in a workbook.

Parameters

ParameterType
worksheetWorksheet

Returns

void

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:256


setName()

setName(name): void

Parameters

ParameterType
namestring

Returns

void

Overrides

UnitModel.setName

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:146


setRev()

setRev(rev): void

Set revision of the current snapshot.

Parameters

ParameterType
revnumber

Returns

void

Overrides

UnitModel.setRev

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:163


uniqueSheetName()

uniqueSheetName(name): string

Check whether the sheet name is unique and generate a new unique sheet name

Parameters

ParameterTypeDefault valueDescription
namestring'Sheet1'sheet name

Returns

string

Unique sheet name

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:368


isIRangeType()

static isIRangeType(range): boolean

Parameters

ParameterType
rangeIRangeType | IRangeType[]

Returns

boolean

Defined in

packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:80