工作表資料結構
IWorksheetData
IWorksheetData 表示 Univer Sheets 中工作表的快照。
屬性
| 屬性 | 類型 | 描述 |
|---|---|---|
| id | string | 工作表的唯一識別碼。 |
| name | string | 工作表的名稱。 |
| tabColor | string | 工作表標籤的顏色。 |
| hidden | BooleanNumber | 工作表是否隱藏。預設值:BooleanNumber.FALSE。 |
| freeze | IFreeze | 凍結窗格設定。 |
| rowCount | number | 總列數。 |
| columnCount | number | 總欄數。 |
| defaultColumnWidth | number | 欄的預設寬度,單位 px。 |
| defaultRowHeight | number | 列的預設高度,單位 px。 |
| mergeData | IRange[] | 合併儲存格範圍的陣列。 |
| cellData | IObjectMatrixPrimitiveType<ICellData> | 儲存格內容的矩陣。詳情 |
| rowData | IObjectArrayPrimitiveType<Partial<IRowData>> | 列資料物件的陣列。 |
| columnData | IObjectArrayPrimitiveType<Partial<IColumnData>> | 欄資料物件的陣列。 |
| rowHeader | { width: number; hidden?: BooleanNumber; } | 列標題設定。 |
| columnHeader | { height: number; hidden?: BooleanNumber; } | 欄標題設定。 |
| backgroundImage? | IWorksheetBackgroundImage | 選用的平鋪圖片來源:{ source: string; imageSourceType: ImageSourceType }。參閱背景圖。 |
| showGridlines | BooleanNumber | 是否顯示格線。 |
| rightToLeft | BooleanNumber | 工作表是否為由右至左模式。 |
| defaultStyle? | Nullable<IStyleData> | 預設工作表樣式 |
範例
TypeScript
const worksheetData: IWorksheetData = { id: 'sheet1', name: '工作表 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,}此結構提供了工作表資料的完整呈現,包含版面配置、內容與顯示設定。
完整範例
TypeScript
const workbook: IWorkbookData = { id: 'gyI0JO', sheetOrder: [ 'RSfWjJFv4opmE1JaiRj80', ], name: '', appVersion: '0.10.2', locale: 'zhCN', styles: {}, sheets: { RSfWjJFv4opmE1JaiRj80: { id: 'RSfWjJFv4opmE1JaiRj80', name: '測試', 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: '', }, ],}你覺得這篇文檔如何?