@justybase/spreadsheet-tasks 1.3.2 → 2.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +25 -16
  3. package/browser/browser-spreadsheet.js +3037 -0
  4. package/browser/justybase-spreadsheet.min.js +36 -0
  5. package/dist/cjs/index.d.ts +399 -0
  6. package/dist/cjs/index.js +3944 -0
  7. package/dist/cjs/index.js.map +1 -0
  8. package/dist/esm/index.js +3889 -0
  9. package/dist/esm/index.js.map +1 -0
  10. package/dist/esm/package.json +1 -0
  11. package/docs/API.md +8 -9
  12. package/docs/PACKAGING.md +32 -0
  13. package/docs/PUBLISHING.md +8 -1
  14. package/examples/basic-read.ts +1 -1
  15. package/examples/formats-verify.ts +1 -2
  16. package/examples/large-dataset.ts +1 -1
  17. package/package.json +29 -14
  18. package/dist/BiffReaderWriter.d.ts +0 -44
  19. package/dist/BiffReaderWriter.d.ts.map +0 -1
  20. package/dist/BiffReaderWriter.js +0 -282
  21. package/dist/BiffReaderWriter.js.map +0 -1
  22. package/dist/BigBuffer.d.ts +0 -24
  23. package/dist/BigBuffer.d.ts.map +0 -1
  24. package/dist/BigBuffer.js +0 -120
  25. package/dist/BigBuffer.js.map +0 -1
  26. package/dist/ExcelReaderAbstract.d.ts +0 -17
  27. package/dist/ExcelReaderAbstract.d.ts.map +0 -1
  28. package/dist/ExcelReaderAbstract.js +0 -25
  29. package/dist/ExcelReaderAbstract.js.map +0 -1
  30. package/dist/Formats.d.ts +0 -34
  31. package/dist/Formats.d.ts.map +0 -1
  32. package/dist/Formats.js +0 -48
  33. package/dist/Formats.js.map +0 -1
  34. package/dist/ReaderFactory.d.ts +0 -6
  35. package/dist/ReaderFactory.d.ts.map +0 -1
  36. package/dist/ReaderFactory.js +0 -56
  37. package/dist/ReaderFactory.js.map +0 -1
  38. package/dist/XlsbReader.d.ts +0 -24
  39. package/dist/XlsbReader.d.ts.map +0 -1
  40. package/dist/XlsbReader.js +0 -186
  41. package/dist/XlsbReader.js.map +0 -1
  42. package/dist/XlsbWriter.d.ts +0 -80
  43. package/dist/XlsbWriter.d.ts.map +0 -1
  44. package/dist/XlsbWriter.js +0 -964
  45. package/dist/XlsbWriter.js.map +0 -1
  46. package/dist/XlsxReader.d.ts +0 -30
  47. package/dist/XlsxReader.d.ts.map +0 -1
  48. package/dist/XlsxReader.js +0 -341
  49. package/dist/XlsxReader.js.map +0 -1
  50. package/dist/XlsxWriter.d.ts +0 -51
  51. package/dist/XlsxWriter.d.ts.map +0 -1
  52. package/dist/XlsxWriter.js +0 -632
  53. package/dist/XlsxWriter.js.map +0 -1
  54. package/dist/index.d.ts +0 -10
  55. package/dist/index.d.ts.map +0 -1
  56. package/dist/index.js +0 -29
  57. package/dist/index.js.map +0 -1
