Worksheet Data Structure
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, unit px. |
| defaultRowHeight | number | Default height for rows, unit px. |
| 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. |
| defaultStyle? | Nullable<IStyleData> | The default style of worksheet |
Example
TypeScript
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
TypeScript
const workbook: IWorkbookData = { id: 'gyI0JO', sheetOrder: [ 'RSfWjJFv4opmE1JaiRj80', ], name: '', appVersion: '0.10.2', 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, }, rightToLeft: 0, }, }, resources: [ { name: 'SHEET_DEFINED_NAME_PLUGIN', data: '', }, ],}How is this guide?