@cj-tech-master/excelts 1.4.5 → 1.5.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 (49) hide show
  1. package/dist/browser/excelts.iife.js +454 -159
  2. package/dist/browser/excelts.iife.js.map +1 -1
  3. package/dist/browser/excelts.iife.min.js +28 -28
  4. package/dist/cjs/doc/anchor.js +25 -11
  5. package/dist/cjs/doc/cell.js +75 -43
  6. package/dist/cjs/doc/column.js +74 -22
  7. package/dist/cjs/doc/defined-names.js +53 -7
  8. package/dist/cjs/doc/image.js +11 -8
  9. package/dist/cjs/doc/range.js +64 -28
  10. package/dist/cjs/doc/row.js +72 -31
  11. package/dist/cjs/doc/table.js +3 -5
  12. package/dist/cjs/doc/workbook.js +30 -6
  13. package/dist/cjs/doc/worksheet.js +165 -41
  14. package/dist/cjs/utils/sheet-utils.js +3 -1
  15. package/dist/cjs/utils/unzip/extract.js +30 -82
  16. package/dist/cjs/utils/unzip/index.js +18 -2
  17. package/dist/cjs/utils/unzip/zip-parser.js +458 -0
  18. package/dist/esm/doc/anchor.js +25 -11
  19. package/dist/esm/doc/cell.js +75 -43
  20. package/dist/esm/doc/column.js +74 -22
  21. package/dist/esm/doc/defined-names.js +53 -7
  22. package/dist/esm/doc/image.js +11 -8
  23. package/dist/esm/doc/range.js +64 -28
  24. package/dist/esm/doc/row.js +72 -31
  25. package/dist/esm/doc/table.js +3 -5
  26. package/dist/esm/doc/workbook.js +30 -6
  27. package/dist/esm/doc/worksheet.js +165 -41
  28. package/dist/esm/utils/sheet-utils.js +3 -1
  29. package/dist/esm/utils/unzip/extract.js +28 -82
  30. package/dist/esm/utils/unzip/index.js +17 -2
  31. package/dist/esm/utils/unzip/zip-parser.js +451 -0
  32. package/dist/types/doc/anchor.d.ts +14 -7
  33. package/dist/types/doc/cell.d.ts +78 -37
  34. package/dist/types/doc/column.d.ts +72 -36
  35. package/dist/types/doc/defined-names.d.ts +11 -8
  36. package/dist/types/doc/image.d.ts +29 -12
  37. package/dist/types/doc/pivot-table.d.ts +1 -1
  38. package/dist/types/doc/range.d.ts +15 -4
  39. package/dist/types/doc/row.d.ts +78 -40
  40. package/dist/types/doc/table.d.ts +21 -36
  41. package/dist/types/doc/workbook.d.ts +54 -34
  42. package/dist/types/doc/worksheet.d.ts +255 -83
  43. package/dist/types/stream/xlsx/worksheet-reader.d.ts +3 -5
  44. package/dist/types/types.d.ts +86 -26
  45. package/dist/types/utils/col-cache.d.ts +11 -8
  46. package/dist/types/utils/unzip/extract.d.ts +16 -14
  47. package/dist/types/utils/unzip/index.d.ts +15 -1
  48. package/dist/types/utils/unzip/zip-parser.d.ts +92 -0
  49. package/package.json +1 -1
