Univer Sheets Data Structures
This document describes the main data structures used in Univer Sheet: IWorkbookData
and IWorksheetData
.
IWorkbookData
IWorkbookData
represents the snapshot of a workbook in Univer Sheet.
Usage
IWorkbookData is the object used to store data in Univer Sheets. It is mainly used for:
Properties
Property | Type | Description |
---|---|---|
id | string | Unique identifier of the Univer Sheets. |
name | string | Name of the Univer Sheets. |
appVersion | string | Version of the Univer model definition. |
locale | LocaleType | Locale of the document. |
styles | Record<string, Nullable<IStyleData>> | Style references for the workbook. |
sheetOrder | string[] | Array of sheet IDs representing the order of worksheets. |
sheets | { [sheetId: string]: Partial<IWorksheetData> } | Record containing data for each worksheet. |
resources? | IResources | Optional resources for other plugins. |
defaultStyle | Nullable<IStyleData> | The default style of worksheet |
Example
const workbookData: IWorkbookData = {
id: 'unique-workbook-id',
name: 'My Workbook',
appVersion: '1.0.0',
locale: LocaleType.EN_US,
styles: { /* style definitions */ },
sheetOrder: ['sheet1', 'sheet2'],
sheets: {
sheet1: { /* sheet data */ },
sheet2: { /* sheet data */ }
}
};
IWorksheetData
IWorksheetData
represents the snapshot of a worksheet in Univer Sheet.
Properties
Property | Type | Description |
---|---|---|
id | string | Unique identifier for the worksheet. |
name | string | Name of the worksheet. |
tabColor | string | Color of the worksheet tab. |
hidden | BooleanNumber | Whether the sheet is hidden. Default: BooleanNumber.FALSE . |
freeze | IFreeze | Freeze pane settings. |
rowCount | number | Total number of rows. |
columnCount | number | Total number of columns. |
defaultColumnWidth | number | Default width for columns. |
defaultRowHeight | number | Default height for rows. |
mergeData | IRange[] | Array of merged cell ranges. |
cellData | IObjectMatrixPrimitiveType<ICellData> | Matrix of cell contents. More details. |
rowData | IObjectArrayPrimitiveType<Partial<IRowData>> | Array of row data objects. |
columnData | IObjectArrayPrimitiveType<Partial<IColumnData>> | Array of column data objects. |
rowHeader | { width: number; hidden?: BooleanNumber; } | Row header configuration. |
columnHeader | { height: number; hidden?: BooleanNumber; } | Column header configuration. |
showGridlines | BooleanNumber | Whether gridlines are visible. |
rightToLeft | BooleanNumber | Whether the worksheet is in right-to-left mode. |
Example
const worksheetData: IWorksheetData = {
id: 'sheet1',
name: 'Sheet 1',
tabColor: '#FF0000',
hidden: BooleanNumber.FALSE,
freeze: { xSplit: 1, ySplit: 1, startRow: 1, startColumn: 1 },
rowCount: 1000,
columnCount: 26,
defaultColumnWidth: 100,
defaultRowHeight: 25,
mergeData: [],
cellData: {
'0': {
'0': {
v: 123
}
}
},
rowData: [],
columnData: [],
rowHeader: { width: 40 },
columnHeader: { height: 20 },
showGridlines: BooleanNumber.TRUE,
rightToLeft: BooleanNumber.FALSE
};
This structure provides a comprehensive representation of worksheet data, including layout, content, and display settings.
Full Example
const workbook: IWorkbookData = {
"id": "gyI0JO",
"sheetOrder": [
"RSfWjJFv4opmE1JaiRj80"
],
"name": "",
"appVersion": "0.5.0",
"locale": "enUS",
"styles": {},
"sheets": {
"RSfWjJFv4opmE1JaiRj80": {
"id": "RSfWjJFv4opmE1JaiRj80",
"name": "Test",
"tabColor": "",
"hidden": 0,
"rowCount": 30,
"columnCount": 10,
"zoomRatio": 1,
"freeze": {
"startRow": -1,
"startColumn": -1,
"ySplit": 0,
"xSplit": 0
},
"scrollTop": 0,
"scrollLeft": 0,
"defaultColumnWidth": 73,
"defaultRowHeight": 23,
"mergeData": [],
"cellData": {},
"rowData": {},
"columnData": {
"0": {
"w": 125,
"hd": 0
},
"1": {
"w": 125,
"hd": 0
},
"2": {
"w": 125,
"hd": 0
},
"3": {
"w": 125,
"hd": 0
},
"4": {
"w": 125,
"hd": 0
},
"5": {
"w": 125,
"hd": 0
},
"6": {
"w": 125,
"hd": 0
},
"7": {
"w": 125,
"hd": 0
},
"8": {
"w": 125,
"hd": 0
},
"9": {
"w": 125,
"hd": 0
}
},
"showGridlines": 1,
"rowHeader": {
"width": 46,
"hidden": 0
},
"columnHeader": {
"height": 20,
"hidden": 0
},
"selections": [
"A1"
],
"rightToLeft": 0
}
},
"resources": [
{
"name": "SHEET_DEFINED_NAME_PLUGIN",
"data": ""
}
]
}