@univerjscoreclassesWorkbook

@univerjs/core v0.5.4


Class: Workbook

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:37

Access and create Univer Sheets files

Extends

Constructors

new Workbook()

new Workbook(workbookData, _logService): Workbook

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

Parameters

ParameterType
workbookDataPartial<IWorkbookData>
_logServiceILogService

Returns

Workbook

Overrides

UnitModel.constructor

Properties

PropertyModifierTypeDefault valueOverridesInherited fromDefined in
_disposedprotectedbooleanfalse-UnitModel._disposedpackages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:96
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

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

Returns

string

Methods

addWorksheet()

addWorksheet(
   id, 
   index, 
   worksheetSnapshot): boolean

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

Add a Worksheet into Workbook.

Parameters

ParameterType
idstring
indexnumber
worksheetSnapshotPartial<IWorksheetData>

Returns

boolean


checkSheetName()

checkSheetName(name): boolean

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

Check if sheet name is unique

Parameters

ParameterTypeDescription
namestringsheet name

Returns

boolean

True if sheet name is unique


dispose()

dispose(): void

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

Returns

void

Overrides

UnitModel.dispose


disposeWithMe()

disposeWithMe(disposable): IDisposable

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:99

Parameters

ParameterType
disposableDisposableLike

Returns

IDisposable

Inherited from

UnitModel.disposeWithMe


ensureActiveSheet()

ensureActiveSheet(): Worksheet

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

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

Returns

Worksheet


ensureNotDisposed()

protected ensureNotDisposed(): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:103

Returns

void

Inherited from

UnitModel.ensureNotDisposed


generateNewSheetName()

generateNewSheetName(name): string

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

Automatically generate new sheet name

Parameters

ParameterTypeDescription
namestringsheet name

Returns

string

New sheet name


getActiveSheet()

Call Signature

getActiveSheet(): Worksheet

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

Get the active sheet.

Returns

Worksheet

Call Signature

getActiveSheet(allowNull): Nullable<Worksheet>

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

Get the active sheet.

Parameters
ParameterType
allowNulltrue
Returns

Nullable<Worksheet>


getActiveSheetIndex()

getActiveSheetIndex(): number

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

Returns

number


getActiveSpreadsheet()

getActiveSpreadsheet(): Workbook

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

Returns

Workbook


getConfig()

getConfig(): IWorkbookData

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

Returns

IWorkbookData


getCustomMetadata()

getCustomMetadata(): CustomData

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:432

Get custom metadata of workbook

Returns

CustomData

custom metadata


getHiddenWorksheets()

getHiddenWorksheets(): string[]

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

Returns

string[]


getIndexBySheetId()

getIndexBySheetId(sheetId): number

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

Parameters

ParameterType
sheetIdstring

Returns

number


getName()

getName(): string

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

Returns

string

Deprecated

use use name property instead


getRev()

getRev(): number

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

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

Returns

number

Overrides

UnitModel.getRev


getSheetByIndex()

getSheetByIndex(index): Nullable<Worksheet>

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

Parameters

ParameterType
indexnumber

Returns

Nullable<Worksheet>


getSheetBySheetId()

getSheetBySheetId(sheetId): Nullable<Worksheet>

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

Parameters

ParameterType
sheetIdstring

Returns

Nullable<Worksheet>


getSheetBySheetName()

getSheetBySheetName(name): Nullable<Worksheet>

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

Parameters

ParameterType
namestring

Returns

Nullable<Worksheet>


getSheetIndex()

getSheetIndex(sheet): number

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

Parameters

ParameterType
sheetWorksheet

Returns

number


getSheetOrders()

getSheetOrders(): readonly string[]

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

Returns

readonly string[]


getSheets()

getSheets(): Worksheet[]

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

Returns

Worksheet[]


getSheetSize()

getSheetSize(): number

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

Returns

number


getSheetsName()

getSheetsName(): string[]

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

Returns

string[]


getSnapshot()

getSnapshot(): IWorkbookData

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

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


getStyles()

getStyles(): Styles

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

Returns

Styles


getUnhiddenWorksheets()

getUnhiddenWorksheets(): string[]

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

Returns

string[]


getUnitId()

getUnitId(): string

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

Returns

string

Overrides

UnitModel.getUnitId


getWorksheets()

getWorksheets(): Map<string, Worksheet>

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

Returns

Map<string, Worksheet>


incrementRev()

incrementRev(): void

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

Increment the current revision.

Returns

void

Overrides

UnitModel.incrementRev


load()

load(config): void

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

Parameters

ParameterType
configIWorkbookData

Returns

void


removeSheet()

removeSheet(sheetId): boolean

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

Parameters

ParameterType
sheetIdstring

Returns

boolean


save()

save(): IWorkbookData

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

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


setActiveSheet()

setActiveSheet(worksheet): void

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

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


setCustomMetadata()

setCustomMetadata(custom): void

Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:440

Set custom metadata of workbook

Parameters

ParameterTypeDescription
customCustomDatacustom metadata

Returns

void


setName()

setName(name): void

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

Parameters

ParameterType
namestring

Returns

void

Overrides

UnitModel.setName


setRev()

setRev(rev): void

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

Set revision of the current snapshot.

Parameters

ParameterType
revnumber

Returns

void

Overrides

UnitModel.setRev


uniqueSheetName()

uniqueSheetName(name): string

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

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


isIRangeType()

static isIRangeType(range): boolean

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

Parameters

ParameterType
range| IRangeType | IRangeType[]

Returns

boolean