@@ -0,0 +1,451 @@
1
+ /**
2
+ * Pure Uint8Array-based ZIP parser
3
+ * Works in both Node.js and browser environments
4
+ * No dependency on Node.js stream module
5
+ */
6
+ import { decompress, decompressSync } from "../zip/compress.js";
7
+ // ZIP file signatures
8
+ const LOCAL_FILE_HEADER_SIG = 0x04034b50;
9
+ const CENTRAL_DIR_HEADER_SIG = 0x02014b50;
10
+ const END_OF_CENTRAL_DIR_SIG = 0x06054b50;
11
+ const ZIP64_END_OF_CENTRAL_DIR_SIG = 0x06064b50;
12
+ const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG = 0x07064b50;
13
+ // Compression methods
14
+ const COMPRESSION_STORED = 0;
15
+ const COMPRESSION_DEFLATE = 8;
16
+ /**
17
+ * Parse DOS date/time format to JavaScript Date
18
+ * Dates in zip file entries are stored as DosDateTime
19
+ * Spec: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-dosdatetimetofiletime
20
+ */
21
+ function parseDateTime(date, time) {
22
+ const day = date & 0x1f;
23
+ const month = (date >> 5) & 0x0f;
24
+ const year = ((date >> 9) & 0x7f) + 1980;
25
+ const seconds = time ? (time & 0x1f) * 2 : 0;
26
+ const minutes = time ? (time >> 5) & 0x3f : 0;
27
+ const hours = time ? time >> 11 : 0;
28
+ return new Date(Date.UTC(year, month - 1, day, hours, minutes, seconds));
29
+ }
30
+ /**
31
+ * Parse ZIP64 extra field
32
+ */
33
+ function parseZip64ExtraField(extraField, compressedSize, uncompressedSize, localHeaderOffset) {
34
+ const view = new DataView(extraField.buffer, extraField.byteOffset, extraField.byteLength);
35
+ let offset = 0;
36
+ while (offset + 4 <= extraField.length) {
37
+ const signature = view.getUint16(offset, true);
38
+ const partSize = view.getUint16(offset + 2, true);
39
+ if (signature === 0x0001) {
40
+ // ZIP64 extended information
41
+ let fieldOffset = offset + 4;
42
+ if (uncompressedSize === 0xffffffff && fieldOffset + 8 <= offset + 4 + partSize) {
43
+ uncompressedSize = Number(view.getBigUint64(fieldOffset, true));
44
+ fieldOffset += 8;
45
+ }
46
+ if (compressedSize === 0xffffffff && fieldOffset + 8 <= offset + 4 + partSize) {
47
+ compressedSize = Number(view.getBigUint64(fieldOffset, true));
48
+ fieldOffset += 8;
49
+ }
50
+ if (localHeaderOffset === 0xffffffff && fieldOffset + 8 <= offset + 4 + partSize) {
51
+ localHeaderOffset = Number(view.getBigUint64(fieldOffset, true));
52
+ }
53
+ break;
54
+ }
55
+ offset += 4 + partSize;
56
+ }
57
+ return { compressedSize, uncompressedSize, localHeaderOffset };
58
+ }
59
+ /**
60
+ * DataView helper for reading little-endian values
61
+ */
62
+ class BinaryReader {
63
+ constructor(data, offset = 0) {
64
+ this.data = data;
65
+ this.view = new DataView(data.buffer, data.byteOffset, data.byteLength);
66
+ this.offset = offset;
67
+ }
68
+ get position() {
69
+ return this.offset;
70
+ }
71
+ set position(value) {
72
+ this.offset = value;
73
+ }
74
+ get remaining() {
75
+ return this.data.length - this.offset;
76
+ }
77
+ readUint8() {
78
+ const value = this.view.getUint8(this.offset);
79
+ this.offset += 1;
80
+ return value;
81
+ }
82
+ readUint16() {
83
+ const value = this.view.getUint16(this.offset, true);
84
+ this.offset += 2;
85
+ return value;
86
+ }
87
+ readUint32() {
88
+ const value = this.view.getUint32(this.offset, true);
89
+ this.offset += 4;
90
+ return value;
91
+ }
92
+ readBigUint64() {
93
+ const value = this.view.getBigUint64(this.offset, true);
94
+ this.offset += 8;
95
+ return value;
96
+ }
97
+ readBytes(length) {
98
+ const bytes = this.data.subarray(this.offset, this.offset + length);
99
+ this.offset += length;
100
+ return bytes;
101
+ }
102
+ readString(length, utf8 = true) {
103
+ const bytes = this.readBytes(length);
104
+ if (utf8) {
105
+ return new TextDecoder("utf-8").decode(bytes);
106
+ }
107
+ // Fallback to ASCII/Latin-1
108
+ return String.fromCharCode(...bytes);
109
+ }
110
+ skip(length) {
111
+ this.offset += length;
112
+ }
113
+ slice(start, end) {
114
+ return this.data.subarray(start, end);
115
+ }
116
+ peekUint32(offset) {
117
+ return this.view.getUint32(offset, true);
118
+ }
119
+ }
120
+ /**
121
+ * Find the End of Central Directory record
122
+ * Searches backwards from the end of the file
123
+ */
124
+ function findEndOfCentralDir(data) {
125
+ // EOCD is at least 22 bytes, search backwards
126
+ // Comment can be up to 65535 bytes
127
+ const minOffset = Math.max(0, data.length - 65557);
128
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
129
+ for (let i = data.length - 22; i >= minOffset; i--) {
130
+ if (view.getUint32(i, true) === END_OF_CENTRAL_DIR_SIG) {
131
+ return i;
132
+ }
133
+ }
134
+ return -1;
135
+ }
136
+ /**
137
+ * Find ZIP64 End of Central Directory Locator
138
+ */
139
+ function findZip64EOCDLocator(data, eocdOffset) {
140
+ // ZIP64 EOCD Locator is 20 bytes and appears right before EOCD
141
+ const locatorOffset = eocdOffset - 20;
142
+ if (locatorOffset < 0) {
143
+ return -1;
144
+ }
145
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
146
+ if (view.getUint32(locatorOffset, true) === ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIG) {
147
+ return locatorOffset;
148
+ }
149
+ return -1;
150
+ }
151
+ /**
152
+ * Parse ZIP file entries from Central Directory
153
+ */
154
+ export function parseZipEntries(data, options = {}) {
155
+ const { decodeStrings = true } = options;
156
+ const entries = [];
157
+ // Find End of Central Directory
158
+ const eocdOffset = findEndOfCentralDir(data);
159
+ if (eocdOffset === -1) {
160
+ throw new Error("Invalid ZIP file: End of Central Directory not found");
161
+ }
162
+ const reader = new BinaryReader(data, eocdOffset);
163
+ // Read EOCD
164
+ // Offset Size Description
165
+ // 0 4 EOCD signature (0x06054b50)
166
+ // 4 2 Number of this disk
167
+ // 6 2 Disk where central directory starts
168
+ // 8 2 Number of central directory records on this disk
169
+ // 10 2 Total number of central directory records
170
+ // 12 4 Size of central directory (bytes)
171
+ // 16 4 Offset of start of central directory
172
+ // 20 2 Comment length
173
+ reader.skip(4); // signature
174
+ reader.skip(2); // disk number
175
+ reader.skip(2); // disk where central dir starts
176
+ reader.skip(2); // entries on this disk
177
+ let totalEntries = reader.readUint16(); // total entries
178
+ let centralDirSize = reader.readUint32();
179
+ let centralDirOffset = reader.readUint32();
180
+ // Check for ZIP64
181
+ const zip64LocatorOffset = findZip64EOCDLocator(data, eocdOffset);
182
+ if (zip64LocatorOffset !== -1) {
183
+ const locatorReader = new BinaryReader(data, zip64LocatorOffset);
184
+ locatorReader.skip(4); // signature
185
+ locatorReader.skip(4); // disk number with ZIP64 EOCD
186
+ const zip64EOCDOffset = Number(locatorReader.readBigUint64());
187
+ // Read ZIP64 EOCD
188
+ const zip64Reader = new BinaryReader(data, zip64EOCDOffset);
189
+ const zip64Sig = zip64Reader.readUint32();
190
+ if (zip64Sig === ZIP64_END_OF_CENTRAL_DIR_SIG) {
191
+ zip64Reader.skip(8); // size of ZIP64 EOCD
192
+ zip64Reader.skip(2); // version made by
193
+ zip64Reader.skip(2); // version needed
194
+ zip64Reader.skip(4); // disk number
195
+ zip64Reader.skip(4); // disk with central dir
196
+ const zip64TotalEntries = Number(zip64Reader.readBigUint64());
197
+ const zip64CentralDirSize = Number(zip64Reader.readBigUint64());
198
+ const zip64CentralDirOffset = Number(zip64Reader.readBigUint64());
199
+ // Use ZIP64 values if standard values are maxed out
200
+ if (totalEntries === 0xffff) {
201
+ totalEntries = zip64TotalEntries;
202
+ }
203
+ if (centralDirSize === 0xffffffff) {
204
+ centralDirSize = zip64CentralDirSize;
205
+ }
206
+ if (centralDirOffset === 0xffffffff) {
207
+ centralDirOffset = zip64CentralDirOffset;
208
+ }
209
+ }
210
+ }
211
+ // Read Central Directory entries
212
+ const centralReader = new BinaryReader(data, centralDirOffset);
213
+ for (let i = 0; i < totalEntries; i++) {
214
+ const sig = centralReader.readUint32();
215
+ if (sig !== CENTRAL_DIR_HEADER_SIG) {
216
+ throw new Error(`Invalid Central Directory header signature at entry ${i}`);
217
+ }
218
+ // Central Directory File Header format:
219
+ // Offset Size Description
220
+ // 0 4 Central directory file header signature (0x02014b50)
221
+ // 4 2 Version made by
222
+ // 6 2 Version needed to extract
223
+ // 8 2 General purpose bit flag
224
+ // 10 2 Compression method
225
+ // 12 2 File last modification time
226
+ // 14 2 File last modification date
227
+ // 16 4 CRC-32
228
+ // 20 4 Compressed size
229
+ // 24 4 Uncompressed size
230
+ // 28 2 File name length
231
+ // 30 2 Extra field length
232
+ // 32 2 File comment length
233
+ // 34 2 Disk number where file starts
234
+ // 36 2 Internal file attributes
235
+ // 38 4 External file attributes
236
+ // 42 4 Relative offset of local file header
237
+ // 46 n File name
238
+ // 46+n m Extra field
239
+ // 46+n+m k File comment
240
+ centralReader.skip(2); // version made by
241
+ centralReader.skip(2); // version needed
242
+ const flags = centralReader.readUint16();
243
+ const compressionMethod = centralReader.readUint16();
244
+ const lastModTime = centralReader.readUint16();
245
+ const lastModDate = centralReader.readUint16();
246
+ const crc32 = centralReader.readUint32();
247
+ let compressedSize = centralReader.readUint32();
248
+ let uncompressedSize = centralReader.readUint32();
249
+ const fileNameLength = centralReader.readUint16();
250
+ const extraFieldLength = centralReader.readUint16();
251
+ const commentLength = centralReader.readUint16();
252
+ centralReader.skip(2); // disk number start
253
+ centralReader.skip(2); // internal attributes
254
+ const externalAttributes = centralReader.readUint32();
255
+ let localHeaderOffset = centralReader.readUint32();
256
+ // Check for UTF-8 flag (bit 11)
257
+ const isUtf8 = (flags & 0x800) !== 0;
258
+ const useUtf8 = decodeStrings && isUtf8;
259
+ const fileName = centralReader.readString(fileNameLength, useUtf8);
260
+ const extraField = centralReader.readBytes(extraFieldLength);
261
+ const comment = centralReader.readString(commentLength, useUtf8);
262
+ // Parse extra field for ZIP64 values
263
+ if (extraFieldLength > 0) {
264
+ const parsed = parseZip64ExtraField(extraField, compressedSize, uncompressedSize, localHeaderOffset);
265
+ compressedSize = parsed.compressedSize;
266
+ uncompressedSize = parsed.uncompressedSize;
267
+ localHeaderOffset = parsed.localHeaderOffset;
268
+ }
269
+ const isDirectory = fileName.endsWith("/") || (externalAttributes & 0x10) !== 0;
270
+ const isEncrypted = (flags & 0x01) !== 0;
271
+ entries.push({
272
+ path: fileName,
273
+ isDirectory,
274
+ compressedSize,
275
+ uncompressedSize,
276
+ compressionMethod,
277
+ crc32,
278
+ lastModified: parseDateTime(lastModDate, lastModTime),
279
+ localHeaderOffset,
280
+ comment,
281
+ externalAttributes,
282
+ isEncrypted
283
+ });
284
+ }
285
+ return entries;
286
+ }
287
+ /**
288
+ * Extract file data for a specific entry
289
+ */
290
+ export async function extractEntryData(data, entry) {
291
+ if (entry.isDirectory) {
292
+ return new Uint8Array(0);
293
+ }
294
+ if (entry.isEncrypted) {
295
+ throw new Error(`File "${entry.path}" is encrypted and cannot be extracted`);
296
+ }
297
+ const reader = new BinaryReader(data, entry.localHeaderOffset);
298
+ // Read local file header
299
+ const sig = reader.readUint32();
300
+ if (sig !== LOCAL_FILE_HEADER_SIG) {
301
+ throw new Error(`Invalid local file header signature for "${entry.path}"`);
302
+ }
303
+ reader.skip(2); // version needed
304
+ reader.skip(2); // flags
305
+ reader.skip(2); // compression method
306
+ reader.skip(2); // last mod time
307
+ reader.skip(2); // last mod date
308
+ reader.skip(4); // crc32
309
+ reader.skip(4); // compressed size
310
+ reader.skip(4); // uncompressed size
311
+ const fileNameLength = reader.readUint16();
312
+ const extraFieldLength = reader.readUint16();
313
+ reader.skip(fileNameLength);
314
+ reader.skip(extraFieldLength);
315
+ // Extract compressed data
316
+ const compressedData = reader.readBytes(entry.compressedSize);
317
+ // Decompress if needed
318
+ if (entry.compressionMethod === COMPRESSION_STORED) {
319
+ return compressedData;
320
+ }
321
+ else if (entry.compressionMethod === COMPRESSION_DEFLATE) {
322
+ return decompress(compressedData);
323
+ }
324
+ else {
325
+ throw new Error(`Unsupported compression method: ${entry.compressionMethod}`);
326
+ }
327
+ }
328
+ /**
329
+ * Extract file data synchronously (Node.js only)
330
+ */
331
+ export function extractEntryDataSync(data, entry) {
332
+ if (entry.isDirectory) {
333
+ return new Uint8Array(0);
334
+ }
335
+ if (entry.isEncrypted) {
336
+ throw new Error(`File "${entry.path}" is encrypted and cannot be extracted`);
337
+ }
338
+ const reader = new BinaryReader(data, entry.localHeaderOffset);
339
+ // Read local file header
340
+ const sig = reader.readUint32();
341
+ if (sig !== LOCAL_FILE_HEADER_SIG) {
342
+ throw new Error(`Invalid local file header signature for "${entry.path}"`);
343
+ }
344
+ reader.skip(2); // version needed
345
+ reader.skip(2); // flags
346
+ reader.skip(2); // compression method
347
+ reader.skip(2); // last mod time
348
+ reader.skip(2); // last mod date
349
+ reader.skip(4); // crc32
350
+ reader.skip(4); // compressed size
351
+ reader.skip(4); // uncompressed size
352
+ const fileNameLength = reader.readUint16();
353
+ const extraFieldLength = reader.readUint16();
354
+ reader.skip(fileNameLength);
355
+ reader.skip(extraFieldLength);
356
+ // Extract compressed data
357
+ const compressedData = reader.readBytes(entry.compressedSize);
358
+ // Decompress if needed
359
+ if (entry.compressionMethod === COMPRESSION_STORED) {
360
+ return compressedData;
361
+ }
362
+ else if (entry.compressionMethod === COMPRESSION_DEFLATE) {
363
+ return decompressSync(compressedData);
364
+ }
365
+ else {
366
+ throw new Error(`Unsupported compression method: ${entry.compressionMethod}`);
367
+ }
368
+ }
369
+ /**
370
+ * High-level ZIP parser class
371
+ */
372
+ export class ZipParser {
373
+ constructor(data, options = {}) {
374
+ this.data = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
375
+ this.entries = parseZipEntries(this.data, options);
376
+ this.entryMap = new Map(this.entries.map(e => [e.path, e]));
377
+ }
378
+ /**
379
+ * Get all entries in the ZIP file
380
+ */
381
+ getEntries() {
382
+ return this.entries;
383
+ }
384
+ /**
385
+ * Get entry by path
386
+ */
387
+ getEntry(path) {
388
+ return this.entryMap.get(path);
389
+ }
390
+ /**
391
+ * Check if entry exists
392
+ */
393
+ hasEntry(path) {
394
+ return this.entryMap.has(path);
395
+ }
396
+ /**
397
+ * List all file paths
398
+ */
399
+ listFiles() {
400
+ return this.entries.map(e => e.path);
401
+ }
402
+ /**
403
+ * Extract a single file (async)
404
+ */
405
+ async extract(path) {
406
+ const entry = this.entryMap.get(path);
407
+ if (!entry) {
408
+ return null;
409
+ }
410
+ return extractEntryData(this.data, entry);
411
+ }
412
+ /**
413
+ * Extract a single file (sync, Node.js only)
414
+ */
415
+ extractSync(path) {
416
+ const entry = this.entryMap.get(path);
417
+ if (!entry) {
418
+ return null;
419
+ }
420
+ return extractEntryDataSync(this.data, entry);
421
+ }
422
+ /**
423
+ * Extract all files (async)
424
+ */
425
+ async extractAll() {
426
+ const result = new Map();
427
+ for (const entry of this.entries) {
428
+ const data = await extractEntryData(this.data, entry);
429
+ result.set(entry.path, data);
430
+ }
431
+ return result;
432
+ }
433
+ /**
434
+ * Iterate over entries with async callback
435
+ */
436
+ async forEach(callback) {
437
+ for (const entry of this.entries) {
438
+ let dataPromise = null;
439
+ const getData = () => {
440
+ if (!dataPromise) {
441
+ dataPromise = extractEntryData(this.data, entry);
442
+ }
443
+ return dataPromise;
444
+ };
445
+ const shouldContinue = await callback(entry, getData);
446
+ if (shouldContinue === false) {
447
+ break;
448
+ }
449
+ }
450
+ }
451
+ }
@@ -1,26 +1,33 @@
1
1
  import type { Worksheet } from "./worksheet.js";
