@cj-tech-master/excelts 1.4.5-canary.20251212064440.3eb099f → 1.4.5-canary.20251212160853.7621827

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.
@@ -45,9 +45,6 @@ interface WorksheetOptions {
45
45
  views?: Partial<WorksheetView>[];
46
46
  autoFilter?: AutoFilter | null;
47
47
  }
48
- interface EachRowOptions {
49
- includeEmpty?: boolean;
50
- }
51
48
  interface PageSetupMargins {
52
49
  left: number;
53
50
  right: number;
@@ -140,62 +137,212 @@ declare class Worksheet {
140
137
  constructor(options: WorksheetOptions);
141
138
  get name(): string;
142
139
  set name(name: string | undefined);
140
+ /**
141
+ * The workbook that contains this worksheet
142
+ */
143
143
  get workbook(): Workbook;
144
+ /**
145
+ * When you're done with this worksheet, call this to remove from workbook
146
+ */
144
147
  destroy(): void;
148
+ /**
149
+ * Get the bounding range of the cells in this worksheet
150
+ */
145
151
  get dimensions(): Range;
152
+ /**
153
+ * Get the current columns array
154
+ */
146
155
  get columns(): Column[];
156
+ /**
157
+ * Add column headers and define column keys and widths.
158
+ *
159
+ * Note: these column structures are a workbook-building convenience only,
160
+ * apart from the column width, they will not be fully persisted.
161
+ */
147
162
  set columns(value: ColumnDefn[]);
148
163
  getColumnKey(key: string): Column | undefined;
149
164
  setColumnKey(key: string, value: Column): void;
150
165
  deleteColumnKey(key: string): void;
151
166
  eachColumnKey(f: (column: Column, key: string) => void): void;
167
+ /**
168
+ * Access an individual column by key, letter and 1-based column number
169
+ */
152
170
  getColumn(c: string | number): Column;
171
+ /**
172
+ * Cut one or more columns (columns to the right are shifted left)
173
+ * and optionally insert more
174
+ *
175
+ * If column properties have been defined, they will be cut or moved accordingly
176
+ *
177
+ * Known Issue: If a splice causes any merged cells to move, the results may be unpredictable
178
+ *
179
+ * Also: If the worksheet has more rows than values in the column inserts,
180
+ * the rows will still be shifted as if the values existed
181
+ */
153
182
  spliceColumns(start: number, count: number, ...inserts: CellValue[][]): void;
183
+ /**
184
+ * Get the last column in a worksheet
185
+ */
154
186
  get lastColumn(): Column;
187
+ /**
188
+ * The total column size of the document. Equal to the maximum cell count from all of the rows
189
+ */
155
190
  get columnCount(): number;
191
+ /**
192
+ * A count of the number of columns that have values
193
+ */
156
194
  get actualColumnCount(): number;
157
195
  _commitRow(row: Row): void;
158
196
  get _lastRowNumber(): number;
159
197
  get _nextRow(): number;
198
+ /**
199
+ * Get the last editable row in a worksheet (or undefined if there are none)
200
+ */
160
201
  get lastRow(): Row | undefined;
202
+ /**
203
+ * Tries to find and return row for row number, else undefined
204
+ *
205
+ * @param r - The 1-indexed row number
206
+ */
161
207
  findRow(r: number): Row | undefined;
208
+ /**
209
+ * Tries to find and return rows for row number start and length, else undefined
210
+ *
211
+ * @param start - The 1-indexed starting row number
212
+ * @param length - The length of the expected array
213
+ */
162
214
  findRows(start: number, length: number): (Row | undefined)[];
215
+ /**
216
+ * The total row size of the document. Equal to the row number of the last row that has values.
217
+ */
163
218
  get rowCount(): number;
219
+ /**
220
+ * A count of the number of rows that have values. If a mid-document row is empty, it will not be included in the count.
221
+ */
164
222
  get actualRowCount(): number;
165
- getRow(r: number): any;
166
- getRows(start: number, length: number): any[] | undefined;
167
- addRow(value: any, style?: string): any;
168
- addRows(value: any[], style?: string): any[];
169
- insertRow(pos: number, value: any, style?: string): any;
170
- insertRows(pos: number, values: any[], style?: string): Row[] | undefined;
223
+ /**
224
+ * Get or create row by 1-based index
225
+ */
226
+ getRow(r: number): Row;
227
+ /**
228
+ * Get or create rows by 1-based index
229
+ */
230
+ getRows(start: number, length: number): Row[] | undefined;
231
+ /**
232
+ * Add a couple of Rows by key-value, after the last current row, using the column keys,
233
+ * or add a row by contiguous Array (assign to columns A, B & C)
234
+ */
235
+ addRow(value: RowValues, style?: string): Row;
236
+ /**
237
+ * Add multiple rows by providing an array of arrays or key-value pairs
238
+ */
239
+ addRows(value: RowValues[], style?: string): Row[];
240
+ /**
241
+ * Insert a Row by key-value, at the position (shifting down all rows from position),
242
+ * using the column keys, or add a row by contiguous Array (assign to columns A, B & C)
243
+ */
244
+ insertRow(pos: number, value: RowValues, style?: string): Row;
245
+ /**
246
+ * Insert multiple rows at position (shifting down all rows from position)
247
+ * by providing an array of arrays or key-value pairs
248
+ */
249
+ insertRows(pos: number, values: RowValues[], style?: string): Row[] | undefined;
171
250
  _setStyleOption(pos: number, style?: string): void;
172
251
  _copyStyle(src: number, dest: number, styleEmpty?: boolean): void;
252
+ /**
253
+ * Duplicate rows and insert new rows
254
+ */
173
255
  duplicateRow(rowNum: number, count: number, insert?: boolean): void;
256
+ /**
257
+ * Cut one or more rows (rows below are shifted up)
258
+ * and optionally insert more
259
+ *
260
+ * Known Issue: If a splice causes any merged cells to move, the results may be unpredictable
261
+ */
174
262
  spliceRows(start: number, count: number, ...inserts: RowValues[]): void;
175
- eachRow(iteratee: (row: any, rowNumber: number) => void): void;
176
- eachRow(options: EachRowOptions, iteratee: (row: any, rowNumber: number) => void): void;
263
+ /**
264
+ * Iterate over all rows that have values in a worksheet
265
+ */
266
+ eachRow(callback: (row: Row, rowNumber: number) => void): void;
267
+ /**
268
+ * Iterate over all rows (including empty rows) in a worksheet
269
+ */
270
+ eachRow(opt: {
271
+ includeEmpty?: boolean;
272
+ }, callback: (row: Row, rowNumber: number) => void): void;
273
+ /**
274
+ * Return all rows as sparse array
275
+ */
177
276
  getSheetValues(): CellValue[][];
277
+ /**
278
+ * Returns the cell at [r,c] or address given by r. If not found, return undefined
279
+ */
178
280
  findCell(r: number | string, c?: number): Cell | undefined;
281
+ /**
282
+ * Get or create cell at [r,c] or address given by r
283
+ */
179
284
  getCell(r: number | string, c?: number): Cell;
285
+ /**
286
+ * Merge cells, either:
287
+ *
288
+ * tlbr string, e.g. `'A4:B5'`
289
+ *
290
+ * tl string, br string, e.g. `'G10', 'H11'`
291
+ *
292
+ * t, l, b, r numbers, e.g. `10,11,12,13`
293
+ */
180
294
  mergeCells(...cells: RangeInput[]): void;
181
295
  mergeCellsWithoutStyle(...cells: RangeInput[]): void;
182
296
  _mergeCellsInternal(dimensions: Range, ignoreStyle?: boolean): void;
183
297
  _unMergeMaster(master: Cell): void;
184
298
  get hasMerges(): boolean;
299
+ /**
300
+ * Scan the range and if any cell is part of a merge, un-merge the group.
301
+ * Note this function can affect multiple merges and merge-blocks are
302
+ * atomic - either they're all merged or all un-merged.
303
+ */
185
304
  unMergeCells(...cells: RangeInput[]): void;
186
305
  fillFormula(range: string, formula: string, results?: FormulaResult[][] | FormulaResult[] | ((row: number, col: number) => FormulaResult | undefined), shareType?: string): void;
306
+ /**
307
+ * Using the image id from `Workbook.addImage`,
308
+ * embed an image within the worksheet to cover a range
309
+ */
187
310
  addImage(imageId: string | number, range: AddImageRange): void;
188
311
  getImages(): Image[];
312
+ /**
313
+ * Using the image id from `Workbook.addImage`, set the background to the worksheet
314
+ */
189
315
  addBackgroundImage(imageId: string | number): void;
190
316
  getBackgroundImageId(): string | undefined;
317
+ /**
318
+ * Protect the worksheet with optional password and options
319
+ */
191
320
  protect(password?: string, options?: Partial<SheetProtection>): Promise<void>;
192
321
  unprotect(): void;
322
+ /**
323
+ * Add a new table and return a reference to it
324
+ */
193
325
  addTable(model: TableProperties): Table;
326
+ /**
327
+ * Fetch table by name
328
+ */
194
329
  getTable(name: string): Table;
330
+ /**
331
+ * Delete table by name
332
+ */
195
333
  removeTable(name: string): void;
334
+ /**
335
+ * Fetch all tables in the worksheet
336
+ */
196
337
  getTables(): Table[];
197
338
  addPivotTable(model: PivotTableModel): PivotTable;
339
+ /**
340
+ * Add conditional formatting rules
341
+ */
198
342
  addConditionalFormatting(cf: ConditionalFormattingOptions): void;
343
+ /**
344
+ * Delete conditional formatting rules
345
+ */
199
346
  removeConditionalFormatting(filter: number | ((value: ConditionalFormattingOptions, index: number, array: ConditionalFormattingOptions[]) => boolean)): void;
200
347
  get model(): WorksheetModel;
201
348
  _parseRows(model: WorksheetModel): void;
@@ -1,16 +1,17 @@
1
1
  /**
2
2
  * Simple ZIP extraction utilities
3
3
  * Provides easy-to-use Promise-based API for extracting ZIP files
4
+ * Works in both Node.js and browser environments
4
5
  */
5
- import { type ZipEntry } from "./parse.js";
6
+ import { type ZipEntryInfo } from "./zip-parser.js";
6
7
  /**
7
8
  * Extracted file entry
8
9
  */
9
10
  export interface ExtractedFile {
10
11
  /** File path within the ZIP */
11
12
  path: string;
12
- /** File content as Buffer */
13
- data: Buffer;
13
+ /** File content as Uint8Array */
14
+ data: Uint8Array;
14
15
  /** Whether this is a directory */
15
16
  isDirectory: boolean;
16
17
  /** Uncompressed size */
@@ -19,7 +20,7 @@ export interface ExtractedFile {
19
20
  /**
20
21
  * Extract all files from a ZIP buffer
21
22
  *
22
- * @param zipData - ZIP file data as Buffer or Uint8Array
23
+ * @param zipData - ZIP file data as Buffer, Uint8Array, or ArrayBuffer
23
24
  * @returns Map of file paths to their content
24
25
  *
25
26
  * @example
@@ -34,13 +35,13 @@ export interface ExtractedFile {
34
35
  * }
35
36
  * ```
36
37
  */
37
- export declare function extractAll(zipData: Buffer | Uint8Array): Promise<Map<string, ExtractedFile>>;
38
+ export declare function extractAll(zipData: Uint8Array | ArrayBuffer): Promise<Map<string, ExtractedFile>>;
38
39
  /**
39
40
  * Extract a single file from a ZIP buffer
40
41
  *
41
- * @param zipData - ZIP file data as Buffer or Uint8Array
42
+ * @param zipData - ZIP file data as Buffer, Uint8Array, or ArrayBuffer
42
43
  * @param filePath - Path of the file to extract
43
- * @returns File content as Buffer, or null if not found
44
+ * @returns File content as Uint8Array, or null if not found
44
45
  *
45
46
  * @example
46
47
  * ```ts
@@ -49,15 +50,15 @@ export declare function extractAll(zipData: Buffer | Uint8Array): Promise<Map<st
49
50
  * const zipData = fs.readFileSync("archive.zip");
50
51
  * const content = await extractFile(zipData, "readme.txt");
51
52
  * if (content) {
52
- * console.log(content.toString("utf-8"));
53
+ * console.log(new TextDecoder().decode(content));
53
54
  * }
54
55
  * ```
55
56
  */
56
- export declare function extractFile(zipData: Buffer | Uint8Array, filePath: string): Promise<Buffer | null>;
57
+ export declare function extractFile(zipData: Uint8Array | ArrayBuffer, filePath: string): Promise<Uint8Array | null>;
57
58
  /**
58
59
  * List all file paths in a ZIP buffer (without extracting content)
59
60
  *
60
- * @param zipData - ZIP file data as Buffer or Uint8Array
61
+ * @param zipData - ZIP file data as Buffer, Uint8Array, or ArrayBuffer
61
62
  * @returns Array of file paths
62
63
  *
63
64
  * @example
@@ -69,11 +70,11 @@ export declare function extractFile(zipData: Buffer | Uint8Array, filePath: stri
69
70
  * console.log(paths); // ["file1.txt", "folder/file2.txt", ...]
70
71
  * ```
71
72
  */
72
- export declare function listFiles(zipData: Buffer | Uint8Array): Promise<string[]>;
73
+ export declare function listFiles(zipData: Uint8Array | ArrayBuffer): Promise<string[]>;
73
74
  /**
74
75
  * Iterate over ZIP entries with a callback (memory efficient for large ZIPs)
75
76
  *
76
- * @param zipData - ZIP file data as Buffer or Uint8Array
77
+ * @param zipData - ZIP file data as Buffer, Uint8Array, or ArrayBuffer
77
78
  * @param callback - Async callback for each entry, return false to stop iteration
78
79
  *
79
80
  * @example
@@ -83,10 +84,11 @@ export declare function listFiles(zipData: Buffer | Uint8Array): Promise<string[
83
84
  * await forEachEntry(zipData, async (path, getData) => {
84
85
  * if (path.endsWith(".xml")) {
85
86
  * const content = await getData();
86
- * console.log(content.toString("utf-8"));
87
+ * console.log(new TextDecoder().decode(content));
87
88
  * }
88
89
  * return true; // continue iteration
89
90
  * });
90
91
  * ```
91
92
  */
92
- export declare function forEachEntry(zipData: Buffer | Uint8Array, callback: (path: string, getData: () => Promise<Buffer>, entry: ZipEntry) => Promise<boolean | void>): Promise<void>;
93
+ export declare function forEachEntry(zipData: Uint8Array | ArrayBuffer, callback: (path: string, getData: () => Promise<Uint8Array>, entry: ZipEntryInfo) => Promise<boolean | void>): Promise<void>;
94
+ export { ZipParser, type ZipEntryInfo, type ZipParseOptions } from "./zip-parser.js";
@@ -1,5 +1,19 @@
1
1
  /**
2
2
  * Unzip utilities for parsing ZIP archives
3
+ *
4
+ * Two APIs are provided:
5
+ *
6
+ * 1. **Stream-based API** (Node.js only):
7
+ * - `Parse`, `createParse` - Parse ZIP files as a stream
8
+ * - Best for large files where you don't want to load entire file into memory
9
+ * - Requires Node.js `stream` module
10
+ *
11
+ * 2. **Buffer-based API** (Browser + Node.js):
12
+ * - `extractAll`, `extractFile`, `listFiles`, `forEachEntry`, `ZipParser`
13
+ * - Works in both Node.js and browser environments
14
+ * - Uses native `DecompressionStream` in browser, `zlib` in Node.js
15
+ * - Best for files already loaded into memory (ArrayBuffer, Uint8Array)
16
+ *
3
17
  * Original source: https://github.com/ZJONSSON/node-unzipper
4
18
  * License: MIT
5
19
  */
@@ -10,4 +24,4 @@ export { bufferStream } from "./buffer-stream.js";
10
24
  export { parse as parseBuffer } from "./parse-buffer.js";
11
25
  export { parseDateTime } from "./parse-datetime.js";
12
26
  export { parseExtraField, type ExtraField, type ZipVars } from "./parse-extra-field.js";
13
- export { extractAll, extractFile, listFiles, forEachEntry, type ExtractedFile } from "./extract.js";
27
+ export { extractAll, extractFile, listFiles, forEachEntry, ZipParser, type ExtractedFile, type ZipEntryInfo, type ZipParseOptions } from "./extract.js";
@@ -0,0 +1,92 @@
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
+ /**
7
+ * Parsed ZIP entry
8
+ */
9
+ export interface ZipEntryInfo {
10
+ /** File path within the ZIP */
11
+ path: string;
12
+ /** Whether this is a directory */
13
+ isDirectory: boolean;
14
+ /** Compressed size */
15
+ compressedSize: number;
16
+ /** Uncompressed size */
17
+ uncompressedSize: number;
18
+ /** Compression method (0 = stored, 8 = deflate) */
19
+ compressionMethod: number;
20
+ /** CRC-32 checksum */
21
+ crc32: number;
22
+ /** Last modified date */
23
+ lastModified: Date;
24
+ /** Offset to local file header */
25
+ localHeaderOffset: number;
26
+ /** File comment */
27
+ comment: string;
28
+ /** External file attributes */
29
+ externalAttributes: number;
30
+ /** Is encrypted */
31
+ isEncrypted: boolean;
32
+ }
33
+ /**
34
+ * ZIP parsing options
35
+ */
36
+ export interface ZipParseOptions {
37
+ /** Whether to decode file names as UTF-8 (default: true) */
38
+ decodeStrings?: boolean;
39
+ }
40
+ /**
41
+ * Parse ZIP file entries from Central Directory
42
+ */
43
+ export declare function parseZipEntries(data: Uint8Array, options?: ZipParseOptions): ZipEntryInfo[];
44
+ /**
45
+ * Extract file data for a specific entry
46
+ */
47
+ export declare function extractEntryData(data: Uint8Array, entry: ZipEntryInfo): Promise<Uint8Array>;
48
+ /**
49
+ * Extract file data synchronously (Node.js only)
50
+ */
51
+ export declare function extractEntryDataSync(data: Uint8Array, entry: ZipEntryInfo): Uint8Array;
52
+ /**
53
+ * High-level ZIP parser class
54
+ */
55
+ export declare class ZipParser {
56
+ private data;
57
+ private entries;
58
+ private entryMap;
59
+ constructor(data: Uint8Array | ArrayBuffer, options?: ZipParseOptions);
60
+ /**
61
+ * Get all entries in the ZIP file
62
+ */
63
+ getEntries(): ZipEntryInfo[];
64
+ /**
65
+ * Get entry by path
66
+ */
67
+ getEntry(path: string): ZipEntryInfo | undefined;
68
+ /**
69
+ * Check if entry exists
70
+ */
71
+ hasEntry(path: string): boolean;
72
+ /**
73
+ * List all file paths
74
+ */
75
+ listFiles(): string[];
76
+ /**
77
+ * Extract a single file (async)
78
+ */
79
+ extract(path: string): Promise<Uint8Array | null>;
80
+ /**
81
+ * Extract a single file (sync, Node.js only)
82
+ */
83
+ extractSync(path: string): Uint8Array | null;
84
+ /**
85
+ * Extract all files (async)
86
+ */
87
+ extractAll(): Promise<Map<string, Uint8Array>>;
88
+ /**
89
+ * Iterate over entries with async callback
90
+ */
91
+ forEach(callback: (entry: ZipEntryInfo, getData: () => Promise<Uint8Array>) => Promise<boolean | void>): Promise<void>;
92
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cj-tech-master/excelts",
3
- "version": "1.4.5-canary.20251212064440.3eb099f",
3
+ "version": "1.4.5-canary.20251212160853.7621827",
4
4
  "description": "TypeScript Excel Workbook Manager - Read and Write xlsx and csv Files.",
5
5
  "private": false,
6
6
  "publishConfig": {