@@ -0,0 +1,3037 @@
1
+ // src/browser/BrowserBigBuffer.ts
2
+ var BrowserBigBuffer = class {
3
+ /**
4
+ * @param {number} [chunkSize=65536]
5
+ */
6
+ constructor(chunkSize = 65536) {
7
+ this.chunkSize = chunkSize;
8
+ this.chunks = [];
9
+ this.currentBuffer = new Uint8Array(chunkSize);
10
+ this.dataView = new DataView(this.currentBuffer.buffer);
11
+ this.cursor = 0;
12
+ this._textEncoder = new TextEncoder();
13
+ }
14
+ /**
15
+ * @param {number} size
16
+ */
17
+ ensureCapacity(size) {
18
+ if (this.cursor + size > this.chunkSize) {
19
+ this._flush();
20
+ }
21
+ }
22
+ _flush() {
23
+ if (this.cursor > 0) {
24
+ this.chunks.push(this.currentBuffer.slice(0, this.cursor));
25
+ this.currentBuffer = new Uint8Array(this.chunkSize);
26
+ this.dataView = new DataView(this.currentBuffer.buffer);
27
+ this.cursor = 0;
28
+ }
29
+ }
30
+ /**
31
+ * Write a Uint8Array to the buffer.
32
+ * @param {Uint8Array} buffer
33
+ */
34
+ write(buffer) {
35
+ let len = buffer.length;
36
+ let offset = 0;
37
+ while (len > 0) {
38
+ let available = this.chunkSize - this.cursor;
39
+ if (available === 0) {
40
+ this._flush();
41
+ available = this.chunkSize;
42
+ }
43
+ const toWrite = Math.min(len, available);
44
+ this.currentBuffer.set(buffer.subarray(offset, offset + toWrite), this.cursor);
45
+ this.cursor += toWrite;
46
+ offset += toWrite;
47
+ len -= toWrite;
48
+ }
49
+ }
50
+ /**
51
+ * @param {number} val
52
+ */
53
+ writeByte(val) {
54
+ this.ensureCapacity(1);
55
+ this.currentBuffer[this.cursor] = val;
56
+ this.cursor++;
57
+ }
58
+ /**
59
+ * @param {number} val
60
+ */
61
+ writeUnsafeByte(val) {
62
+ this.currentBuffer[this.cursor++] = val;
63
+ }
64
+ /**
65
+ * @param {number} val
66
+ */
67
+ writeInt32LE(val) {
68
+ this.ensureCapacity(4);
69
+ this.dataView.setInt32(this.cursor, val, true);
70
+ this.cursor += 4;
71
+ }
72
+ /**
73
+ * @param {number} val
74
+ */
75
+ writeUnsafeInt32LE(val) {
76
+ this.dataView.setInt32(this.cursor, val, true);
77
+ this.cursor += 4;
78
+ }
79
+ /**
80
+ * @param {number} val
81
+ */
82
+ writeDoubleLE(val) {
83
+ this.ensureCapacity(8);
84
+ this.dataView.setFloat64(this.cursor, val, true);
85
+ this.cursor += 8;
86
+ }
87
+ /**
88
+ * @param {number} val
89
+ */
90
+ writeUnsafeDoubleLE(val) {
91
+ this.dataView.setFloat64(this.cursor, val, true);
92
+ this.cursor += 8;
93
+ }
94
+ /**
95
+ * Write a UTF-8 string.
96
+ * @param {string} str
97
+ */
98
+ writeString(str) {
99
+ const encoded = this._textEncoder.encode(str);
100
+ const byteLength = encoded.length;
101
+ if (this.cursor + byteLength <= this.chunkSize) {
102
+ this.currentBuffer.set(encoded, this.cursor);
103
+ this.cursor += byteLength;
104
+ return;
105
+ }
106
+ this._flush();
107
+ if (byteLength > this.chunkSize) {
108
+ this.chunks.push(encoded);
109
+ } else {
110
+ this.currentBuffer.set(encoded, this.cursor);
111
+ this.cursor += byteLength;
112
+ }
113
+ }
114
+ /**
115
+ * Write a string as UTF-16LE.
116
+ * @param {string} str
117
+ */
118
+ writeUtf16LE(str) {
119
+ const byteLength = str.length * 2;
120
+ if (this.cursor + byteLength <= this.chunkSize) {
121
+ for (let i = 0; i < str.length; i++) {
122
+ const code = str.charCodeAt(i);
123
+ this.currentBuffer[this.cursor++] = code & 255;
124
+ this.currentBuffer[this.cursor++] = code >> 8 & 255;
125
+ }
126
+ return;
127
+ }
128
+ this._flush();
129
+ if (byteLength > this.chunkSize) {
130
+ const buf = new Uint8Array(byteLength);
131
+ for (let i = 0; i < str.length; i++) {
132
+ const code = str.charCodeAt(i);
133
+ buf[i * 2] = code & 255;
134
+ buf[i * 2 + 1] = code >> 8 & 255;
135
+ }
136
+ this.chunks.push(buf);
137
+ } else {
138
+ for (let i = 0; i < str.length; i++) {
139
+ const code = str.charCodeAt(i);
140
+ this.currentBuffer[this.cursor++] = code & 255;
141
+ this.currentBuffer[this.cursor++] = code >> 8 & 255;
142
+ }
143
+ }
144
+ }
145
+ /**
146
+ * Flush and return all chunks.
147
+ * @returns {Uint8Array[]}
148
+ */
149
+ getChunks() {
150
+ if (this.cursor > 0) {
151
+ this.chunks.push(this.currentBuffer.slice(0, this.cursor));
152
+ this.currentBuffer = new Uint8Array(this.chunkSize);
153
+ this.dataView = new DataView(this.currentBuffer.buffer);
154
+ this.cursor = 0;
155
+ }
156
+ return this.chunks;
157
+ }
158
+ /**
159
+ * Concatenate all chunks into a single Uint8Array.
160
+ * @returns {Uint8Array}
161
+ */
162
+ toUint8Array() {
163
+ const chunks = this.getChunks();
164
+ let totalLen = 0;
165
+ for (const c of chunks) totalLen += c.length;
166
+ const result = new Uint8Array(totalLen);
167
+ let offset = 0;
168
+ for (const c of chunks) {
169
+ result.set(c, offset);
170
+ offset += c.length;
171
+ }
172
+ return result;
173
+ }
174
+ reset() {
175
+ this.chunks = [];
176
+ this.cursor = 0;
177
+ }
178
+ };
179
+
180
+ // src/browser/BrowserZip.ts
181
+ var BrowserZip = class _BrowserZip {
182
+ constructor() {
183
+ this.files = [];
184
+ }
185
+ /**
186
+ * Add a file entry (string or Uint8Array).
187
+ * @param {string} name - Path inside the ZIP (e.g. "xl/workbook.xml")
188
+ * @param {string | Uint8Array | Uint8Array[]} data - File contents
189
+ */
190
+ addFile(name, data) {
191
+ let bytes;
192
+ if (typeof data === "string") {
193
+ bytes = new TextEncoder().encode(data);
194
+ } else if (Array.isArray(data)) {
195
+ let totalLen = 0;
196
+ for (const c of data) totalLen += c.length;
197
+ bytes = new Uint8Array(totalLen);
198
+ let offset = 0;
199
+ for (const c of data) {
200
+ bytes.set(c, offset);
201
+ offset += c.length;
202
+ }
203
+ } else {
204
+ bytes = data;
205
+ }
206
+ this.files.push({ name, data: bytes });
207
+ }
208
+ /**
209
+ * Generate the ZIP file as a Blob.
210
+ * @returns {Blob}
211
+ */
212
+ toBlob() {
213
+ const parts = [];
214
+ const centralDir = [];
215
+ let localOffset = 0;
216
+ for (const file of this.files) {
217
+ const nameBytes = new TextEncoder().encode(file.name);
218
+ const crc = this._crc32(file.data);
219
+ const localHeader = new Uint8Array(30 + nameBytes.length);
220
+ const lhView = new DataView(localHeader.buffer);
221
+ lhView.setUint32(0, 67324752, true);
222
+ lhView.setUint16(4, 20, true);
223
+ lhView.setUint16(6, 0, true);
224
+ lhView.setUint16(8, 0, true);
225
+ lhView.setUint16(10, 0, true);
226
+ lhView.setUint16(12, 0, true);
227
+ lhView.setUint32(14, crc, true);
228
+ lhView.setUint32(18, file.data.length, true);
229
+ lhView.setUint32(22, file.data.length, true);
230
+ lhView.setUint16(26, nameBytes.length, true);
231
+ lhView.setUint16(28, 0, true);
232
+ localHeader.set(nameBytes, 30);
233
+ parts.push(localHeader);
234
+ parts.push(file.data);
235
+ const cdEntry = new Uint8Array(46 + nameBytes.length);
236
+ const cdView = new DataView(cdEntry.buffer);
237
+ cdView.setUint32(0, 33639248, true);
238
+ cdView.setUint16(4, 20, true);
239
+ cdView.setUint16(6, 20, true);
240
+ cdView.setUint16(8, 0, true);
241
+ cdView.setUint16(10, 0, true);
242
+ cdView.setUint16(12, 0, true);
243
+ cdView.setUint16(14, 0, true);
244
+ cdView.setUint32(16, crc, true);
245
+ cdView.setUint32(20, file.data.length, true);
246
+ cdView.setUint32(24, file.data.length, true);
247
+ cdView.setUint16(28, nameBytes.length, true);
248
+ cdView.setUint16(30, 0, true);
249
+ cdView.setUint16(32, 0, true);
250
+ cdView.setUint16(34, 0, true);
251
+ cdView.setUint16(36, 0, true);
252
+ cdView.setUint32(38, 0, true);
253
+ cdView.setUint32(42, localOffset, true);
254
+ cdEntry.set(nameBytes, 46);
255
+ centralDir.push(cdEntry);
256
+ localOffset += localHeader.length + file.data.length;
257
+ }
258
+ const cdStartOffset = localOffset;
259
+ let cdSize = 0;
260
+ for (const entry of centralDir) {
261
+ parts.push(entry);
262
+ cdSize += entry.length;
263
+ }
264
+ const eocd = new Uint8Array(22);
265
+ const eocdView = new DataView(eocd.buffer);
266
+ eocdView.setUint32(0, 101010256, true);
267
+ eocdView.setUint16(4, 0, true);
268
+ eocdView.setUint16(6, 0, true);
269
+ eocdView.setUint16(8, this.files.length, true);
270
+ eocdView.setUint16(10, this.files.length, true);
271
+ eocdView.setUint32(12, cdSize, true);
272
+ eocdView.setUint32(16, cdStartOffset, true);
273
+ eocdView.setUint16(20, 0, true);
274
+ parts.push(eocd);
275
+ return new Blob(parts, { type: "application/octet-stream" });
276
+ }
277
+ /**
278
+ * CRC-32 calculation.
279
+ * @param {Uint8Array} data
280
+ * @returns {number}
281
+ */
282
+ _crc32(data) {
283
+ if (!_BrowserZip._crc32Table) {
284
+ _BrowserZip._crc32Table = new Uint32Array(256);
285
+ for (let i = 0; i < 256; i++) {
286
+ let c = i;
287
+ for (let j = 0; j < 8; j++) {
288
+ c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
289
+ }
290
+ _BrowserZip._crc32Table[i] = c;
291
+ }
292
+ }
293
+ const table = _BrowserZip._crc32Table;
294
+ let crc = 4294967295;
295
+ for (let i = 0; i < data.length; i++) {
296
+ crc = table[(crc ^ data[i]) & 255] ^ crc >>> 8;
297
+ }
298
+ return (crc ^ 4294967295) >>> 0;
299
+ }
300
+ };
301
+ BrowserZip._crc32Table = null;
302
+
303
+ // src/Formats.ts
304
+ var F = {
305
+ THOUSANDS_SEP: "#,##0",
306
+ CURRENCY_PLN: '#,##0.00 "z\u0142"',
307
+ CURRENCY_EUR: "#,##0.00 \u20AC",
308
+ PERCENTAGE: "0%",
309
+ SCIENTIFIC: "0.00E+00",
310
+ TWO_DECIMALS: "#,##0.00",
311
+ TEXT: "@",
312
+ LEADING_ZEROS: "000000000",
313
+ DATE_SHORT: "dd.mm.yyyy",
314
+ DATE_LONG: "d mmmm yyyy",
315
+ DATE_DAY_MONTH_YEAR: "dd-mm-yyyy",
316
+ DATE_ISO: "yyyy-mm-dd",
317
+ DATE_MONTH_YEAR: "mmmm yyyy",
318
+ DATE_WEEKDAY: "dddd, d mmmm yyyy",
319
+ DATE_DAY_MONTH: "d mmmm",
320
+ DATE_YEAR_ONLY: "yyyy",
321
+ DATETIME_SHORT: "dd.mm.yyyy hh:mm",
322
+ DATETIME_LONG: "d mmmm yyyy hh:mm:ss",
323
+ TIME_HH_MM: "hh:mm",
324
+ TIME_HH_MM_SS: "hh:mm:ss",
325
+ TIME_12H: "h:mm AM/PM",
326
+ DATETIME_24H: "dd.mm.yyyy hh:mm:ss",
327
+ DATETIME_ISO: 'yyyy-mm-dd"T"hh:mm:ss',
328
+ TIME_MS: "hh:mm:ss.000"
329
+ };
330
+ function isFormattedCell(val) {
331
+ return val !== null && val !== void 0 && typeof val === "object" && "format" in val && typeof val.format === "string";
332
+ }
333
+ function unwrapCell(val) {
334
+ if (isFormattedCell(val)) {
335
+ return val.value;
336
+ }
337
+ return val;
338
+ }
339
+ function getFormat(val) {
340
+ if (isFormattedCell(val)) {
341
+ return val.format;
342
+ }
343
+ return null;
344
+ }
345
+
346
+ // src/browser/BrowserXlsxWriter.ts
347
+ var COL_LETTERS = (() => {
348
+ const l = [];
349
+ for (let i = 65; i < 91; i++) l.push(String.fromCharCode(i));
350
+ const t = [];
351
+ for (const p of l) for (let i = 65; i < 91; i++) t.push(p + String.fromCharCode(i));
352
+ l.push(...t);
353
+ return l;
354
+ })();
355
+ var BrowserXlsxWriter = class {
356
+ constructor() {
357
+ this._zip = new BrowserZip();
358
+ this._sc = 0;
359
+ this._sl = [];
360
+ this._sstA = [];
361
+ this._sstM = /* @__PURE__ */ new Map();
362
+ this._sstCnt = 0;
363
+ this._cw = [];
364
+ this._afOn = false;
365
+ this._oaE = Date.UTC(1899, 11, 30);
366
+ this._csb = null;
367
+ this._csrn = 0;
368
+ this._csSC = 0;
369
+ this._csEC = 0;
370
+ this._csAF = false;
371
+ this._isS = false;
372
+ this._csCL = [];
373
+ this._fmtReg = /* @__PURE__ */ new Map();
374
+ this._fmtXf = /* @__PURE__ */ new Map();
375
+ this._nextNfmt = 165;
376
+ this._nextXf = 6;
377
+ }
378
+ _cl(i) {
379
+ return i < COL_LETTERS.length ? COL_LETTERS[i] : "A";
380
+ }
381
+ _san(n) {
382
+ if (!n || typeof n !== "string") return `Sheet${this._sc + 1}`;
383
+ let s = n.replace(/[\\/*?[\]:]/g, "_");
384
+ if (s.length > 31) s = s.substring(0, 31);
385
+ if (!s.trim()) s = `Sheet${this._sc + 1}`;
386
+ return s;
387
+ }
388
+ _ex(s) {
389
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
390
+ }
391
+ _esc(s) {
392
+ if (typeof s !== "string") return s;
393
+ let need = false;
394
+ for (let i = 0; i < s.length; i++) {
395
+ const c = s.charCodeAt(i);
396
+ if (c === 38 || c === 60 || c === 62 || c === 34 || c === 39 || c >= 0 && c <= 8 || c === 11 || c === 12 || c >= 14 && c <= 31) {
397
+ need = true;
398
+ break;
399
+ }
400
+ }
401
+ if (!need) return s;
402
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;").replace(/[\x00-\x08\x0b\x0c\x0e-\x1f]/g, "");
403
+ }
404
+ _fmn(n) {
405
+ return /[\s\-+=()!@#$%^&]/.test(n) || /^[0-9]/.test(n) ? `'${n.replace(/'/g, "''")}'` : n;
406
+ }
407
+ addSheet(name, hidden = false) {
408
+ const sn = this._san(name);
409
+ this._sc++;
410
+ this._sl.push({ name: sn, path: `xl/worksheets/sheet${this._sc}.xml`, hidden, fn: `sheet${this._sc}.xml`, id: this._sc, rId: `rId${this._sc}`, fhr: null });
411
+ }
412
+ _wsc(bb, val, cr, rn, so) {
413
+ let idx = this._sstM.get(val);
414
+ if (idx === void 0) {
415
+ idx = this._sstA.length;
416
+ this._sstA.push(val);
417
+ this._sstM.set(val, idx);
418
+ }
419
+ this._sstCnt++;
420
+ const sa = so !== void 0 ? ` s="${so}"` : "";
421
+ bb.writeString(`<c r="${cr}${rn}" t="s"${sa}><v>${idx}</v></c>`);
422
+ }
423
+ _wscStyle(bb, val, cr, rn, styleId) {
424
+ let idx = this._sstM.get(val);
425
+ if (idx === void 0) {
426
+ idx = this._sstA.length;
427
+ this._sstA.push(val);
428
+ this._sstM.set(val, idx);
429
+ }
430
+ this._sstCnt++;
431
+ bb.writeString(`<c r="${cr}${rn}" t="s" s="${styleId}"><v>${idx}</v></c>`);
432
+ }
433
+ _oa(d) {
434
+ return (d.getTime() - this._oaE) / 864e5;
435
+ }
436
+ _regFmt(fs) {
437
+ if (this._fmtXf.has(fs)) return this._fmtXf.get(fs);
438
+ const nid = this._nextNfmt++;
439
+ this._fmtReg.set(fs, nid);
440
+ const xf = this._nextXf++;
441
+ this._fmtXf.set(fs, xf);
442
+ return xf;
443
+ }
444
+ _wcv(bb, raw, cr, rn) {
445
+ if (raw === null || raw === void 0) return;
446
+ const fs = getFormat(raw);
447
+ const v = fs !== null ? unwrapCell(raw) : raw;
448
+ const xf = fs !== null ? this._regFmt(fs) : -1;
449
+ const sa = xf >= 0 ? ` s="${xf}"` : "";
450
+ if (typeof v === "number") {
451
+ if (Number.isFinite(v)) bb.writeString(`<c r="${cr}${rn}"${sa}><v>${v}</v></c>`);
452
+ else this._wsc(bb, v.toString(), cr, rn, xf >= 0 ? xf : void 0);
453
+ } else if (typeof v === "bigint") this._wsc(bb, v.toString(), cr, rn, xf >= 0 ? xf : void 0);
454
+ else if (typeof v === "boolean") bb.writeString(`<c r="${cr}${rn}" t="b"${sa}><v>${v ? 1 : 0}</v></c>`);
455
+ else if (v instanceof Date) {
456
+ const o = this._oa(v);
457
+ if (Number.isFinite(o)) bb.writeString(`<c r="${cr}${rn}" s="${xf >= 0 ? xf : 1}"><v>${o}</v></c>`);
458
+ else this._wsc(bb, v.toString(), cr, rn, xf >= 0 ? xf : void 0);
459
+ } else this._wsc(bb, v.toString(), cr, rn, xf >= 0 ? xf : void 0);
460
+ }
461
+ _sheetHead(bb, cc, isFirst, hasAF) {
462
+ bb.writeString('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>');
463
+ bb.writeString('<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">');
464
+ bb.writeString('<dimension ref="A1"/>');
465
+ if (hasAF) bb.writeString(`<sheetViews><sheetView ${isFirst ? 'tabSelected="1" ' : ""}workbookViewId="0"><pane ySplit="1" topLeftCell="A2" activePane="bottomLeft" state="frozen"/><selection pane="bottomLeft"/></sheetView></sheetViews><sheetFormatPr defaultRowHeight="15"/>`);
466
+ else bb.writeString(`<sheetViews><sheetView ${isFirst ? 'tabSelected="1" ' : ""}workbookViewId="0"/></sheetViews><sheetFormatPr defaultRowHeight="15"/>`);
467
+ bb.writeString("<cols>");
468
+ for (let i = 0; i < cc; i++) {
469
+ const w = this._cw[i] > 0 ? this._cw[i] : 10;
470
+ bb.writeString(`<col min="${i + 1}" max="${i + 1}" width="${w}" bestFit="1" customWidth="1"/>`);
471
+ }
472
+ bb.writeString("</cols><sheetData>");
473
+ }
474
+ startSheet(name, colCount, headers, options = {}) {
475
+ if (this._isS) throw new Error("Already streaming");
476
+ const { hidden = false, doAutofilter = true, headerStyle = "bold" } = options;
477
+ let hs = 3;
478
+ if (headerStyle === "fill") hs = 4;
479
+ else if (headerStyle === "bold+fill") hs = 5;
480
+ this.addSheet(name, hidden);
481
+ this._isS = true;
482
+ this._csb = new BrowserBigBuffer();
483
+ this._csrn = 0;
484
+ this._csSC = 0;
485
+ this._csEC = colCount;
486
+ this._csAF = doAutofilter && headers !== void 0;
487
+ this._cw = new Array(colCount).fill(-1);
488
+ const cl = new Array(colCount);
489
+ for (let i = 0; i < colCount; i++) cl[i] = this._cl(i);
490
+ this._csCL = cl;
491
+ if (headers) for (let i = 0; i < colCount; i++) {
492
+ let w = 1.3 * (headers[i] ? headers[i].length : 0) + 3;
493
+ if (w > 80) w = 80;
494
+ if (this._cw[i] < w) this._cw[i] = w;
495
+ }
496
+ this._sheetHead(this._csb, colCount, this._sc === 1, this._csAF);
497
+ if (headers) {
498
+ this._csrn++;
499
+ this._csb.writeString(`<row r="${this._csrn}">`);
500
+ for (let c = 0; c < headers.length; c++) this._wscStyle(this._csb, headers[c], cl[c], this._csrn, hs);
501
+ this._csb.writeString("</row>");
502
+ }
503
+ }
504
+ writeRow(row) {
505
+ if (!this._isS) throw new Error("Not streaming");
506
+ this._csrn++;
507
+ this._csb.writeString(`<row r="${this._csrn}">`);
508
+ for (let c = 0; c < row.length; c++) this._wcv(this._csb, row[c], this._csCL[c], this._csrn);
509
+ this._csb.writeString("</row>");
510
+ }
511
+ endSheet() {
512
+ if (!this._isS) throw new Error("Not streaming");
513
+ this._csb.writeString("</sheetData>");
514
+ if (this._csAF && this._csEC > 0) {
515
+ this._afOn = true;
516
+ const fr = `A1:${this._csCL[this._csEC - 1]}${this._csrn}`;
517
+ this._csb.writeString(`<autoFilter ref="${fr}"/>`);
518
+ const sh = this._sl[this._sc - 1];
519
+ sh.fhr = `${this._fmn(sh.name)}!$A$1:$${this._csCL[this._csEC - 1]}$${this._csrn}`;
520
+ }
521
+ this._csb.writeString("</worksheet>");
522
+ this._zip.addFile(this._sl[this._sc - 1].path, this._csb.toUint8Array());
523
+ this._isS = false;
524
+ this._csb = null;
525
+ }
526
+ writeSheet(rows, headers = null, options = {}) {
527
+ const doAutofilter = options.doAutofilter !== false;
528
+ const headerStyle = options.headerStyle || "bold";
529
+ let hs = 3;
530
+ if (headerStyle === "fill") hs = 4;
531
+ else if (headerStyle === "bold+fill") hs = 5;
532
+ const bb = new BrowserBigBuffer();
533
+ let cc = rows.length > 0 ? rows[0].length : headers ? headers.length : 0;
534
+ this._cw = new Array(cc).fill(-1);
535
+ const cl = new Array(cc);
536
+ for (let i = 0; i < cc; i++) cl[i] = this._cl(i);
537
+ if (headers) for (let i = 0; i < cc; i++) {
538
+ let w = 1.3 * (headers[i] ? headers[i].length : 0) + 3;
539
+ if (w > 80) w = 80;
540
+ if (this._cw[i] < w) this._cw[i] = w;
541
+ }
542
+ for (let r = 0; r < Math.min(rows.length, 100); r++) for (let c = 0; c < rows[r].length; c++) {
543
+ const raw = rows[r][c];
544
+ if (raw == null) continue;
545
+ const v = isFormattedCell(raw) ? raw.value : raw;
546
+ let w = 1.3 * (v instanceof Date ? 10 : v.toString().length) + 3;
547
+ if (w > 80) w = 80;
548
+ if (this._cw[c] < w) this._cw[c] = w;
549
+ }
550
+ const tr = rows.length + (headers ? 1 : 0);
551
+ this._sheetHead(bb, cc, this._sc === 1, doAutofilter && !!headers);
552
+ let rn = 0;
553
+ if (headers) {
554
+ rn++;
555
+ bb.writeString(`<row r="${rn}">`);
556
+ for (let c = 0; c < headers.length; c++) this._wscStyle(bb, headers[c], cl[c], rn, hs);
557
+ bb.writeString("</row>");
558
+ }
559
+ for (let r = 0; r < rows.length; r++) {
560
+ rn++;
561
+ bb.writeString(`<row r="${rn}">`);
562
+ for (let c = 0; c < rows[r].length; c++) this._wcv(bb, rows[r][c], cl[c], rn);
563
+ bb.writeString("</row>");
564
+ }
565
+ bb.writeString("</sheetData>");
566
+ if (doAutofilter && headers && cc > 0) {
567
+ this._afOn = true;
568
+ const fr = `A1:${cl[cc - 1]}${tr}`;
569
+ bb.writeString(`<autoFilter ref="${fr}"/>`);
570
+ const sh = this._sl[this._sc - 1];
571
+ sh.fhr = `${this._fmn(sh.name)}!$A$1:$${cl[cc - 1]}$${tr}`;
572
+ }
573
+ bb.writeString("</worksheet>");
574
+ this._zip.addFile(this._sl[this._sc - 1].path, bb.toUint8Array());
575
+ }
576
+ finalize() {
577
+ this._writeSst();
578
+ this._writeStyles();
579
+ this._writeWb();
580
+ this._writeCt();
581
+ this._writeRels();
582
+ return this._zip.toBlob();
583
+ }
584
+ _writeSst() {
585
+ const bb = new BrowserBigBuffer();
586
+ bb.writeString('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>');
587
+ bb.writeString(`<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="${this._sstCnt}" uniqueCount="${this._sstA.length}">`);
588
+ for (const t of this._sstA) {
589
+ const c = this._esc(t);
590
+ if (c.length > 0 && (c[0] === " " || c[c.length - 1] === " " || /[\t\n\r]/.test(c))) bb.writeString(`<si><t xml:space="preserve">${c}</t></si>`);
591
+ else bb.writeString(`<si><t>${c}</t></si>`);
592
+ }
593
+ bb.writeString("</sst>");
594
+ this._zip.addFile("xl/sharedStrings.xml", bb.toUint8Array());
595
+ }
596
+ _writeStyles() {
597
+ let nfs = '<numFmt numFmtId="164" formatCode="yyyy\\-mm\\-dd\\ hh:mm:ss"/>';
598
+ let nfc = 1;
599
+ const xfe = [
600
+ '<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>',
601
+ '<xf numFmtId="14" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>',
602
+ '<xf numFmtId="164" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>',
603
+ '<xf numFmtId="0" fontId="1" fillId="0" borderId="0" xfId="0" applyFont="1"/>',
604
+ '<xf numFmtId="0" fontId="0" fillId="1" borderId="0" xfId="0" applyFill="1"/>',
605
+ '<xf numFmtId="0" fontId="1" fillId="1" borderId="0" xfId="0" applyFont="1" applyFill="1"/>'
606
+ ];
607
+ for (const [fs, nid] of this._fmtReg) {
608
+ const ef = fs.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
609
+ nfs += `<numFmt numFmtId="${nid}" formatCode="${ef}"/>`;
610
+ nfc++;
611
+ }
612
+ const sf = [...this._fmtXf.entries()].sort((a, b) => a[1] - b[1]);
613
+ for (const [fs] of sf) {
614
+ const nid = this._fmtReg.get(fs);
615
+ xfe.push(`<xf numFmtId="${nid}" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1"/>`);
616
+ }
617
+ this._zip.addFile("xl/styles.xml", `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
618
+ <styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
619
+ <numFmts count="${nfc}">${nfs}</numFmts>
620
+ <fonts count="2">
621
+ <font><sz val="11"/><color theme="1"/><name val="Calibri"/><family val="2"/><scheme val="minor"/></font>
622
+ <font><b/><sz val="11"/><color theme="1"/><name val="Calibri"/><family val="2"/><scheme val="minor"/></font>
623
+ </fonts>
624
+ <fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills>
625
+ <borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders>
626
+ <cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs>
627
+ <cellXfs count="${xfe.length}">
628
+ ${xfe.join("\n")}
629
+ </cellXfs>
630
+ <cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles>
631
+ <dxfs count="0"/><tableStyles count="0" defaultTableStyle="TableStyleMedium2" defaultPivotStyle="PivotStyleLight16"/>
632
+ </styleSheet>`);
633
+ }
634
+ _writeWb() {
635
+ let x = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><fileVersion appName="xl" lastEdited="4" lowestEdited="4" rupBuild="4505"/><workbookPr defaultThemeVersion="124226"/><bookViews><workbookView xWindow="240" yWindow="15" windowWidth="16095" windowHeight="9660"/></bookViews><sheets>`;
636
+ for (const s of this._sl) x += `<sheet name="${this._ex(s.name)}" sheetId="${s.id}"${s.hidden ? ' state="hidden"' : ""} r:id="${s.rId}"/>`;
637
+ x += "</sheets>";
638
+ if (this._afOn) {
639
+ x += "<definedNames>";
640
+ for (const s of this._sl) if (s.fhr) x += `<definedName name="_xlnm._FilterDatabase" localSheetId="${s.id - 1}" hidden="1">${this._esc(s.fhr)}</definedName>`;
641
+ x += "</definedNames>";
642
+ }
643
+ x += '<calcPr calcId="124519" fullCalcOnLoad="1"/></workbook>';
644
+ this._zip.addFile("xl/workbook.xml", x);
645
+ }
646
+ _writeCt() {
647
+ let x = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/><Override PartName="/xl/sharedStrings.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"/>`;
648
+ for (const s of this._sl) x += `<Override PartName="/${s.path}" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`;
649
+ x += "</Types>";
650
+ this._zip.addFile("[Content_Types].xml", x);
651
+ }
652
+ _writeRels() {
653
+ this._zip.addFile("_rels/.rels", `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>`);
654
+ let r = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">`;
655
+ for (const s of this._sl) r += `<Relationship Id="${s.rId}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/${s.fn}"/>`;
656
+ let n = this._sl.length + 1;
657
+ r += `<Relationship Id="rId${n++}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>`;
658
+ r += `<Relationship Id="rId${n++}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Target="sharedStrings.xml"/>`;
659
+ r += "</Relationships>";
660
+ this._zip.addFile("xl/_rels/workbook.xml.rels", r);
661
+ }
662
+ };
663
+
664
+ // src/browser/BrowserXlsbWriter.ts
665
+ var INVALID_SHEET_NAME_CHARS = /[\\/*?[\]:]/g;
666
+ var BrowserXlsbWriter = class {
667
+ constructor() {
668
+ this._zip = new BrowserZip();
669
+ this._sheetCount = 0;
670
+ this._sheetList = [];
671
+ this._sstDic = /* @__PURE__ */ new Map();
672
+ this._sstCntUnique = 0;
673
+ this._sstCntAll = 0;
674
+ this._colWidths = [];
675
+ this._autofilterIsOn = false;
676
+ this._oaEpoch = Date.UTC(1899, 11, 30);
677
+ this._isStreaming = false;
678
+ this._currentSheetBuffer = null;
679
+ this._currentSheetRowNum = 0;
680
+ this._currentSheetStartCol = 0;
681
+ this._currentSheetEndCol = 0;
682
+ this._currentSheetDoAutofilter = false;
683
+ this._fmtMap = /* @__PURE__ */ new Map();
684
+ this._nextNid = 167;
685
+ this._nextXf = 4;
686
+ this._sheet1Bytes = new Uint8Array([
687
+ 129,
688
+ 1,
689
+ 0,
690
+ 147,
691
+ 1,
692
+ 23,
693
+ 203,
694
+ 4,
695
+ 2,
696
+ 0,
697
+ 64,
698
+ 0,
699
+ 0,
700
+ 0,
701
+ 0,
702
+ 0,
703
+ 0,
704
+ 255,
705
+ 255,
706
+ 255,
707
+ 255,
708
+ 255,
709
+ 255,
710
+ 255,
711
+ 255,
712
+ 0,
713
+ 0,
714
+ 0,
715
+ 0,
716
+ 148,
717
+ 1,
718
+ 16,
719
+ 0,
720
+ 0,
721
+ 0,
722
+ 0,
723
+ 0,
724
+ 0,
725
+ 0,
726
+ 0,
727
+ 0,
728
+ 0,
729
+ 0,
730
+ 0,
731
+ 0,
732
+ 0,
733
+ 0,
734
+ 0,
735
+ 133,
736
+ 1,
737
+ 0,
738
+ 137,
739
+ 1,
740
+ 30,
741
+ 220,
742
+ 3,
743
+ 0,
744
+ 0,
745
+ 0,
746
+ 0,
747
+ 0,
748
+ 0,
749
+ 0,
750
+ 0,
751
+ 0,
752
+ 0,
753
+ 0,
754
+ 0,
755
+ 64,
756
+ 0,
757
+ 0,
758
+ 0,
759
+ 100,
760
+ 0,
761
+ 0,
762
+ 0,
763
+ 0,
764
+ 0,
765
+ 0,
766
+ 0,
767
+ 0,
768
+ 0,
769
+ 0,
770
+ 0,
771
+ 152,
772
+ 1,
773
+ 36,
774
+ 3,
775
+ 0,
776
+ 0,
777
+ 0,
778
+ 0,
779
+ 0,
780
+ 0,
781
+ 0,
782
+ 0,
783
+ 0,
784
+ 0,
785
+ 0,
786
+ 0,
787
+ 0,
788
+ 0,
789
+ 0,
790
+ 1,
791
+ 0,
792
+ 0,
793
+ 0,
794
+ 0,
795
+ 0,
796
+ 0,
797
+ 0,
798
+ 0,
799
+ 0,
800
+ 0,
801
+ 0,
802
+ 0,
803
+ 0,
804
+ 0,
805
+ 0,
806
+ 0,
807
+ 0,
808
+ 0,
809
+ 0,
810
+ 138,
811
+ 1,
812
+ 0,
813
+ 134,
814
+ 1,
815
+ 0,
816
+ 37,
817
+ 6,
818
+ 1,
819
+ 0,
820
+ 2,
821
+ 14,
822
+ 0,
823
+ 128,
824
+ 149,
825
+ 8,
826
+ 2,
827
+ 5,
828
+ 0,
829
+ 38,
830
+ 0,
831
+ 229,
832
+ 3,
833
+ 12,
834
+ 255,
835
+ 255,
836
+ 255,
837
+ 255,
838
+ 8,
839
+ 0,
840
+ 44,
841
+ 1,
842
+ 0,
843
+ 0,
844
+ 0,
845
+ 0,
846
+ 145,
847
+ 1,
848
+ 0,
849
+ 37,
850
+ 6,
851
+ 1,
852
+ 0,
853
+ 2,
854
+ 14,
855
+ 0,
856
+ 128,
857
+ 128,
858
+ 8,
859
+ 2,
860
+ 5,
861
+ 0,
862
+ 38,
863
+ 0,
864
+ 0,
865
+ 25,
866
+ 0,
867
+ 0,
868
+ 0,
869
+ 0,
870
+ 0,
871
+ 0,
872
+ 0,
873
+ 0,
874
+ 44,
875
+ 1,
876
+ 0,
877
+ 0,
878
+ 0,
879
+ 1,
880
+ 0,
881
+ 0,
882
+ 0,
883
+ 0,
884
+ 0,
885
+ 0,
886
+ 0,
887
+ 0,
888
+ 0,
889
+ 0,
890
+ 0,
891
+ 7,
892
+ 12,
893
+ 0,
894
+ 0,
895
+ 0,
896
+ 0,
897
+ 0,
898
+ 0,
899
+ 0,
900
+ 0,
901
+ 0,
902
+ 0,
903
+ 0,
904
+ 0,
905
+ 146,
906
+ 1,
907
+ 0,
908
+ 151,
909
+ 4,
910
+ 66,
911
+ 0,
912
+ 0,
913
+ 0,
914
+ 0,
915
+ 0,
916
+ 0,
917
+ 1,
918
+ 0,
919
+ 0,
920
+ 0,
921
+ 1,
922
+ 0,
923
+ 0,
924
+ 0,
925
+ 0,
926
+ 0,
927
+ 0,
928
+ 0,
929
+ 0,
930
+ 0,
931
+ 0,
932
+ 0,
933
+ 0,
934
+ 0,
935
+ 0,
936
+ 0,
937
+ 0,
938
+ 0,
939
+ 0,
940
+ 0,
941
+ 0,
942
+ 0,
943
+ 0,
944
+ 0,
945
+ 0,
946
+ 0,
947
+ 0,
948
+ 0,
949
+ 0,
950
+ 0,
951
+ 0,
952
+ 0,
953
+ 0,
954
+ 0,
955
+ 0,
956
+ 0,
957
+ 1,
958
+ 0,
959
+ 0,
960
+ 0,
961
+ 0,
962
+ 0,
963
+ 0,
964
+ 0,
965
+ 0,
966
+ 0,
967
+ 0,
968
+ 0,
969
+ 0,
970
+ 0,
971
+ 0,
972
+ 0,
973
+ 1,
974
+ 0,
975
+ 0,
976
+ 0,
977
+ 221,
978
+ 3,
979
+ 2,
980
+ 16,
981
+ 0,
982
+ 220,
983
+ 3,
984
+ 48,
985
+ 102,
986
+ 102,
987
+ 102,
988
+ 102,
989
+ 102,
990
+ 102,
991
+ 230,
992
+ 63,
993
+ 102,
994
+ 102,
995
+ 102,
996
+ 102,
997
+ 102,
998
+ 102,
999
+ 230,
1000
+ 63,
1001
+ 0,
1002
+ 0,
1003
+ 0,
1004
+ 0,
1005
+ 0,
1006
+ 0,
1007
+ 232,
1008
+ 63,
1009
+ 0,
1010
+ 0,
1011
+ 0,
1012
+ 0,
1013
+ 0,
1014
+ 0,
1015
+ 232,
1016
+ 63,
1017
+ 51,
1018
+ 51,
1019
+ 51,
1020
+ 51,
1021
+ 51,
1022
+ 51,
1023
+ 211,
1024
+ 63,
1025
+ 51,
1026
+ 51,
1027
+ 51,
1028
+ 51,
1029
+ 51,
1030
+ 51,
1031
+ 211,
1032
+ 63,
1033
+ 37,
1034
+ 6,
1035
+ 1,
1036
+ 0,
1037
+ 0,
1038
+ 16,
1039
+ 0,
1040
+ 128,
1041
+ 128,
1042
+ 24,
1043
+ 16,
1044
+ 0,
1045
+ 0,
1046
+ 0,
1047
+ 0,
1048
+ 1,
1049
+ 0,
1050
+ 0,
1051
+ 0,
1052
+ 0,
1053
+ 0,
1054
+ 0,
1055
+ 0,
1056
+ 0,
1057
+ 0,
1058
+ 0,
1059
+ 0,
1060
+ 38,
1061
+ 0,
1062
+ 130,
1063
+ 1,
1064
+ 0
1065
+ ]);
1066
+ this._workbookBinStart = new Uint8Array([
1067
+ 131,
1068
+ 1,
1069
+ 0,
1070
+ 128,
1071
+ 1,
1072
+ 50,
1073
+ 0,
1074
+ 0,
1075
+ 0,
1076
+ 0,
1077
+ 0,
1078
+ 0,
1079
+ 0,
1080
+ 0,
1081
+ 0,
1082
+ 0,
1083
+ 0,
1084
+ 0,
1085
+ 0,
1086
+ 0,
1087
+ 0,
1088
+ 0,
1089
+ 2,
1090
+ 0,
1091
+ 0,
1092
+ 0,
1093
+ 120,
1094
+ 0,
1095
+ 108,
1096
+ 0,
1097
+ 1,
1098
+ 0,
1099
+ 0,
1100
+ 0,
1101
+ 55,
1102
+ 0,
1103
+ 1,
1104
+ 0,
1105
+ 0,
1106
+ 0,
1107
+ 54,
1108
+ 0,
1109
+ 5,
1110
+ 0,
1111
+ 0,
1112
+ 0,
1113
+ 50,
1114
+ 0,
1115
+ 52,
1116
+ 0,
1117
+ 51,
1118
+ 0,
1119
+ 50,
1120
+ 0,
1121
+ 54,
1122
+ 0,
1123
+ 153,
1124
+ 1,
1125
+ 12,
1126
+ 32,
1127
+ 0,
1128
+ 1,
1129
+ 0,
1130
+ 0,
1131
+ 0,
1132
+ 0,
1133
+ 0,
1134
+ 0,
1135
+ 0,
1136
+ 0,
1137
+ 0,
1138
+ 37,
1139
+ 6,
1140
+ 1,
1141
+ 0,
1142
+ 3,
1143
+ 15,
1144
+ 0,
1145
+ 128,
1146
+ 151,
1147
+ 16,
1148
+ 52,
1149
+ 24,
1150
+ 0,
1151
+ 0,
1152
+ 0,
1153
+ 67,
1154
+ 0,
1155
+ 58,
1156
+ 0,
1157
+ 92,
1158
+ 0,
1159
+ 115,
1160
+ 0,
1161
+ 113,
1162
+ 0,
1163
+ 108,
1164
+ 0,
1165
+ 115,
1166
+ 0,
1167
+ 92,
1168
+ 0,
1169
+ 84,
1170
+ 0,
1171
+ 101,
1172
+ 0,
1173
+ 115,
1174
+ 0,
1175
+ 116,
1176
+ 0,
1177
+ 121,
1178
+ 0,
1179
+ 90,
1180
+ 0,
1181
+ 97,
1182
+ 0,
1183
+ 112,
1184
+ 0,
1185
+ 105,
1186
+ 0,
1187
+ 115,
1188
+ 0,
1189
+ 117,
1190
+ 0,
1191
+ 88,
1192
+ 0,
1193
+ 108,
1194
+ 0,
1195
+ 115,
1196
+ 0,
1197
+ 98,
1198
+ 0,
1199
+ 92,
1200
+ 0,
1201
+ 38,
1202
+ 0,
1203
+ 37,
1204
+ 6,
1205
+ 1,
1206
+ 0,
1207
+ 0,
1208
+ 16,
1209
+ 0,
1210
+ 128,
1211
+ 129,
1212
+ 24,
1213
+ 130,
1214
+ 1,
1215
+ 0,
1216
+ 0,
1217
+ 0,
1218
+ 0,
1219
+ 0,
1220
+ 0,
1221
+ 0,
1222
+ 0,
1223
+ 47,
1224
+ 0,
1225
+ 0,
1226
+ 0,
1227
+ 49,
1228
+ 0,
1229
+ 51,
1230
+ 0,
1231
+ 95,
1232
+ 0,
1233
+ 110,
1234
+ 0,
1235
+ 99,
1236
+ 0,
1237
+ 114,
1238
+ 0,
1239
+ 58,
1240
+ 0,
1241
+ 49,
1242
+ 0,
1243
+ 95,
1244
+ 0,
1245
+ 123,
1246
+ 0,
1247
+ 49,
1248
+ 0,
1249
+ 54,
1250
+ 0,
1251
+ 53,
1252
+ 0,
1253
+ 48,
1254
+ 0,
1255
+ 56,
1256
+ 0,
1257
+ 68,
1258
+ 0,
1259
+ 54,
1260
+ 0,
1261
+ 57,
1262
+ 0,
1263
+ 45,
1264
+ 0,
1265
+ 67,
1266
+ 0,
1267
+ 70,
1268
+ 0,
1269
+ 56,
1270
+ 0,
1271
+ 55,
1272
+ 0,
1273
+ 45,
1274
+ 0,
1275
+ 52,
1276
+ 0,
1277
+ 55,
1278
+ 0,
1279
+ 54,
1280
+ 0,
1281
+ 57,
1282
+ 0,
1283
+ 45,
1284
+ 0,
1285
+ 56,
1286
+ 0,
1287
+ 52,
1288
+ 0,
1289
+ 53,
1290
+ 0,
1291
+ 54,
1292
+ 0,
1293
+ 45,
1294
+ 0,
1295
+ 68,
1296
+ 0,
1297
+ 52,
1298
+ 0,
1299
+ 65,
1300
+ 0,
1301
+ 52,
1302
+ 0,
1303
+ 48,
1304
+ 0,
1305
+ 49,
1306
+ 0,
1307
+ 49,
1308
+ 0,
1309
+ 51,
1310
+ 0,
1311
+ 49,
1312
+ 0,
1313
+ 53,
1314
+ 0,
1315
+ 54,
1316
+ 0,
1317
+ 55,
1318
+ 0,
1319
+ 125,
1320
+ 0,
1321
+ 47,
1322
+ 0,
1323
+ 0,
1324
+ 0,
1325
+ 47,
1326
+ 0,
1327
+ 0,
1328
+ 0,
1329
+ 0,
1330
+ 0,
1331
+ 0,
1332
+ 0,
1333
+ 0,
1334
+ 0,
1335
+ 0,
1336
+ 0,
1337
+ 0,
1338
+ 0,
1339
+ 0,
1340
+ 0,
1341
+ 0,
1342
+ 0,
1343
+ 0,
1344
+ 0,
1345
+ 38,
1346
+ 0,
1347
+ 135,
1348
+ 1,
1349
+ 0,
1350
+ 37,
1351
+ 6,
1352
+ 1,
1353
+ 0,
1354
+ 2,
1355
+ 16,
1356
+ 0,
1357
+ 128,
1358
+ 128,
1359
+ 24,
1360
+ 16,
1361
+ 0,
1362
+ 0,
1363
+ 0,
1364
+ 0,
1365
+ 13,
1366
+ 0,
1367
+ 0,
1368
+ 0,
1369
+ 255,
1370
+ 255,
1371
+ 255,
1372
+ 255,
1373
+ 0,
1374
+ 0,
1375
+ 0,
1376
+ 0,
1377
+ 38,
1378
+ 0,
1379
+ 158,
1380
+ 1,
1381
+ 29,
1382
+ 0,
1383
+ 0,
1384
+ 0,
1385
+ 0,
1386
+ 158,
1387
+ 22,
1388
+ 0,
1389
+ 0,
1390
+ 180,
1391
+ 105,
1392
+ 0,
1393
+ 0,
1394
+ 232,
1395
+ 38,
1396
+ 0,
1397
+ 0,
1398
+ 88,
1399
+ 2,
1400
+ 0,
1401
+ 0,
1402
+ 0,
1403
+ 0,
1404
+ 0,
1405
+ 0,
1406
+ 0,
1407
+ 0,
1408
+ 0,
1409
+ 0,
1410
+ 120,
1411
+ 136,
1412
+ 1,
1413
+ 0,
1414
+ 143,
1415
+ 1,
1416
+ 0
1417
+ ]);
1418
+ this._workbookBinMiddle = new Uint8Array([144, 1, 0]);
1419
+ this._workbookBinEnd = new Uint8Array([
1420
+ 157,
1421
+ 1,
1422
+ 26,
1423
+ 53,
1424
+ 234,
1425
+ 2,
1426
+ 0,
1427
+ 1,
1428
+ 0,
1429
+ 0,
1430
+ 0,
1431
+ 100,
1432
+ 0,
1433
+ 0,
1434
+ 0,
1435
+ 252,
1436
+ 169,
1437
+ 241,
1438
+ 210,
1439
+ 77,
1440
+ 98,
1441
+ 80,
1442
+ 63,
1443
+ 1,
1444
+ 0,
1445
+ 0,
1446
+ 0,
1447
+ 106,
1448
+ 0,
1449
+ 155,
1450
+ 1,
1451
+ 1,
1452
+ 0,
1453
+ 35,
1454
+ 4,
1455
+ 3,
1456
+ 15,
1457
+ 0,
1458
+ 0,
1459
+ 171,
1460
+ 16,
1461
+ 1,
1462
+ 1,
1463
+ 36,
1464
+ 0,
1465
+ 132,
1466
+ 1,
1467
+ 0
1468
+ ]);
1469
+ this._stylesBin = new Uint8Array([
1470
+ 150,
1471
+ 2,
1472
+ 0,
1473
+ 231,
1474
+ 4,
1475
+ 4,
1476
+ 2,
1477
+ 0,
1478
+ 0,
1479
+ 0,
1480
+ 44,
1481
+ 44,
1482
+ 164,
1483
+ 0,
1484
+ 19,
1485
+ 0,
1486
+ 0,
1487
+ 0,
1488
+ 121,
1489
+ 0,
1490
+ 121,
1491
+ 0,
1492
+ 121,
1493
+ 0,
1494
+ 121,
1495
+ 0,
1496
+ 92,
1497
+ 0,
1498
+ 45,
1499
+ 0,
1500
+ 109,
1501
+ 0,
1502
+ 109,
1503
+ 0,
1504
+ 92,
1505
+ 0,
1506
+ 45,
1507
+ 0,
1508
+ 100,
1509
+ 0,
1510
+ 100,
1511
+ 0,
1512
+ 92,
1513
+ 0,
1514
+ 32,
1515
+ 0,
1516
+ 104,
1517
+ 0,
1518
+ 104,
1519
+ 0,
1520
+ 58,
1521
+ 0,
1522
+ 109,
1523
+ 0,
1524
+ 109,
1525
+ 0,
1526
+ 44,
1527
+ 30,
1528
+ 166,
1529
+ 0,
1530
+ 12,
1531
+ 0,
1532
+ 0,
1533
+ 0,
1534
+ 121,
1535
+ 0,
1536
+ 121,
1537
+ 0,
1538
+ 121,
1539
+ 0,
1540
+ 121,
1541
+ 0,
1542
+ 92,
1543
+ 0,
1544
+ 45,
1545
+ 0,
1546
+ 109,
1547
+ 0,
1548
+ 109,
1549
+ 0,
1550
+ 92,
1551
+ 0,
1552
+ 45,
1553
+ 0,
1554
+ 100,
1555
+ 0,
1556
+ 100,
1557
+ 0,
1558
+ 232,
1559
+ 4,
1560
+ 0,
1561
+ 227,
1562
+ 4,
1563
+ 4,
1564
+ 2,
1565
+ 0,
1566
+ 0,
1567
+ 0,
1568
+ 43,
1569
+ 39,
1570
+ 220,
1571
+ 0,
1572
+ 0,
1573
+ 0,
1574
+ 144,
1575
+ 1,
1576
+ 0,
1577
+ 0,
1578
+ 0,
1579
+ 2,
1580
+ 0,
1581
+ 0,
1582
+ 7,
1583
+ 1,
1584
+ 0,
1585
+ 0,
1586
+ 0,
1587
+ 0,
1588
+ 0,
1589
+ 255,
1590
+ 2,
1591
+ 7,
1592
+ 0,
1593
+ 0,
1594
+ 0,
1595
+ 67,
1596
+ 0,
1597
+ 97,
1598
+ 0,
1599
+ 108,
1600
+ 0,
1601
+ 105,
1602
+ 0,
1603
+ 98,
1604
+ 0,
1605
+ 114,
1606
+ 0,
1607
+ 105,
1608
+ 0,
1609
+ 43,
1610
+ 39,
1611
+ 220,
1612
+ 0,
1613
+ 1,
1614
+ 0,
1615
+ 188,
1616
+ 2,
1617
+ 0,
1618
+ 0,
1619
+ 0,
1620
+ 2,
1621
+ 238,
1622
+ 0,
1623
+ 7,
1624
+ 1,
1625
+ 0,
1626
+ 0,
1627
+ 0,
1628
+ 0,
1629
+ 0,
1630
+ 255,
1631
+ 2,
1632
+ 7,
1633
+ 0,
1634
+ 0,
1635
+ 0,
1636
+ 67,
1637
+ 0,
1638
+ 97,
1639
+ 0,
1640
+ 108,
1641
+ 0,
1642
+ 105,
1643
+ 0,
1644
+ 98,
1645
+ 0,
1646
+ 114,
1647
+ 0,
1648
+ 105,
1649
+ 0,
1650
+ 37,
1651
+ 6,
1652
+ 1,
1653
+ 0,
1654
+ 2,
1655
+ 14,
1656
+ 0,
1657
+ 128,
1658
+ 129,
1659
+ 8,
1660
+ 0,
1661
+ 38,
1662
+ 0,
1663
+ 228,
1664
+ 4,
1665
+ 0,
1666
+ 219,
1667
+ 4,
1668
+ 4,
1669
+ 2,
1670
+ 0,
1671
+ 0,
1672
+ 0,
1673
+ 45,
1674
+ 68,
1675
+ 0,
1676
+ 0,
1677
+ 0,
1678
+ 0,
1679
+ 3,
1680
+ 64,
1681
+ 0,
1682
+ 0,
1683
+ 0,
1684
+ 0,
1685
+ 0,
1686
+ 255,
1687
+ 3,
1688
+ 65,
1689
+ 0,
1690
+ 0,
1691
+ 255,
1692
+ 255,
1693
+ 255,
1694
+ 255,
1695
+ 0,
1696
+ 0,
1697
+ 0,
1698
+ 0,
1699
+ 0,
1700
+ 0,
1701
+ 0,
1702
+ 0,
1703
+ 0,
1704
+ 0,
1705
+ 0,
1706
+ 0,
1707
+ 0,
1708
+ 0,
1709
+ 0,
1710
+ 0,
1711
+ 0,
1712
+ 0,
1713
+ 0,
1714
+ 0,
1715
+ 0,
1716
+ 0,
1717
+ 0,
1718
+ 0,
1719
+ 0,
1720
+ 0,
1721
+ 0,
1722
+ 0,
1723
+ 0,
1724
+ 0,
1725
+ 0,
1726
+ 0,
1727
+ 0,
1728
+ 0,
1729
+ 0,
1730
+ 0,
1731
+ 0,
1732
+ 0,
1733
+ 0,
1734
+ 0,
1735
+ 0,
1736
+ 0,
1737
+ 0,
1738
+ 0,
1739
+ 0,
1740
+ 0,
1741
+ 0,
1742
+ 0,
1743
+ 45,
1744
+ 68,
1745
+ 17,
1746
+ 0,
1747
+ 0,
1748
+ 0,
1749
+ 3,
1750
+ 64,
1751
+ 0,
1752
+ 0,
1753
+ 0,
1754
+ 0,
1755
+ 0,
1756
+ 255,
1757
+ 3,
1758
+ 65,
1759
+ 0,
1760
+ 0,
1761
+ 255,
1762
+ 255,
1763
+ 255,
1764
+ 255,
1765
+ 0,
1766
+ 0,
1767
+ 0,
1768
+ 0,
1769
+ 0,
1770
+ 0,
1771
+ 0,
1772
+ 0,
1773
+ 0,
1774
+ 0,
1775
+ 0,
1776
+ 0,
1777
+ 0,
1778
+ 0,
1779
+ 0,
1780
+ 0,
1781
+ 0,
1782
+ 0,
1783
+ 0,
1784
+ 0,
1785
+ 0,
1786
+ 0,
1787
+ 0,
1788
+ 0,
1789
+ 0,
1790
+ 0,
1791
+ 0,
1792
+ 0,
1793
+ 0,
1794
+ 0,
1795
+ 0,
1796
+ 0,
1797
+ 0,
1798
+ 0,
1799
+ 0,
1800
+ 0,
1801
+ 0,
1802
+ 0,
1803
+ 0,
1804
+ 0,
1805
+ 0,
1806
+ 0,
1807
+ 0,
1808
+ 0,
1809
+ 0,
1810
+ 0,
1811
+ 0,
1812
+ 0,
1813
+ 220,
1814
+ 4,
1815
+ 0,
1816
+ 229,
1817
+ 4,
1818
+ 4,
1819
+ 1,
1820
+ 0,
1821
+ 0,
1822
+ 0,
1823
+ 46,
1824
+ 51,
1825
+ 0,
1826
+ 0,
1827
+ 0,
1828
+ 1,
1829
+ 0,
1830
+ 0,
1831
+ 0,
1832
+ 0,
1833
+ 0,
1834
+ 0,
1835
+ 0,
1836
+ 0,
1837
+ 0,
1838
+ 1,
1839
+ 0,
1840
+ 0,
1841
+ 0,
1842
+ 0,
1843
+ 0,
1844
+ 0,
1845
+ 0,
1846
+ 0,
1847
+ 0,
1848
+ 1,
1849
+ 0,
1850
+ 0,
1851
+ 0,
1852
+ 0,
1853
+ 0,
1854
+ 0,
1855
+ 0,
1856
+ 0,
1857
+ 0,
1858
+ 1,
1859
+ 0,
1860
+ 0,
1861
+ 0,
1862
+ 0,
1863
+ 0,
1864
+ 0,
1865
+ 0,
1866
+ 0,
1867
+ 0,
1868
+ 1,
1869
+ 0,
1870
+ 0,
1871
+ 0,
1872
+ 0,
1873
+ 0,
1874
+ 0,
1875
+ 0,
1876
+ 230,
1877
+ 4,
1878
+ 0,
1879
+ 242,
1880
+ 4,
1881
+ 4,
1882
+ 1,
1883
+ 0,
1884
+ 0,
1885
+ 0,
1886
+ 47,
1887
+ 16,
1888
+ 255,
1889
+ 255,
1890
+ 0,
1891
+ 0,
1892
+ 0,
1893
+ 0,
1894
+ 0,
1895
+ 0,
1896
+ 0,
1897
+ 0,
1898
+ 0,
1899
+ 0,
1900
+ 16,
1901
+ 16,
1902
+ 0,
1903
+ 0,
1904
+ 243,
1905
+ 4,
1906
+ 0,
1907
+ 233,
1908
+ 4,
1909
+ 4,
1910
+ 6,
1911
+ // 6 xfs
1912
+ 0,
1913
+ 0,
1914
+ 0,
1915
+ 47,
1916
+ 16,
1917
+ 0,
1918
+ 0,
1919
+ 0,
1920
+ 0,
1921
+ 0,
1922
+ 0,
1923
+ 0,
1924
+ 0,
1925
+ 0,
1926
+ 0,
1927
+ 0,
1928
+ 0,
1929
+ 16,
1930
+ 16,
1931
+ 0,
1932
+ 0,
1933
+ 47,
1934
+ 16,
1935
+ 0,
1936
+ 0,
1937
+ 164,
1938
+ 0,
1939
+ 0,
1940
+ 0,
1941
+ 0,
1942
+ 0,
1943
+ 0,
1944
+ 0,
1945
+ 0,
1946
+ 0,
1947
+ 16,
1948
+ 16,
1949
+ 1,
1950
+ 0,
1951
+ 47,
1952
+ 16,
1953
+ 0,
1954
+ 0,
1955
+ 166,
1956
+ 0,
1957
+ 0,
1958
+ 0,
1959
+ 0,
1960
+ 0,
1961
+ 0,
1962
+ 0,
1963
+ 0,
1964
+ 0,
1965
+ 16,
1966
+ 16,
1967
+ 1,
1968
+ 0,
1969
+ 47,
1970
+ 16,
1971
+ 0,
1972
+ 0,
1973
+ 0,
1974
+ 0,
1975
+ 1,
1976
+ 0,
1977
+ 0,
1978
+ 0,
1979
+ 0,
1980
+ 0,
1981
+ 0,
1982
+ 0,
1983
+ 16,
1984
+ 16,
1985
+ 1,
1986
+ 0,
1987
+ // index=3: bold
1988
+ 47,
1989
+ 16,
1990
+ 0,
1991
+ 0,
1992
+ 0,
1993
+ 0,
1994
+ 0,
1995
+ 0,
1996
+ 1,
1997
+ 0,
1998
+ 0,
1999
+ 0,
2000
+ 0,
2001
+ 0,
2002
+ 16,
2003
+ 16,
2004
+ 1,
2005
+ 0,
2006
+ // index=4: fill
2007
+ 47,
2008
+ 16,
2009
+ 0,
2010
+ 0,
2011
+ 0,
2012
+ 0,
2013
+ 1,
2014
+ 0,
2015
+ 1,
2016
+ 0,
2017
+ 0,
2018
+ 0,
2019
+ 0,
2020
+ 0,
2021
+ 16,
2022
+ 16,
2023
+ 1,
2024
+ 0,
2025
+ // index=5: bold+fill
2026
+ 234,
2027
+ 4,
2028
+ 0,
2029
+ 235,
2030
+ 4,
2031
+ 4,
2032
+ 1,
2033
+ 0,
2034
+ 0,
2035
+ 0,
2036
+ 37,
2037
+ 6,
2038
+ 1,
2039
+ 0,
2040
+ 2,
2041
+ 17,
2042
+ 0,
2043
+ 128,
2044
+ 128,
2045
+ 24,
2046
+ 16,
2047
+ 0,
2048
+ 0,
2049
+ 0,
2050
+ 0,
2051
+ 0,
2052
+ 0,
2053
+ 0,
2054
+ 0,
2055
+ 0,
2056
+ 0,
2057
+ 0,
2058
+ 0,
2059
+ 0,
2060
+ 0,
2061
+ 0,
2062
+ 0,
2063
+ 38,
2064
+ 0,
2065
+ 48,
2066
+ 28,
2067
+ 0,
2068
+ 0,
2069
+ 0,
2070
+ 0,
2071
+ 1,
2072
+ 0,
2073
+ 0,
2074
+ 0,
2075
+ 8,
2076
+ 0,
2077
+ 0,
2078
+ 0,
2079
+ 78,
2080
+ 0,
2081
+ 111,
2082
+ 0,
2083
+ 114,
2084
+ 0,
2085
+ 109,
2086
+ 0,
2087
+ 97,
2088
+ 0,
2089
+ 108,
2090
+ 0,
2091
+ 110,
2092
+ 0,
2093
+ 121,
2094
+ 0,
2095
+ 236,
2096
+ 4,
2097
+ 0,
2098
+ 249,
2099
+ 3,
2100
+ 4,
2101
+ 0,
2102
+ 0,
2103
+ 0,
2104
+ 0,
2105
+ 250,
2106
+ 3,
2107
+ 0,
2108
+ 252,
2109
+ 3,
2110
+ 80,
2111
+ 0,
2112
+ 0,
2113
+ 0,
2114
+ 0,
2115
+ 17,
2116
+ 0,
2117
+ 0,
2118
+ 0,
2119
+ 84,
2120
+ 0,
2121
+ 97,
2122
+ 0,
2123
+ 98,
2124
+ 0,
2125
+ 108,
2126
+ 0,
2127
+ 101,
2128
+ 0,
2129
+ 83,
2130
+ 0,
2131
+ 116,
2132
+ 0,
2133
+ 121,
2134
+ 0,
2135
+ 108,
2136
+ 0,
2137
+ 101,
2138
+ 0,
2139
+ 77,
2140
+ 0,
2141
+ 101,
2142
+ 0,
2143
+ 100,
2144
+ 0,
2145
+ 105,
2146
+ 0,
2147
+ 117,
2148
+ 0,
2149
+ 109,
2150
+ 0,
2151
+ 50,
2152
+ 0,
2153
+ 17,
2154
+ 0,
2155
+ 0,
2156
+ 0,
2157
+ 80,
2158
+ 0,
2159
+ 105,
2160
+ 0,
2161
+ 118,
2162
+ 0,
2163
+ 111,
2164
+ 0,
2165
+ 116,
2166
+ 0,
2167
+ 83,
2168
+ 0,
2169
+ 116,
2170
+ 0,
2171
+ 121,
2172
+ 0,
2173
+ 108,
2174
+ 0,
2175
+ 101,
2176
+ 0,
2177
+ 76,
2178
+ 0,
2179
+ 105,
2180
+ 0,
2181
+ 103,
2182
+ 0,
2183
+ 104,
2184
+ 0,
2185
+ 116,
2186
+ 0,
2187
+ 49,
2188
+ 0,
2189
+ 54,
2190
+ 0,
2191
+ 253,
2192
+ 3,
2193
+ 0,
2194
+ 35,
2195
+ 4,
2196
+ 2,
2197
+ 14,
2198
+ 0,
2199
+ 0,
2200
+ 235,
2201
+ 8,
2202
+ 0,
2203
+ 246,
2204
+ 8,
2205
+ 42,
2206
+ 0,
2207
+ 0,
2208
+ 0,
2209
+ 0,
2210
+ 17,
2211
+ 0,
2212
+ 0,
2213
+ 0,
2214
+ 83,
2215
+ 0,
2216
+ 108,
2217
+ 0,
2218
+ 105,
2219
+ 0,
2220
+ 99,
2221
+ 0,
2222
+ 101,
2223
+ 0,
2224
+ 114,
2225
+ 0,
2226
+ 83,
2227
+ 0,
2228
+ 116,
2229
+ 0,
2230
+ 121,
2231
+ 0,
2232
+ 108,
2233
+ 0,
2234
+ 101,
2235
+ 0,
2236
+ 76,
2237
+ 0,
2238
+ 105,
2239
+ 0,
2240
+ 103,
2241
+ 0,
2242
+ 104,
2243
+ 0,
2244
+ 116,
2245
+ 0,
2246
+ 49,
2247
+ 0,
2248
+ 247,
2249
+ 8,
2250
+ 0,
2251
+ 236,
2252
+ 8,
2253
+ 0,
2254
+ 36,
2255
+ 0,
2256
+ 35,
2257
+ 4,
2258
+ 3,
2259
+ 15,
2260
+ 0,
2261
+ 0,
2262
+ 176,
2263
+ 16,
2264
+ 0,
2265
+ 178,
2266
+ 16,
2267
+ 50,
2268
+ 0,
2269
+ 0,
2270
+ 0,
2271
+ 0,
2272
+ 21,
2273
+ 0,
2274
+ 0,
2275
+ 0,
2276
+ 84,
2277
+ 0,
2278
+ 105,
2279
+ 0,
2280
+ 109,
2281
+ 0,
2282
+ 101,
2283
+ 0,
2284
+ 83,
2285
+ 0,
2286
+ 108,
2287
+ 0,
2288
+ 105,
2289
+ 0,
2290
+ 99,
2291
+ 0,
2292
+ 101,
2293
+ 0,
2294
+ 114,
2295
+ 0,
2296
+ 83,
2297
+ 0,
2298
+ 116,
2299
+ 0,
2300
+ 121,
2301
+ 0,
2302
+ 108,
2303
+ 0,
2304
+ 101,
2305
+ 0,
2306
+ 76,
2307
+ 0,
2308
+ 105,
2309
+ 0,
2310
+ 103,
2311
+ 0,
2312
+ 104,
2313
+ 0,
2314
+ 116,
2315
+ 0,
2316
+ 49,
2317
+ 0,
2318
+ 179,
2319
+ 16,
2320
+ 0,
2321
+ 177,
2322
+ 16,
2323
+ 0,
2324
+ 36,
2325
+ 0,
2326
+ 151,
2327
+ 2,
2328
+ 0
2329
+ ]);
2330
+ this._binaryIndexBin = new Uint8Array([
2331
+ 42,
2332
+ 24,
2333
+ 0,
2334
+ 0,
2335
+ 0,
2336
+ 0,
2337
+ 32,
2338
+ 0,
2339
+ 0,
2340
+ 0,
2341
+ 0,
2342
+ 0,
2343
+ 0,
2344
+ 0,
2345
+ 0,
2346
+ 0,
2347
+ 0,
2348
+ 0,
2349
+ 0,
2350
+ 0,
2351
+ 0,
2352
+ 0,
2353
+ 0,
2354
+ 0,
2355
+ 0,
2356
+ 0,
2357
+ 149,
2358
+ 2,
2359
+ 0
2360
+ ]);
2361
+ this._rRkIntegerLowerLimit = -1 << 29;
2362
+ this._rRkIntegerUpperLimit = (1 << 29) - 1;
2363
+ this._autoFilterStartBytes = new Uint8Array([161, 1, 16]);
2364
+ this._autoFilterEndBytes = new Uint8Array([162, 1, 0]);
2365
+ this._stickHeaderA1bytes = new Uint8Array([
2366
+ 151,
2367
+ 1,
2368
+ 29,
2369
+ 0,
2370
+ 0,
2371
+ 0,
2372
+ 0,
2373
+ 0,
2374
+ 0,
2375
+ 0,
2376
+ 0,
2377
+ 0,
2378
+ 0,
2379
+ 0,
2380
+ 0,
2381
+ 0,
2382
+ 0,
2383
+ 240,
2384
+ 63,
2385
+ 1,
2386
+ 0,
2387
+ 0,
2388
+ 0,
2389
+ 0,
2390
+ 0,
2391
+ 0,
2392
+ 0,
2393
+ 2,
2394
+ 0,
2395
+ 0,
2396
+ 0,
2397
+ 3
2398
+ ]);
2399
+ this._magicFilterExcel2016Fix0 = new Uint8Array([225, 2, 0, 229, 2, 0, 234, 2]);
2400
+ this._magicFilterExcel2016Fix1 = new Uint8Array([
2401
+ 39,
2402
+ 70,
2403
+ 33,
2404
+ 0,
2405
+ 0,
2406
+ 0,
2407
+ 0,
2408
+ 255,
2409
+ 0,
2410
+ 0,
2411
+ 0,
2412
+ 15,
2413
+ 0,
2414
+ 0,
2415
+ 0,
2416
+ 95,
2417
+ 0,
2418
+ 70,
2419
+ 0,
2420
+ 105,
2421
+ 0,
2422
+ 108,
2423
+ 0,
2424
+ 116,
2425
+ 0,
2426
+ 101,
2427
+ 0,
2428
+ 114,
2429
+ 0,
2430
+ 68,
2431
+ 0,
2432
+ 97,
2433
+ 0,
2434
+ 116,
2435
+ 0,
2436
+ 97,
2437
+ 0,
2438
+ 98,
2439
+ 0,
2440
+ 97,
2441
+ 0,
2442
+ 115,
2443
+ 0,
2444
+ 101,
2445
+ 0,
2446
+ 15,
2447
+ 0,
2448
+ 0,
2449
+ 0,
2450
+ 59,
2451
+ 255,
2452
+ 0
2453
+ ]);
2454
+ this._magicFilterExcel2016Fix2 = new Uint8Array([0, 0, 0, 0, 255, 255, 255, 255]);
2455
+ }
2456
+ _sanitizeSheetName(name) {
2457
+ if (!name || typeof name !== "string") return `Sheet${this._sheetCount + 1}`;
2458
+ let s = name.replace(INVALID_SHEET_NAME_CHARS, "_");
2459
+ if (s.length > 31) s = s.substring(0, 31);
2460
+ if (s.trim().length === 0) s = `Sheet${this._sheetCount + 1}`;
2461
+ return s;
2462
+ }
2463
+ _registerFormat(fmtString) {
2464
+ if (this._fmtMap.has(fmtString)) return this._fmtMap.get(fmtString).xf;
2465
+ const nid = this._nextNid++;
2466
+ const xf = this._nextXf++;
2467
+ this._fmtMap.set(fmtString, { nid, xf });
2468
+ return xf;
2469
+ }
2470
+ _buildStylesBin() {
2471
+ if (this._fmtMap.size === 0) return this._stylesBin;
2472
+ const base = this._stylesBin;
2473
+ let fontEndOff = -1;
2474
+ for (let i = 3; i < base.length - 3; i++) {
2475
+ if (base[i] === 232 && base[i + 1] === 4 && base[i + 2] === 0) {
2476
+ fontEndOff = i;
2477
+ break;
2478
+ }
2479
+ }
2480
+ let xfBeginOff = -1;
2481
+ for (let i = fontEndOff + 3; i < base.length - 2; i++) {
2482
+ if (base[i] === 233 && base[i + 1] === 4) {
2483
+ xfBeginOff = i;
2484
+ break;
2485
+ }
2486
+ }
2487
+ let xfEndOff = -1;
2488
+ for (let i = xfBeginOff; i < base.length - 3; i++) {
2489
+ if (base[i] === 234 && base[i + 1] === 4 && base[i + 2] === 0) {
2490
+ xfEndOff = i;
2491
+ break;
2492
+ }
2493
+ }
2494
+ let fillBeginOff = -1;
2495
+ for (let i = fontEndOff + 3; i < base.length - 2; i++) {
2496
+ if (base[i] === 227 && base[i + 1] === 4) {
2497
+ fillBeginOff = i;
2498
+ break;
2499
+ }
2500
+ }
2501
+ const tf = 2 + this._fmtMap.size;
2502
+ const tx = 4 + this._fmtMap.size;
2503
+ const p = [];
2504
+ function vlq(v) {
2505
+ const r2 = [];
2506
+ while (v >= 128) {
2507
+ r2.push(v & 127 | 128);
2508
+ v >>>= 7;
2509
+ }
2510
+ r2.push(v & 127);
2511
+ return r2;
2512
+ }
2513
+ function brt(t, d) {
2514
+ return new Uint8Array([...vlq(t), ...vlq(d.length), ...d]);
2515
+ }
2516
+ function stFmt(ifmt, fs) {
2517
+ const cch = fs.length, rem = 2 + 4 + cch * 2;
2518
+ const buf = new Uint8Array(2 + rem);
2519
+ buf[0] = 44;
2520
+ buf[1] = rem;
2521
+ const dv = new DataView(buf.buffer);
2522
+ dv.setUint16(2, ifmt, true);
2523
+ dv.setUint32(4, cch, true);
2524
+ for (let i = 0; i < cch; i++) {
2525
+ const cp = fs.charCodeAt(i);
2526
+ buf[8 + i * 2] = cp & 255;
2527
+ buf[8 + i * 2 + 1] = cp >> 8 & 255;
2528
+ }
2529
+ return buf;
2530
+ }
2531
+ function xfRec(fid, ifmt, fl, be = 0) {
2532
+ const buf = new Uint8Array(18);
2533
+ const dv = new DataView(buf.buffer);
2534
+ buf[0] = 47;
2535
+ buf[1] = 16;
2536
+ dv.setUint16(2, fid, true);
2537
+ dv.setUint16(4, ifmt, true);
2538
+ buf[6] = be;
2539
+ buf[14] = 16;
2540
+ buf[15] = 16;
2541
+ dv.setUint16(16, fl, true);
2542
+ return buf;
2543
+ }
2544
+ p.push(base.subarray(0, 3));
2545
+ const fh = new Uint8Array(4);
2546
+ new DataView(fh.buffer).setUint16(0, tf, true);
2547
+ p.push(brt(615, fh));
2548
+ p.push(stFmt(164, "yyyy\\-mm\\-dd\\ hh:mm:ss"));
2549
+ p.push(stFmt(166, "yyyy\\-mm\\-dd"));
2550
+ for (const [fs, st] of this._fmtMap) p.push(stFmt(st.nid, fs));
2551
+ p.push(brt(616, new Uint8Array(0)));
2552
+ p.push(base.subarray(fillBeginOff, xfBeginOff));
2553
+ const xh = new Uint8Array(4);
2554
+ new DataView(xh.buffer).setUint16(0, tx, true);
2555
+ p.push(brt(617, xh));
2556
+ p.push(xfRec(0, 0, 0));
2557
+ p.push(xfRec(0, 164, 1));
2558
+ p.push(xfRec(0, 166, 1));
2559
+ p.push(xfRec(1, 0, 0, 1));
2560
+ const sortedXf = [...this._fmtMap.entries()].sort((a, b) => a[1].xf - b[1].xf);
2561
+ for (const [, st] of sortedXf) p.push(xfRec(0, st.nid, 1));
2562
+ p.push(brt(618, new Uint8Array(0)));
2563
+ p.push(base.subarray(xfEndOff + 3));
2564
+ let tl = 0;
2565
+ for (const c of p) tl += c.length;
2566
+ const r = new Uint8Array(tl);
2567
+ let pos = 0;
2568
+ for (const c of p) {
2569
+ r.set(c, pos);
2570
+ pos += c.length;
2571
+ }
2572
+ return r;
2573
+ }
2574
+ addSheet(sheetName, hidden = false) {
2575
+ const s = this._sanitizeSheetName(sheetName);
2576
+ this._sheetCount++;
2577
+ this._sheetList.push({
2578
+ name: s,
2579
+ pathInArchive: `xl/worksheets/sheet${this._sheetCount}.bin`,
2580
+ hidden,
2581
+ nameInArchive: `sheet${this._sheetCount}.bin`,
2582
+ sheetId: this._sheetCount,
2583
+ filterHeaderRange: null
2584
+ });
2585
+ }
2586
+ startSheet(sheetName, columnCount, headers, options = {}) {
2587
+ if (this._isStreaming) throw new Error("Already streaming");
2588
+ const { hidden = false, doAutofilter = true, headerStyle = "bold" } = options;
2589
+ let hs = 3;
2590
+ if (headerStyle === "fill") hs = 4;
2591
+ else if (headerStyle === "bold+fill") hs = 5;
2592
+ this.addSheet(sheetName, hidden);
2593
+ this._isStreaming = true;
2594
+ this._currentSheetBuffer = new BrowserBigBuffer();
2595
+ this._currentSheetRowNum = 0;
2596
+ this._currentSheetStartCol = 0;
2597
+ this._currentSheetEndCol = columnCount;
2598
+ this._currentSheetDoAutofilter = doAutofilter && headers !== void 0;
2599
+ this._colWidths = new Array(columnCount).fill(-1);
2600
+ if (headers) {
2601
+ for (let i = 0; i < columnCount; i++) {
2602
+ const len = headers[i] ? headers[i].length : 0;
2603
+ let w = 1.3 * len + 3;
2604
+ if (w > 80) w = 80;
2605
+ if (this._colWidths[i] < w) this._colWidths[i] = w;
2606
+ }
2607
+ }
2608
+ this._writeSheetHeader(this._currentSheetBuffer, this._currentSheetStartCol, this._currentSheetEndCol, this._currentSheetDoAutofilter);
2609
+ if (headers) {
2610
+ this.createRowHeader(this._currentSheetBuffer, this._currentSheetRowNum, this._currentSheetStartCol, this._currentSheetEndCol);
2611
+ for (let c = 0; c < headers.length; c++) this.writeString(this._currentSheetBuffer, headers[c], c, hs);
2612
+ this._currentSheetRowNum++;
2613
+ }
2614
+ }
2615
+ writeRow(row) {
2616
+ if (!this._isStreaming) throw new Error("Not streaming");
2617
+ const bb = this._currentSheetBuffer;
2618
+ this.createRowHeader(bb, this._currentSheetRowNum, this._currentSheetStartCol, this._currentSheetEndCol);
2619
+ for (let c = 0; c < row.length; c++) this._writeCell(bb, row[c], c);
2620
+ this._currentSheetRowNum++;
2621
+ }
2622
+ endSheet() {
2623
+ if (!this._isStreaming) throw new Error("Not streaming");
2624
+ const bb = this._currentSheetBuffer;
2625
+ bb.write(this._sheet1Bytes.subarray(218, 290));
2626
+ if (this._currentSheetDoAutofilter) {
2627
+ this._autofilterIsOn = true;
2628
+ bb.write(this._autoFilterStartBytes);
2629
+ const rBuf = new Uint8Array(8);
2630
+ const rView = new DataView(rBuf.buffer);
2631
+ rView.setInt32(0, 0, true);
2632
+ rView.setInt32(4, this._currentSheetRowNum - 1, true);
2633
+ bb.write(rBuf);
2634
+ const cBuf = new Uint8Array(8);
2635
+ const cView = new DataView(cBuf.buffer);
2636
+ cView.setInt32(0, this._currentSheetStartCol, true);
2637
+ cView.setInt32(4, this._currentSheetEndCol - 1, true);
2638
+ bb.write(cBuf);
2639
+ bb.write(this._autoFilterEndBytes);
2640
+ this._sheetList[this._sheetCount - 1].filterData = {
2641
+ startRow: 0,
2642
+ endRow: this._currentSheetRowNum - 1,
2643
+ startColumn: this._currentSheetStartCol,
2644
+ endColumn: this._currentSheetEndCol - 1
2645
+ };
2646
+ }
2647
+ bb.write(this._sheet1Bytes.subarray(290));
2648
+ this._zip.addFile(this._sheetList[this._sheetCount - 1].pathInArchive, bb.toUint8Array());
2649
+ this._isStreaming = false;
2650
+ this._currentSheetBuffer = null;
2651
+ }
2652
+ writeSheet(rows, headers = null, options = {}) {
2653
+ const doAutofilter = options.doAutofilter !== false;
2654
+ const headerStyle = options.headerStyle || "bold";
2655
+ let hs = 3;
2656
+ if (headerStyle === "fill") hs = 4;
2657
+ else if (headerStyle === "bold+fill") hs = 5;
2658
+ const bb = new BrowserBigBuffer();
2659
+ let colCount = rows.length > 0 ? rows[0].length : headers ? headers.length : 0;
2660
+ this._colWidths = new Array(colCount).fill(-1);
2661
+ if (headers) {
2662
+ for (let i = 0; i < colCount; i++) {
2663
+ const len = headers[i] ? headers[i].length : 0;
2664
+ let w = 1.3 * len + 3;
2665
+ if (w > 80) w = 80;
2666
+ if (this._colWidths[i] < w) this._colWidths[i] = w;
2667
+ }
2668
+ }
2669
+ for (let r = 0; r < Math.min(rows.length, 100); r++) {
2670
+ for (let c = 0; c < rows[r].length; c++) {
2671
+ const raw = rows[r][c];
2672
+ if (raw == null) continue;
2673
+ const v = isFormattedCell(raw) ? raw.value : raw;
2674
+ const len = v instanceof Date ? 10 : v.toString().length;
2675
+ let w = 1.3 * len + 3;
2676
+ if (w > 80) w = 80;
2677
+ if (this._colWidths[c] < w) this._colWidths[c] = w;
2678
+ }
2679
+ }
2680
+ const doAf = doAutofilter && !!headers;
2681
+ this._writeSheetHeader(bb, 0, colCount, doAf);
2682
+ let rn = 0;
2683
+ if (headers) {
2684
+ this.createRowHeader(bb, rn, 0, colCount);
2685
+ for (let c = 0; c < headers.length; c++) this.writeString(bb, headers[c], c, hs);
2686
+ rn++;
2687
+ }
2688
+ for (let r = 0; r < rows.length; r++) {
2689
+ this.createRowHeader(bb, rn, 0, colCount);
2690
+ for (let c = 0; c < rows[r].length; c++) this._writeCell(bb, rows[r][c], c);
2691
+ rn++;
2692
+ }
2693
+ bb.write(this._sheet1Bytes.subarray(218, 290));
2694
+ if (doAf) {
2695
+ this._autofilterIsOn = true;
2696
+ bb.write(this._autoFilterStartBytes);
2697
+ const rBuf = new Uint8Array(8), rView = new DataView(rBuf.buffer);
2698
+ rView.setInt32(0, 0, true);
2699
+ rView.setInt32(4, rn - 1, true);
2700
+ bb.write(rBuf);
2701
+ const cBuf = new Uint8Array(8), cView = new DataView(cBuf.buffer);
2702
+ cView.setInt32(0, 0, true);
2703
+ cView.setInt32(4, colCount - 1, true);
2704
+ bb.write(cBuf);
2705
+ bb.write(this._autoFilterEndBytes);
2706
+ this._sheetList[this._sheetCount - 1].filterData = {
2707
+ startRow: 0,
2708
+ endRow: rn,
2709
+ startColumn: 0,
2710
+ endColumn: colCount - 1
2711
+ };
2712
+ }
2713
+ bb.write(this._sheet1Bytes.subarray(290));
2714
+ this._zip.addFile(this._sheetList[this._sheetCount - 1].pathInArchive, bb.toUint8Array());
2715
+ }
2716
+ _writeSheetHeader(bb, startCol, endCol, doAf) {
2717
+ const sh = new Uint8Array(this._sheet1Bytes);
2718
+ const shView = new DataView(sh.buffer);
2719
+ shView.setInt32(40, startCol, true);
2720
+ shView.setInt32(44, endCol, true);
2721
+ if (this._sheetCount !== 1) sh[54] = 156;
2722
+ bb.write(sh.subarray(0, 84));
2723
+ if (doAf) bb.write(this._stickHeaderA1bytes);
2724
+ bb.write(sh.subarray(84, 159));
2725
+ bb.writeByte(134);
2726
+ bb.writeByte(3);
2727
+ for (let i = startCol; i < endCol; i++) {
2728
+ bb.writeByte(0);
2729
+ bb.writeByte(60);
2730
+ bb.writeByte(18);
2731
+ bb.writeInt32LE(i);
2732
+ bb.writeInt32LE(i);
2733
+ const w = this._colWidths[i] > 0 ? this._colWidths[i] : 10;
2734
+ bb.writeInt32LE(Math.round(w * 256));
2735
+ bb.writeByte(0);
2736
+ bb.writeByte(0);
2737
+ bb.writeByte(0);
2738
+ bb.writeByte(0);
2739
+ bb.writeByte(2);
2740
+ }
2741
+ bb.writeByte(0);
2742
+ bb.writeByte(135);
2743
+ bb.writeByte(3);
2744
+ bb.writeByte(0);
2745
+ bb.write(sh.subarray(159, 175));
2746
+ bb.write(new Uint8Array([38, 0]));
2747
+ }
2748
+ _writeCell(bb, raw, c) {
2749
+ if (raw === null || raw === void 0) return;
2750
+ const fmtString = getFormat(raw);
2751
+ const val = fmtString !== null ? unwrapCell(raw) : raw;
2752
+ const styleNum = fmtString !== null ? this._registerFormat(fmtString) : 0;
2753
+ if (typeof val === "number") {
2754
+ if (Number.isInteger(val) && val >= this._rRkIntegerLowerLimit && val <= this._rRkIntegerUpperLimit) {
2755
+ this.writeRkNumberInteger(bb, val, c, styleNum);
2756
+ } else {
2757
+ this.writeDouble(bb, val, c, styleNum);
2758
+ }
2759
+ } else if (typeof val === "bigint") {
2760
+ this.writeString(bb, val.toString(), c);
2761
+ } else if (typeof val === "boolean") {
2762
+ this.writeBool(bb, val, c);
2763
+ } else if (val instanceof Date) {
2764
+ const oaDate = (val.getTime() - this._oaEpoch) / 864e5;
2765
+ this.writeDouble(bb, oaDate, c, fmtString !== null ? styleNum : 1);
2766
+ } else {
2767
+ this.writeString(bb, val.toString(), c, 0, fmtString !== null ? styleNum : void 0);
2768
+ }
2769
+ }
2770
+ createRowHeader(bb, rn, sc, ec) {
2771
+ bb.ensureCapacity(27);
2772
+ bb.writeUnsafeByte(0);
2773
+ bb.writeUnsafeByte(25);
2774
+ bb.writeUnsafeInt32LE(rn);
2775
+ bb.writeUnsafeInt32LE(0);
2776
+ bb.writeUnsafeByte(44);
2777
+ bb.writeUnsafeByte(1);
2778
+ bb.writeUnsafeByte(0);
2779
+ bb.writeUnsafeByte(0);
2780
+ bb.writeUnsafeByte(0);
2781
+ bb.writeUnsafeByte(1);
2782
+ bb.writeUnsafeByte(0);
2783
+ bb.writeUnsafeByte(0);
2784
+ bb.writeUnsafeByte(0);
2785
+ bb.writeUnsafeInt32LE(sc);
2786
+ bb.writeUnsafeInt32LE(ec);
2787
+ }
2788
+ writeRkNumberInteger(bb, val, colNum, styleNum = 0) {
2789
+ bb.ensureCapacity(14);
2790
+ bb.writeUnsafeByte(2);
2791
+ bb.writeUnsafeByte(12);
2792
+ bb.writeUnsafeInt32LE(colNum);
2793
+ bb.writeUnsafeByte(styleNum);
2794
+ bb.writeUnsafeByte(0);
2795
+ bb.writeUnsafeByte(0);
2796
+ bb.writeUnsafeByte(0);
2797
+ bb.writeUnsafeInt32LE(val << 2 | 2);
2798
+ }
2799
+ writeDouble(bb, val, colNum, styleNum = 0) {
2800
+ bb.ensureCapacity(18);
2801
+ bb.writeUnsafeByte(5);
2802
+ bb.writeUnsafeByte(16);
2803
+ bb.writeUnsafeInt32LE(colNum);
2804
+ bb.writeUnsafeByte(styleNum);
2805
+ bb.writeUnsafeByte(0);
2806
+ bb.writeUnsafeByte(0);
2807
+ bb.writeUnsafeByte(0);
2808
+ bb.writeUnsafeDoubleLE(val);
2809
+ }
2810
+ writeBool(bb, val, colNum) {
2811
+ bb.ensureCapacity(13);
2812
+ bb.writeUnsafeByte(4);
2813
+ bb.writeUnsafeByte(9);
2814
+ bb.writeUnsafeInt32LE(colNum);
2815
+ bb.writeUnsafeInt32LE(0);
2816
+ bb.writeUnsafeByte(val ? 1 : 0);
2817
+ }
2818
+ writeDateTime(bb, date, colNum) {
2819
+ this.writeDouble(bb, (date.getTime() - this._oaEpoch) / 864e5, colNum, 1);
2820
+ }
2821
+ writeString(bb, val, colNum, styleIndex = 0, styleOverride = void 0) {
2822
+ let index;
2823
+ if (this._sstDic.has(val)) {
2824
+ index = this._sstDic.get(val);
2825
+ } else {
2826
+ index = this._sstCntUnique++;
2827
+ this._sstDic.set(val, index);
2828
+ }
2829
+ this._sstCntAll++;
2830
+ const finalStyle = styleOverride !== void 0 ? styleOverride : styleIndex;
2831
+ bb.ensureCapacity(17);
2832
+ bb.writeUnsafeByte(7);
2833
+ bb.writeUnsafeByte(12);
2834
+ bb.writeUnsafeInt32LE(colNum);
2835
+ bb.writeUnsafeByte(finalStyle);
2836
+ bb.writeUnsafeByte(0);
2837
+ bb.writeUnsafeByte(0);
2838
+ bb.writeUnsafeByte(0);
2839
+ bb.writeUnsafeInt32LE(index);
2840
+ }
2841
+ _saveSst() {
2842
+ const bb = new BrowserBigBuffer();
2843
+ bb.writeByte(159);
2844
+ bb.writeByte(1);
2845
+ bb.writeByte(8);
2846
+ bb.writeInt32LE(this._sstCntUnique);
2847
+ bb.writeInt32LE(this._sstCntAll);
2848
+ for (const [txt] of this._sstDic) {
2849
+ const tl = txt.length;
2850
+ bb.writeByte(19);
2851
+ const rl = 5 + 2 * tl;
2852
+ if (rl >= 128) {
2853
+ bb.writeByte(128 + rl % 128);
2854
+ const tmp = rl >> 7;
2855
+ if (tmp >= 256) bb.writeByte(128 + tmp % 128);
2856
+ else bb.writeByte(tmp);
2857
+ bb.writeByte(rl >> 14);
2858
+ if (rl >> 14 > 0) bb.writeByte(0);
2859
+ } else {
2860
+ bb.writeByte(rl & 255);
2861
+ bb.writeByte(rl >> 8 & 255);
2862
+ }
2863
+ bb.writeInt32LE(tl);
2864
+ bb.writeUtf16LE(txt);
2865
+ }
2866
+ bb.writeByte(160);
2867
+ bb.writeByte(1);
2868
+ bb.writeByte(0);
2869
+ this._zip.addFile("xl/sharedStrings.bin", bb.toUint8Array());
2870
+ }
2871
+ _writeFilterDefinedName(wbBuffers, sheet, sheetNum) {
2872
+ const fd = sheet.filterData;
2873
+ const fix1 = new Uint8Array(this._magicFilterExcel2016Fix1);
2874
+ fix1[7] = sheet.sheetId - 1;
2875
+ fix1[fix1.length - 2] = sheetNum;
2876
+ wbBuffers.push(fix1);
2877
+ const rBuf = new Uint8Array(8), rView = new DataView(rBuf.buffer);
2878
+ rView.setInt32(0, fd.startRow, true);
2879
+ rView.setInt32(4, fd.endRow, true);
2880
+ wbBuffers.push(rBuf);
2881
+ const cBuf = new Uint8Array(4), cView = new DataView(cBuf.buffer);
2882
+ cView.setInt16(0, fd.startColumn, true);
2883
+ cView.setInt16(2, fd.endColumn, true);
2884
+ wbBuffers.push(cBuf);
2885
+ wbBuffers.push(this._magicFilterExcel2016Fix2);
2886
+ }
2887
+ finalize() {
2888
+ this._saveSst();
2889
+ this._zip.addFile("xl/styles.bin", this._buildStylesBin());
2890
+ const wbBuffers = [this._workbookBinStart];
2891
+ for (const sheet of this._sheetList) {
2892
+ const rId = `rId${sheet.sheetId}`;
2893
+ const sn = sheet.name;
2894
+ const rl = 4 + 12 + sn.length * 2 + rId.length * 2;
2895
+ const buf = new Uint8Array(3 + rl);
2896
+ const view = new DataView(buf.buffer);
2897
+ buf[0] = 156;
2898
+ buf[1] = 1;
2899
+ buf[2] = rl;
2900
+ let pos = 3;
2901
+ view.setInt32(pos, sheet.hidden ? 1 : 0, true);
2902
+ pos += 4;
2903
+ view.setInt32(pos, sheet.sheetId, true);
2904
+ pos += 4;
2905
+ view.setInt32(pos, rId.length, true);
2906
+ pos += 4;
2907
+ for (let i = 0; i < rId.length; i++) {
2908
+ const c = rId.charCodeAt(i);
2909
+ buf[pos++] = c & 255;
2910
+ buf[pos++] = c >> 8 & 255;
2911
+ }
2912
+ view.setInt32(pos, sn.length, true);
2913
+ pos += 4;
2914
+ for (let i = 0; i < sn.length; i++) {
2915
+ const c = sn.charCodeAt(i);
2916
+ buf[pos++] = c & 255;
2917
+ buf[pos++] = c >> 8 & 255;
2918
+ }
2919
+ wbBuffers.push(buf);
2920
+ }
2921
+ wbBuffers.push(this._workbookBinMiddle);
2922
+ if (this._autofilterIsOn) {
2923
+ const filtered = this._sheetList.filter((s) => s.filterData);
2924
+ if (filtered.length > 0) {
2925
+ wbBuffers.push(this._magicFilterExcel2016Fix0);
2926
+ const cnt = filtered.length;
2927
+ const firstByte = cnt <= 20 ? 16 + (cnt - 1) * 12 : 128 + (cnt - 21) * 12;
2928
+ wbBuffers.push(cnt <= 10 ? new Uint8Array([firstByte, cnt, 0, 0, 0]) : new Uint8Array([firstByte, Math.floor((cnt - 1) / 10), cnt, 0, 0, 0]));
2929
+ for (let i = 0; i < filtered.length; i++) {
2930
+ const si = filtered[i].sheetId - 1;
2931
+ const ib = new Uint8Array(12);
2932
+ ib[4] = si;
2933
+ ib[8] = si;
2934
+ wbBuffers.push(ib);
2935
+ }
2936
+ wbBuffers.push(new Uint8Array([226, 2, 0]));
2937
+ for (let i = 0; i < filtered.length; i++) this._writeFilterDefinedName(wbBuffers, filtered[i], i);
2938
+ }
2939
+ }
2940
+ wbBuffers.push(this._workbookBinEnd);
2941
+ let totalWbLen = 0;
2942
+ for (const b of wbBuffers) totalWbLen += b.length;
2943
+ const wbFinal = new Uint8Array(totalWbLen);
2944
+ let wbOffset = 0;
2945
+ for (const b of wbBuffers) {
2946
+ wbFinal.set(b, wbOffset);
2947
+ wbOffset += b.length;
2948
+ }
2949
+ this._zip.addFile("xl/workbook.bin", wbFinal);
2950
+ for (const s of this._sheetList) this._zip.addFile(`xl/worksheets/binaryIndex${s.sheetId}.bin`, this._binaryIndexBin);
2951
+ let ct = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2952
+ <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
2953
+ <Default Extension="bin" ContentType="application/vnd.ms-excel.sheet.binary.macroEnabled.main"/>
2954
+ <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
2955
+ <Default Extension="xml" ContentType="application/xml"/>`;
2956
+ for (const s of this._sheetList) {
2957
+ ct += `<Override PartName="/${s.pathInArchive}" ContentType="application/vnd.ms-excel.worksheet"/>
2958
+ <Override PartName="/xl/worksheets/binaryIndex${s.sheetId}.bin" ContentType="application/vnd.ms-excel.binIndexWs"/>
2959
+ `;
2960
+ }
2961
+ ct += `<Override PartName="/xl/styles.bin" ContentType="application/vnd.ms-excel.styles"/>
2962
+ <Override PartName="/xl/sharedStrings.bin" ContentType="application/vnd.ms-excel.sharedStrings"/>
2963
+ </Types>`;
2964
+ this._zip.addFile("[Content_Types].xml", ct);
2965
+ let wr = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2966
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
2967
+ `;
2968
+ for (const s of this._sheetList) wr += `<Relationship Id="rId${s.sheetId}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/${s.nameInArchive}"/>
2969
+ `;
2970
+ wr += `<Relationship Id="rId${this._sheetList.length + 2}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.bin"/>
2971
+ <Relationship Id="rId${this._sheetList.length + 3}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Target="sharedStrings.bin"/>
2972
+ </Relationships>`;
2973
+ this._zip.addFile("xl/_rels/workbook.bin.rels", wr);
2974
+ this._zip.addFile("_rels/.rels", `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2975
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
2976
+ <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.bin"/>
2977
+ </Relationships>`);
2978
+ for (const s of this._sheetList) {
2979
+ this._zip.addFile(`xl/worksheets/_rels/${s.nameInArchive}.rels`, `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2980
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
2981
+ <Relationship Id="rId1" Type="http://schemas.microsoft.com/office/2006/relationships/xlBinaryIndex" Target="binaryIndex${s.sheetId}.bin"/>
2982
+ </Relationships>`);
2983
+ }
2984
+ return this._zip.toBlob();
2985
+ }
2986
+ };
2987
+
2988
+ // src/browser/download.ts
2989
+ function triggerDownload(blob, fileName) {
2990
+ const url = URL.createObjectURL(blob);
2991
+ const a = document.createElement("a");
2992
+ a.href = url;
2993
+ a.download = fileName;
2994
+ document.body.appendChild(a);
2995
+ a.click();
2996
+ document.body.removeChild(a);
2997
+ setTimeout(() => URL.revokeObjectURL(url), 5e3);
2998
+ }
2999
+ function downloadXlsx(fileName, rows, headers, sheetName = "Sheet1") {
3000
+ const w = new BrowserXlsxWriter();
3001
+ w.addSheet(sheetName);
3002
+ w.writeSheet(rows, headers, { doAutofilter: true });
3003
+ triggerDownload(w.finalize(), fileName);
3004
+ }
3005
+ function downloadXlsxMultiSheet(fileName, sheets) {
3006
+ const w = new BrowserXlsxWriter();
3007
+ for (const s of sheets) {
3008
+ w.addSheet(s.name);
3009
+ w.writeSheet(s.rows, s.headers, { doAutofilter: true });
3010
+ }
3011
+ triggerDownload(w.finalize(), fileName);
3012
+ }
3013
+ function downloadXlsb(fileName, rows, headers, sheetName = "Sheet1") {
3014
+ const w = new BrowserXlsbWriter();
3015
+ w.addSheet(sheetName);
3016
+ w.writeSheet(rows, headers, { doAutofilter: true });
3017
+ triggerDownload(w.finalize(), fileName);
3018
+ }
3019
+ function downloadXlsbMultiSheet(fileName, sheets) {
3020
+ const w = new BrowserXlsbWriter();
3021
+ for (const s of sheets) {
3022
+ w.addSheet(s.name);
3023
+ w.writeSheet(s.rows, s.headers, { doAutofilter: true });
3024
+ }
3025
+ triggerDownload(w.finalize(), fileName);
3026
+ }
3027
+ export {
3028
+ BrowserBigBuffer,
3029
+ BrowserXlsbWriter,
3030
+ BrowserXlsxWriter,
3031
+ BrowserZip,
3032
+ F,
3033
+ downloadXlsb,
3034
+ downloadXlsbMultiSheet,
3035
+ downloadXlsx,
3036
+ downloadXlsxMultiSheet
3037
+ };