quickspeadsheet 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,415 @@
1
+ /**
2
+ * ExcelIO 类型定义 - 对齐 gc.spread.excelio API
3
+ */
4
+
5
+ export const ErrorCode: {
6
+ fileIOError: 0
7
+ fileFormatError: 1
8
+ noPassword: 2
9
+ invalidPassword: 3
10
+ }
11
+
12
+ export interface ExcelIOError {
13
+ errorCode: number
14
+ errorMessage: string
15
+ fileName?: string
16
+ }
17
+
18
+ export interface ExcelIOOpenOptions {
19
+ /** 密码(加密文件) */
20
+ password?: string
21
+ /** 0=DataURL, 1=ArrayBuffer,默认 1 */
22
+ loadType?: 0 | 1
23
+ /** 仅解析指定 sheet 索引,如 [0, 1] */
24
+ parseSheets?: number[]
25
+ /** 每个 sheet 最多解析行数 */
26
+ maxRows?: number
27
+ /** 加载进度回调 (loaded, total) */
28
+ onProgress?: (loaded: number, total: number) => void
29
+ /** 调试模式,输出解析阶段与耗时 */
30
+ debug?: boolean
31
+ /** 延迟解析 preservedFiles,首次 save 时从 zip 按需加载,降低大文件内存占用,默认 true */
32
+ lazyPreservedFiles?: boolean
33
+ /** 仅校验结构不解析数据,快速检测损坏文件,返回 ValidateResult */
34
+ validateOnly?: boolean
35
+ /** 打开时预计算公式值,将结果写入单元格 v(依赖 formulaEngine 支持的函数) */
36
+ precomputeFormulas?: boolean
37
+ /** 加密文件解密时使用 Web Worker,避免 PBKDF2 阻塞主线程(需浏览器支持 Worker) */
38
+ useWorkerForDecrypt?: boolean
39
+ /** Worker 中对 worksheet 使用 SAX/token 解析(大文件建议开启) */
40
+ useSaxWorksheetParser?: boolean
41
+ /** worksheet SAX 解析批大小,默认 1000 */
42
+ rowBatchSize?: number
43
+ /**
44
+ * Worker 将大表 `sheet.data` 流式 post 到主线程时每块行数(仅 dataLength 超过该值时分块)。
45
+ * 更大可减少 `onmessage` 与 structured clone 次数;过大可能抬高单次克隆峰值。默认 40000,范围约 2000~120000。
46
+ */
47
+ sheetPostChunkRows?: number
48
+ /**
49
+ * 每条主线程消息合并几个行数据分片(`sheet_chunks`),降低 `worker.onmessage` 调度开销。
50
+ * 默认 3;可设 1 关闭合并;最大 16。与 `sheetPostChunkRows` 同时调大时注意单次克隆内存峰值。
51
+ */
52
+ sheetChunksPerPost?: number
53
+ /** Worker 路径下跳过大段 XML 序列化回填,降低峰值内存 */
54
+ skipXmlSerializationInWorker?: boolean
55
+ /** 开发调试:对比 SAX 与 DOM 解析结果字段差异(Worker progress: worksheet_sax_diff) */
56
+ debugWorksheetSaxDiff?: boolean
57
+ }
58
+
59
+ export interface ValidateResult {
60
+ valid: true
61
+ sheetCount: number
62
+ sheetNames: string[]
63
+ /** OPC:与完整解析结果中字段一致 */
64
+ workbookPartPath?: string
65
+ officeDocumentTarget?: string | null
66
+ }
67
+
68
+ /** OOXML c:spPr 简化结构(parseChart / buildChartXml 对齐) */
69
+ export interface ChartSpPrJson {
70
+ noFill?: boolean
71
+ fillColor?: string
72
+ fillSchemeClr?: string
73
+ [key: string]: unknown
74
+ }
75
+
76
+ export interface ChartAxisTitleJson {
77
+ text?: string
78
+ spPr?: ChartSpPrJson
79
+ txPr?: unknown
80
+ layout?: unknown
81
+ [key: string]: unknown
82
+ }
83
+
84
+ /** parseAxis / parseAxisFallback 输出的轴(catAx、valAx、dateAx、serAx) */
85
+ export interface ChartAxisJson {
86
+ axisType?: 'cat' | 'val' | 'date' | 'ser' | string
87
+ axId?: number
88
+ axPos?: string
89
+ crossAx?: number
90
+ crosses?: string
91
+ crossesAt?: number
92
+ crossBetween?: string
93
+ scaling?: unknown
94
+ numFmt?: { formatCode?: string; sourceLinked?: boolean }
95
+ title?: ChartAxisTitleJson
96
+ delete?: boolean
97
+ majorGridlines?: boolean
98
+ minorGridlines?: boolean
99
+ lblOffset?: number
100
+ majorTickMark?: string
101
+ minorTickMark?: string
102
+ tickLblPos?: string
103
+ [key: string]: unknown
104
+ }
105
+
106
+ /** c:legend(与 parseLegend / buildLegendXml 对齐) */
107
+ export interface ChartLegendJson {
108
+ pos?: string
109
+ overlay?: boolean
110
+ layout?: unknown
111
+ spPr?: ChartSpPrJson
112
+ txPr?: unknown
113
+ [key: string]: unknown
114
+ }
115
+
116
+ /** c:dTable(绘图区数据表,ECMA-376 CT_DTable) */
117
+ export interface ChartDataTableJson {
118
+ showHorzBorder?: boolean
119
+ showVertBorder?: boolean
120
+ showOutline?: boolean
121
+ showKeys?: boolean
122
+ spPr?: ChartSpPrJson
123
+ txPr?: unknown
124
+ [key: string]: unknown
125
+ }
126
+
127
+ export interface ChartSeriesErrBarsJson {
128
+ errBarType?: string
129
+ errValType?: string
130
+ errDir?: string
131
+ noEndCap?: boolean
132
+ val?: number
133
+ plus?: number[]
134
+ minus?: number[]
135
+ plusFormula?: string
136
+ minusFormula?: string
137
+ plusNumFmt?: { formatCode?: string }
138
+ minusNumFmt?: { formatCode?: string }
139
+ spPr?: ChartSpPrJson
140
+ [key: string]: unknown
141
+ }
142
+
143
+ /** parseChart 输出的单张图表 JSON(字段随类型扩展,未列出的仍可能存在) */
144
+ export interface WorkbookChartJson {
145
+ chartType?: string | null
146
+ title?: unknown
147
+ legend?: ChartLegendJson
148
+ chartStyleId?: number
149
+ /** chartSpace / c:lang @val(BCP 47) */
150
+ lang?: string
151
+ /** c:chart / c:roundedCorners */
152
+ roundedCorners?: boolean
153
+ /** 与 plotArea.dataTable 等价入口(写 chart 时若 plotArea 未带 dataTable 则用此项) */
154
+ dataTable?: ChartDataTableJson
155
+ /** 与 plotArea.axes 同一引用(多轴、写回 buildChartXml) */
156
+ axes?: ChartAxisJson[]
157
+ /** chartSpace 直接子级 c:spPr(在 c:chart 之后等) */
158
+ chartSpaceSpPr?: ChartSpPrJson
159
+ /** c:chart 下 c:spPr */
160
+ chartSpPr?: ChartSpPrJson
161
+ /** 自 charts/_rels/chartN.xml.rels 解析的 chartColorStyle 关系(如 colorsN.xml) */
162
+ chartColorStyleRel?: {
163
+ rId?: string
164
+ relationshipType?: string
165
+ target?: string
166
+ targetMode?: string
167
+ [key: string]: unknown
168
+ }
169
+ /** 自 chart .rels 解析的 chartStyle 关系(如 styleN.xml,不含 chartColorStyle) */
170
+ chartStyleRel?: {
171
+ rId?: string
172
+ relationshipType?: string
173
+ target?: string
174
+ targetMode?: string
175
+ [key: string]: unknown
176
+ }
177
+ /** 自包内读入的 colorsN.xml 全文(回写时优先于占位 XML) */
178
+ chartColorStyleXml?: string
179
+ /** 自包内读入的 styleN.xml 全文 */
180
+ chartStyleXml?: string
181
+ /** chartSpace / c:externalData;保存时 workbookJsonToZip 会写 charts/_rels/chartN.xml.rels */
182
+ externalData?: {
183
+ rId?: string
184
+ autoUpdate?: boolean
185
+ /** 默认 officeDocument;外链可设 hyperlink 等 */
186
+ relationshipType?: string
187
+ /** 相对 chart 部件的 Target;缺省按 workbookPartPath 算到主 workbook */
188
+ target?: string
189
+ targetMode?: string
190
+ [key: string]: unknown
191
+ }
192
+ chartGroups?: unknown[]
193
+ dLbls?: unknown
194
+ dispBlanksAs?: string
195
+ view3D?: unknown
196
+ /** 部分属性自 plotArea 主图组同步到根级 */
197
+ wireframe?: boolean
198
+ radarStyle?: string
199
+ /** 首图组 c:dropLines / c:hiLowLines / c:upDownBars(与 parseChartGroupProps 一致) */
200
+ dropLines?: { spPr?: ChartSpPrJson; [key: string]: unknown }
201
+ hiLowLines?: { spPr?: ChartSpPrJson; [key: string]: unknown }
202
+ upDownBars?: {
203
+ gapWidth?: number
204
+ upBars?: { spPr?: ChartSpPrJson; [key: string]: unknown }
205
+ downBars?: { spPr?: ChartSpPrJson; [key: string]: unknown }
206
+ [key: string]: unknown
207
+ }
208
+ plotArea?: {
209
+ chartType?: string | null
210
+ radarStyle?: string
211
+ wireframe?: boolean
212
+ series?: unknown[]
213
+ axes?: ChartAxisJson[]
214
+ catAx?: ChartAxisJson | null
215
+ valAx?: ChartAxisJson | null
216
+ dateAx?: ChartAxisJson | null
217
+ serAx?: ChartAxisJson | null
218
+ spPr?: ChartSpPrJson
219
+ dataTable?: ChartDataTableJson
220
+ layout?: unknown
221
+ chartGroups?: unknown[]
222
+ [key: string]: unknown
223
+ } | null
224
+ series?: Array<{
225
+ idx?: number
226
+ order?: number
227
+ name?: string | null
228
+ catFormula?: string | null
229
+ valFormula?: string | null
230
+ errBars?: ChartSeriesErrBarsJson
231
+ [key: string]: unknown
232
+ }>
233
+ [key: string]: unknown
234
+ }
235
+
236
+ /** calcChain.xml 中 `<c>` 项(`r` 为单元格引用;`i`/`l`/`s` 为 ECMA-376 可选整数属性) */
237
+ export interface CalcChainCell {
238
+ r: string
239
+ i?: number
240
+ l?: number
241
+ s?: number
242
+ }
243
+
244
+ /** `parseCalcChain` / `buildCalcChainXml` 使用的结构化模型(与 `ooxml/calcChain.js` 一致) */
245
+ export interface CalcChainParsed {
246
+ cells: CalcChainCell[]
247
+ }
248
+
249
+ export interface ExcelIOSaveOptions {
250
+ /** 保存时加密密码 */
251
+ password?: string
252
+ /** true 时返回 ArrayBuffer,false 时返回 Blob;未指定时在无 Blob 环境(如旧版 Node)自动用 ArrayBuffer */
253
+ useArrayBuffer?: boolean
254
+ /** 压缩级别 0-9,大文件可降低以加快保存 */
255
+ compressionLevel?: number
256
+ /** 是否使用 Web Worker 执行保存(默认 true;失败会自动回退主线程) */
257
+ useWorker?: boolean
258
+ }
259
+
260
+ export interface WorkbookJson {
261
+ version?: string
262
+ sheets: SheetJson[]
263
+ stylesXml?: string
264
+ /** x14:slicerStyles 从 styles extLst 提取(显式访问) */
265
+ slicerStylesXml?: string
266
+ /** x14:slicerStyles 结构化解析 { defaultSlicerStyle, styles: [{ name, styleElements }] } */
267
+ slicerStyles?: { defaultSlicerStyle: string; styles: Array<{ name: string; styleElements?: Array<{ type: string; dxfId: string }> }> }
268
+ themeXml?: string
269
+ themeColors?: Record<string, string>
270
+ themeFonts?: { name?: string; majorFont?: { latin?: string }; minorFont?: { latin?: string } }
271
+ sharedStringsItems?: unknown[]
272
+ preservedFiles?: Record<string, string>
273
+ preservedRootRels?: string
274
+ /** 图表结构化解析(P3-10,key 为 `{spreadsheetRoot}/charts/chartN.xml` 形式包内路径) */
275
+ charts?: Record<string, WorkbookChartJson>
276
+ preservedWbRels?: string
277
+ /** workbook 级关联部件(externalLinks/connections/pivotCache/calcChain 等) */
278
+ workbookLinkedParts?: Array<{
279
+ relId: string
280
+ type: string
281
+ path: string
282
+ xml: string | null
283
+ parsed?: CalcChainParsed
284
+ }>
285
+ externalLinks?: Array<{ relId: string; type: string; path: string; xml: string | null }>
286
+ connections?: Array<{ relId: string; type: string; path: string; xml: string | null }>
287
+ queryTables?: Array<{ relId: string; type: string; path: string; xml: string | null }>
288
+ pivotCaches?: Array<{ relId: string; type: string; path: string; xml: string | null }>
289
+ pivotCacheRecords?: Array<{ relId: string; type: string; path: string; xml: string | null }>
290
+ pivotTables?: Array<{ relId: string; type: string; path: string; xml: string | null }>
291
+ slicerCaches?: Array<{ relId: string; type: string; path: string; xml: string | null }>
292
+ pivotCacheDefinitions?: Array<{ relId: string; type: string; path: string; xml: string | null; parsed?: Record<string, unknown> }>
293
+ pivotCacheRecordDefinitions?: Array<{ relId: string; type: string; path: string; xml: string | null; parsed?: Record<string, unknown> }>
294
+ pivotTableDefinitions?: Array<{ relId: string; type: string; path: string; xml: string | null; parsed?: Record<string, unknown> }>
295
+ slicerCacheDefinitions?: Array<{ relId: string; type: string; path: string; xml: string | null; parsed?: Record<string, unknown> }>
296
+ externalLinkDefinitions?: Array<{ relId: string; type: string; path: string; xml: string | null; parsed?: Record<string, unknown> }>
297
+ connectionDefinitions?: Array<{ relId: string; type: string; path: string; xml: string | null; parsed?: Record<string, unknown> }>
298
+ queryTableDefinitions?: Array<{ relId: string; type: string; path: string; xml: string | null; parsed?: Record<string, unknown> }>
299
+ /**
300
+ * calcChain 部件快捷引用(与 `workbookLinkedParts` 中 calcChain 项宜为同一引用)。
301
+ * 保存前可将顶层的 `parsed` / `xml` 合并进 linkedParts:`mergeTopLevelCalcChainIntoWorkbookLinkedParts(json)`(与 ExcelIO 内部一致)。
302
+ */
303
+ calcChain?: {
304
+ relId: string
305
+ type: string
306
+ path: string
307
+ xml: string | null
308
+ parsed?: CalcChainParsed
309
+ } | null
310
+ workbookPr?: Record<string, unknown>
311
+ workbookExtLstXml?: string
312
+ wbPassthrough?: string
313
+ customProperties?: Array<{ name: string; value: string }>
314
+ definedNames?: Array<{ name: string; formula: string; localSheetId?: number }>
315
+ bookViews?: unknown
316
+ calcPr?: unknown
317
+ [key: string]: unknown
318
+ }
319
+
320
+ export interface SheetJson {
321
+ name: string
322
+ data: Record<number, Record<number, CellValue>>
323
+ spans?: Array<{ row: number; col: number; rowCount: number; colCount: number }>
324
+ visible?: boolean
325
+ state?: string
326
+ rId?: string
327
+ sheetId?: number
328
+ uuid?: string
329
+ rowMeta?: Record<number, { hidden?: boolean; ht?: number; outlineLevel?: number; collapsed?: boolean; resizable?: boolean }>
330
+ colMeta?: Record<number, { width?: number; hidden?: boolean; outlineLevel?: number; collapsed?: boolean; resizable?: boolean }>
331
+ preservedWorksheetXml?: string
332
+ preservedWsRels?: string
333
+ /** autoFilter 结构化(ref、filterColumns) */
334
+ autoFilter?: { ref: string; filterColumns?: Array<{ colId: number; filtersXml?: string; customFiltersXml?: string }>; sortState?: unknown }
335
+ /** sortState 结构化(ref、sortConditions) */
336
+ sortState?: { ref: string; columnSort?: boolean; caseSensitive?: boolean; sortMethod?: string; sortConditions?: Array<{ ref?: string; descending?: boolean; sortType?: string }> }
337
+ /** 绘图 shapes(P3-11 解析 xdr:twoCellAnchor 等) */
338
+ shapes?: Array<{
339
+ type: string
340
+ anchorType: string
341
+ from: { col: number; row: number; colOff: number; rowOff: number }
342
+ to?: { col: number; row: number; colOff: number; rowOff: number }
343
+ ext?: { cx: number; cy: number }
344
+ element?: string
345
+ editAs?: string | null
346
+ innerXml?: string
347
+ }>
348
+ /** 切片器结构化(解析 sle:slicers) */
349
+ slicers?: Array<{ name?: string; cache?: string; caption?: string; columnCount?: number; style?: string; cachePath?: string; [key: string]: unknown }>
350
+ /** worksheet 级 pivot table parts 原始 XML */
351
+ pivotTablePartsXml?: string
352
+ /** worksheet 级 pivot table 定义(来自 sheet rels) */
353
+ pivotTables?: Array<{ relId?: string; type?: string; path?: string; xml?: string | null; parsed?: Record<string, unknown> }>
354
+ /** worksheet 级 query table 定义(来自 sheet rels) */
355
+ queryTables?: Array<{ relId?: string; type?: string; path?: string; xml?: string | null; parsed?: Record<string, unknown> }>
356
+ /** 表结构化(解析 `{spreadsheetRoot}/tables/tableN.xml`) */
357
+ tables?: Array<{
358
+ id?: number
359
+ name?: string
360
+ displayName?: string
361
+ ref: string
362
+ headerRowCount?: number
363
+ totalsRowCount?: number
364
+ totalsRowShown?: boolean
365
+ columns?: Array<{ id?: number; name: string; totalsRowLabel?: string; totalsRowFunction?: string }>
366
+ style?: {
367
+ name?: string
368
+ showFirstColumn?: boolean
369
+ showLastColumn?: boolean
370
+ showRowStripes?: boolean
371
+ showColumnStripes?: boolean
372
+ }
373
+ autoFilter?: { ref?: string; xml?: string }
374
+ path?: string
375
+ }>
376
+ [key: string]: unknown
377
+ }
378
+
379
+ export interface CellValue {
380
+ v?: string | number | { _error?: string; _code?: number }
381
+ f?: string
382
+ styleId?: number
383
+ comment?: string | { text: string; textRunsXml?: string; authorId?: number }
384
+ hyperlink?: string
385
+ [key: string]: unknown
386
+ }
387
+
388
+ export class ExcelIO {
389
+ open(
390
+ file: string | Blob | ArrayBuffer | File,
391
+ successCallback: (workbookJson: WorkbookJson) => void,
392
+ errorCallback: (error: ExcelIOError) => void,
393
+ options?: ExcelIOOpenOptions
394
+ ): void
395
+
396
+ openAsync(file: string | Blob | ArrayBuffer | File, options?: ExcelIOOpenOptions): Promise<WorkbookJson | ValidateResult>
397
+
398
+ save(
399
+ workbookJson: WorkbookJson | string,
400
+ successCallback: (out: Blob | ArrayBuffer) => void,
401
+ errorCallback: (error: ExcelIOError) => void,
402
+ options?: ExcelIOSaveOptions
403
+ ): void
404
+
405
+ saveAsync(workbookJson: WorkbookJson | string, options?: ExcelIOSaveOptions): Promise<Blob | ArrayBuffer>
406
+ }
407
+
408
+ export interface CreateExcelIOOptions {
409
+ /** true 时仅支持 open,save 将报错 */
410
+ readOnly?: boolean
411
+ }
412
+
413
+ export function createExcelIO(options?: CreateExcelIOOptions): ExcelIO
414
+
415
+ export function getCommentDisplayText(comment: string | { text?: string } | null | undefined): string
@@ -0,0 +1,33 @@
1
+ export * from './types/spread'
2
+
3
+ export type { Workbook, Worksheet, Cell } from './types/spread'
4
+
5
+ export type {
6
+ ApplyRemoteOperationsResult,
7
+ CollaborationHistoryVersionsPage,
8
+ CollaborationJsonRecord,
9
+ CollaborationServicesConfig,
10
+ CollaborationSessionLike,
11
+ CollaborationStateSnapshot,
12
+ ConnectDocumentInput,
13
+ ExcelIO,
14
+ FormulaBoxInstance,
15
+ HostActionMissingPayload,
16
+ HostActionReturn,
17
+ PublishOperationsResult,
18
+ RemoteReplayReportInput,
19
+ RemoteReplayReportResult,
20
+ ResolveConflictInput,
21
+ RuntimeAddInDefinition,
22
+ RuntimeDownloadRequest,
23
+ RuntimeImportFileResult,
24
+ RuntimeImportUrlResult,
25
+ RuntimeIoHooks,
26
+ SpreadExtensionHostLike,
27
+ SpreadLicenseSnapshot,
28
+ SpreadRuntime,
29
+ SpreadRuntimeHostActions,
30
+ SpreadRuntimeOptions,
31
+ SpreadWorkbookInstance,
32
+ SpreadWorkbookOpcPackageFields,
33
+ } from './runtime-public'
@@ -0,0 +1,10 @@
1
+ export * from './index'
2
+
3
+ export declare const proEditionPlugin: {
4
+ install(app: any, options?: Record<string, any>): any
5
+ }
6
+
7
+ export declare const install: typeof proEditionPlugin.install
8
+
9
+ declare const _default: typeof proEditionPlugin
10
+ export default _default