2
+ interface AnchorModel {
3
+ nativeCol: number;
4
+ nativeRow: number;
5
+ nativeColOff: number;
6
+ nativeRowOff: number;
7
+ }
2
8
  interface SimpleAddress {
3
- col?: number;
4
- row?: number;
9
+ col: number;
10
+ row: number;
5
11
  }
6
- type AddressInput = string | Anchor | SimpleAddress | null | undefined;
12
+ type AddressInput = string | AnchorModel | SimpleAddress;
7
13
  declare class Anchor {
8
14
  nativeCol: number;
9
15
  nativeRow: number;
10
16
  nativeColOff: number;
11
17
  nativeRowOff: number;
12
18
  worksheet?: Worksheet;
13
- constructor(worksheet?: Worksheet, address?: AddressInput, offset?: number);
14
- static asInstance(model: any): Anchor | null;
19
+ constructor(worksheet?: Worksheet, address?: AddressInput | null, offset?: number);
20
+ static asInstance(model: AddressInput | Anchor | null | undefined): Anchor | null;
15
21
  get col(): number;
16
22
  set col(v: number);
17
23
  get row(): number;
18
24
  set row(v: number);
19
25
  get colWidth(): number;
20
26
  get rowHeight(): number;
21
- get model(): Pick<Anchor, "nativeCol" | "nativeRow" | "nativeColOff" | "nativeRowOff">;
22
- set model(value: Pick<Anchor, "nativeCol" | "nativeRow" | "nativeColOff" | "nativeRowOff">);
27
+ get model(): AnchorModel;
28
+ set model(value: AnchorModel);
23
29
  }
