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
Parameter | Type |
---|---|
workbookData | Partial <IWorkbookData > |
_logService | ILogService |
Returns
Overrides
Properties
Property | Modifier | Type | Default value | Overrides | Inherited from | Defined in |
---|---|---|---|---|---|---|
_disposed | protected | boolean | false | - | UnitModel ._disposed | packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:96 |
activeSheet$ | readonly | Observable <Nullable <Worksheet >> | undefined | - | - | packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:48 |
name$ | readonly | Observable <string > | undefined | UnitModel .name$ | - | packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:75 |
sheetCreated$ | readonly | Observable <Worksheet > | undefined | - | - | packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:41 |
sheetDisposed$ | readonly | Observable <Worksheet > | undefined | - | - | packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:44 |
type | public | UNIVER_SHEET | UniverInstanceType.UNIVER_SHEET | UnitModel .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
Parameter | Type |
---|---|
id | string |
index | number |
worksheetSnapshot | Partial <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
Parameter | Type | Description |
---|---|---|
name | string | sheet 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
disposeWithMe()
disposeWithMe(disposable): IDisposable
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:99
Parameters
Parameter | Type |
---|---|
disposable | DisposableLike |
Returns
Inherited from
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
ensureNotDisposed()
protected ensureNotDisposed(): void
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/shared/lifecycle.ts:103
Returns
void
Inherited from
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
Parameter | Type | Description |
---|---|---|
name | string | sheet 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
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
Parameter | Type |
---|---|
allowNull | true |
Returns
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
getConfig()
getConfig(): IWorkbookData
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:201
Returns
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
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
Parameter | Type |
---|---|
sheetId | string |
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
getSheetByIndex()
getSheetByIndex(index): Nullable<Worksheet>
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:331
Parameters
Parameter | Type |
---|---|
index | number |
Returns
getSheetBySheetId()
getSheetBySheetId(sheetId): Nullable<Worksheet>
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:327
Parameters
Parameter | Type |
---|---|
sheetId | string |
Returns
getSheetBySheetName()
getSheetBySheetName(name): Nullable<Worksheet>
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:318
Parameters
Parameter | Type |
---|---|
name | string |
Returns
getSheetIndex()
getSheetIndex(sheet): number
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:307
Parameters
Parameter | Type |
---|---|
sheet | Worksheet |
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
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}
Memberof
Workbook
Overrides
getStyles()
getStyles(): Styles
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:197
Returns
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
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
load()
load(config): void
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:348
Parameters
Parameter | Type |
---|---|
config | IWorkbookData |
Returns
void
removeSheet()
removeSheet(sheetId): boolean
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:260
Parameters
Parameter | Type |
---|---|
sheetId | string |
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
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
Parameter | Type |
---|---|
worksheet | Worksheet |
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
Parameter | Type | Description |
---|---|---|
custom | CustomData | custom metadata |
Returns
void
setName()
setName(name): void
Defined in: packages/api/tmp/univer-pro/submodules/univer/packages/core/src/sheets/workbook.ts:146
Parameters
Parameter | Type |
---|---|
name | string |
Returns
void
Overrides
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
Parameter | Type |
---|---|
rev | number |
Returns
void
Overrides
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
Parameter | Type | Default value | Description |
---|---|---|---|
name | string | '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
Parameter | Type |
---|---|
range | | IRangeType | IRangeType [] |
Returns
boolean