24
30
  export { Anchor };
31
+ export type { AnchorModel };
25
32
  type IAnchor = Pick<InstanceType<typeof Anchor>, "col" | "row" | "nativeCol" | "nativeRow" | "nativeColOff" | "nativeRowOff">;
26
33
  export type { IAnchor };
@@ -1,19 +1,57 @@
1
+ import { Note } from "./note.js";
1
2
  import type { Row } from "./row.js";
2
3
  import type { Column } from "./column.js";
3
4
  import type { Worksheet } from "./worksheet.js";
4
5
  import type { Workbook } from "./workbook.js";
6
+ import type { Style, NumFmt, Font, Alignment, Protection, Borders, Fill, CellRichTextValue, CellErrorValue, DataValidation, CellValue, CellHyperlinkValue } from "../types.js";
7
+ export type HyperlinkValueData = CellHyperlinkValue;
8
+ export type FormulaResult = string | number | boolean | Date | CellErrorValue;
9
+ export interface FormulaValueData {
10
+ shareType?: string;
11
+ ref?: string;
12
+ formula?: string;
13
+ sharedFormula?: string;
14
+ result?: FormulaResult;
15
+ date1904?: boolean;
16
+ }
5
17
  interface FullAddress {
6
18
  sheetName: string;
7
19
  address: string;
8
20
  row: number;
9
21
  col: number;
10
22
  }
11
- interface CellModel {
23
+ export interface CellAddress {
24
+ address: string;
25
+ row: number;
26
+ col: number;
27
+ $col$row?: string;
28
+ }
29
+ export interface NoteText {
30
+ text: string;
31
+ font?: Record<string, unknown>;
32
+ }
33
+ export interface NoteConfig {
34
+ texts?: NoteText[];
35
+ margins?: {
36
+ insetmode?: string;
37
+ inset?: number[];
38
+ };
39
+ protection?: {
40
+ locked?: string;
41
+ lockText?: string;
42
+ };
43
+ editAs?: string;
44
+ }
45
+ export interface NoteModel {
46
+ type: string;
47
+ note: NoteConfig;
48
+ }
49
+ export interface CellModel {
12
50
  address: string;
13
51
  type: number;
14
- value?: any;
15
- style?: any;
16
- comment?: any;
52
+ value?: number | string | boolean | Date | CellRichTextValue | CellErrorValue | HyperlinkValueData;
53
+ style?: Partial<Style>;
54
+ comment?: NoteModel;
17
55
  text?: string;
18
56
  hyperlink?: string;
19
57
  tooltip?: string;
@@ -22,38 +60,39 @@ interface CellModel {
22
60
  ref?: string;
23
61
  formula?: string;
24
62
  sharedFormula?: string;
25
- result?: any;
26
- richText?: any[];
27
- sharedString?: any;
28
- error?: any;
29
- rawValue?: any;
63
+ result?: FormulaResult;
64
+ richText?: CellRichTextValue;
65
+ sharedString?: number;
66
+ error?: CellErrorValue;
67
+ rawValue?: unknown;
30
68
  }
69
+ export type CellValueType = CellValue;
31
70
  declare class Cell {
32
71
  static Types: typeof import("./enums.js").ValueType;
33
- _row: Row;
34
- _column: Column;
35
- _address: string;
36
- _value: any;
37
- style: Record<string, unknown>;
38
- _mergeCount: number;
39
- _comment?: any;
72
+ private _row;
73
+ private _column;
74
+ private _address;
75
+ private _value;
76
+ style: Partial<Style>;
77
+ private _mergeCount;
78
+ private _comment?;
40
79
  constructor(row: Row, column: Column, address: string);
41
80
  get worksheet(): Worksheet;
42
81
  get workbook(): Workbook;
43
82
  destroy(): void;
44
- get numFmt(): any;
45
- set numFmt(value: any);
46
- get font(): any;
47
- set font(value: any);
48
- get alignment(): any;
49
- set alignment(value: any);
50
- get border(): any;
51
- set border(value: any);
52
- get fill(): any;
53
- set fill(value: any);
54
- get protection(): any;
55
- set protection(value: any);
56
- _mergeStyle(rowStyle: any, colStyle: any, style: any): any;
83
+ get numFmt(): string | NumFmt | undefined;
84
+ set numFmt(value: string | undefined);
85
+ get font(): Partial<Font> | undefined;
86
+ set font(value: Partial<Font> | undefined);
87
+ get alignment(): Partial<Alignment> | undefined;
88
+ set alignment(value: Partial<Alignment> | undefined);
89
+ get border(): Partial<Borders> | undefined;
90
+ set border(value: Partial<Borders> | undefined);
91
+ get fill(): Fill | undefined;
92
+ set fill(value: Fill | undefined);
93
+ get protection(): Partial<Protection> | undefined;
94
+ set protection(value: Partial<Protection> | undefined);
95
+ private _mergeStyle;
57
96
  get address(): string;
58
97
  get row(): number;
59
98
  get col(): number;
@@ -70,16 +109,18 @@ declare class Cell {
70
109
  get master(): Cell;
71
110
  get isHyperlink(): boolean;
72
111
  get hyperlink(): string | undefined;
73
- get value(): any;
74
- set value(v: any);
75
- get note(): string | undefined;
76
- set note(note: string);
112
+ get value(): CellValueType;
113
+ set value(v: CellValueType);
114
+ get note(): string | NoteConfig | undefined;
115
+ set note(note: string | NoteConfig);
116
+ get comment(): Note | undefined;
117
+ set comment(comment: Note | NoteConfig | undefined);
77
118
  get text(): string;
78
119
  get html(): string;
79
120
  toString(): string;
80
121
  _upgradeToHyperlink(hyperlink: string): void;
81
122
  get formula(): string | undefined;
82
- get result(): any;
123
+ get result(): FormulaResult | undefined;
83
124
  get formulaType(): number;
84
125
  get fullAddress(): FullAddress;
85
126
  get name(): string;
@@ -89,9 +130,9 @@ declare class Cell {
89
130
  addName(name: string): void;
90
131
  removeName(name: string): void;
91
132
  removeAllNames(): void;
92
- get _dataValidations(): any;
93
- get dataValidation(): any;
94
- set dataValidation(value: any);
133
+ private get _dataValidations();
134
+ get dataValidation(): DataValidation | undefined;
135
+ set dataValidation(value: DataValidation);
95
136
  get model(): CellModel;
96
137
  set model(value: CellModel);
97
138
  }