@cj-tech-master/excelts 1.0.0 → 1.4.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 (69) hide show
  1. package/dist/browser/excelts.iife.js +2568 -1188
  2. package/dist/browser/excelts.iife.js.map +1 -1
  3. package/dist/browser/excelts.iife.min.js +21 -19
  4. package/dist/cjs/index.js +1 -0
  5. package/dist/cjs/stream/xlsx/workbook-reader.js +2 -2
  6. package/dist/cjs/stream/xlsx/workbook-writer.js +8 -4
  7. package/dist/cjs/utils/cell-format.js +815 -0
  8. package/dist/cjs/utils/cell-matrix.js +37 -2
  9. package/dist/cjs/utils/parse-sax.js +2 -2
  10. package/dist/cjs/utils/sheet-utils.js +615 -0
  11. package/dist/cjs/utils/stream-buf.js +15 -4
  12. package/dist/cjs/utils/unzip/buffer-stream.js +27 -0
  13. package/dist/cjs/utils/unzip/index.js +23 -0
  14. package/dist/cjs/utils/unzip/noop-stream.js +20 -0
  15. package/dist/cjs/utils/unzip/parse-buffer.js +60 -0
  16. package/dist/cjs/utils/unzip/parse-datetime.js +23 -0
  17. package/dist/cjs/utils/unzip/parse-extra-field.js +52 -0
  18. package/dist/cjs/utils/unzip/parse.js +340 -0
  19. package/dist/cjs/utils/unzip/pull-stream.js +145 -0
  20. package/dist/cjs/utils/utils.js +13 -17
  21. package/dist/cjs/utils/zip-stream.js +29 -33
  22. package/dist/cjs/xlsx/xlsx.js +1 -2
  23. package/dist/esm/index.browser.js +1 -0
  24. package/dist/esm/index.js +1 -0
  25. package/dist/esm/stream/xlsx/workbook-reader.js +2 -2
  26. package/dist/esm/stream/xlsx/workbook-writer.js +9 -5
  27. package/dist/esm/utils/cell-format.js +810 -0
  28. package/dist/esm/utils/cell-matrix.js +37 -2
  29. package/dist/esm/utils/parse-sax.js +1 -1
  30. package/dist/esm/utils/sheet-utils.js +595 -0
  31. package/dist/esm/utils/stream-buf.js +15 -4
  32. package/dist/esm/utils/unzip/buffer-stream.js +24 -0
  33. package/dist/esm/utils/unzip/index.js +12 -0
  34. package/dist/esm/utils/unzip/noop-stream.js +16 -0
  35. package/dist/esm/utils/unzip/parse-buffer.js +57 -0
  36. package/dist/esm/utils/unzip/parse-datetime.js +20 -0
  37. package/dist/esm/utils/unzip/parse-extra-field.js +49 -0
  38. package/dist/esm/utils/unzip/parse.js +332 -0
  39. package/dist/esm/utils/unzip/pull-stream.js +141 -0
  40. package/dist/esm/utils/utils.js +12 -16
  41. package/dist/esm/utils/zip-stream.js +30 -34
  42. package/dist/esm/xlsx/xlsx.js +1 -2
  43. package/dist/types/doc/column.d.ts +1 -1
  44. package/dist/types/doc/worksheet.d.ts +2 -2
  45. package/dist/types/index.browser.d.ts +1 -0
  46. package/dist/types/index.d.ts +1 -0
  47. package/dist/types/stream/xlsx/workbook-writer.d.ts +1 -0
  48. package/dist/types/utils/cell-format.d.ts +32 -0
  49. package/dist/types/utils/sheet-utils.d.ts +203 -0
  50. package/dist/types/utils/unzip/buffer-stream.d.ts +9 -0
  51. package/dist/types/utils/unzip/index.d.ts +12 -0
  52. package/dist/types/utils/unzip/noop-stream.d.ts +13 -0
  53. package/dist/types/utils/unzip/parse-buffer.d.ts +24 -0
  54. package/dist/types/utils/unzip/parse-datetime.d.ts +12 -0
  55. package/dist/types/utils/unzip/parse-extra-field.d.ts +18 -0
  56. package/dist/types/utils/unzip/parse.d.ts +70 -0
  57. package/dist/types/utils/unzip/pull-stream.d.ts +24 -0
  58. package/dist/types/utils/utils.d.ts +5 -2
  59. package/dist/types/utils/zip-stream.d.ts +5 -1
  60. package/package.json +35 -32
  61. package/dist/cjs/utils/browser-buffer-decode.js +0 -13
  62. package/dist/cjs/utils/browser-buffer-encode.js +0 -13
  63. package/dist/cjs/utils/browser.js +0 -6
  64. package/dist/esm/utils/browser-buffer-decode.js +0 -11
  65. package/dist/esm/utils/browser-buffer-encode.js +0 -11
  66. package/dist/esm/utils/browser.js +0 -3
  67. package/dist/types/utils/browser-buffer-decode.d.ts +0 -2
  68. package/dist/types/utils/browser-buffer-encode.d.ts +0 -2
  69. package/dist/types/utils/browser.d.ts +0 -1
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Unzipper pull-stream module
3
+ * Original source: https://github.com/ZJONSSON/node-unzipper
4
+ * License: MIT
5
+ * Copyright (c) 2012 - 2013 Near Infinity Corporation
6
+ * Commits in this fork are (c) Ziggy Jonsson (ziggy.jonsson.nyc@gmail.com)
7
+ */
8
+ import { Duplex, PassThrough, Transform } from "stream";
9
+ const STR_FUNCTION = "function";
10
+ export class PullStream extends Duplex {
11
+ constructor() {
12
+ super({ decodeStrings: false, objectMode: true });
13
+ this.buffer = Buffer.from("");
14
+ this.finished = false;
15
+ this.on("finish", () => {
16
+ this.finished = true;
17
+ this.emit("chunk", false);
18
+ });
19
+ }
20
+ _write(chunk, _encoding, cb) {
21
+ this.buffer = Buffer.concat([this.buffer, chunk]);
22
+ this.cb = cb;
23
+ this.emit("chunk");
24
+ }
25
+ _read() { }
26
+ /**
27
+ * The `eof` parameter is interpreted as `file_length` if the type is number
28
+ * otherwise (i.e. buffer) it is interpreted as a pattern signaling end of stream
29
+ */
30
+ stream(eof, includeEof) {
31
+ const p = new PassThrough();
32
+ let done = false;
33
+ const cb = () => {
34
+ if (typeof this.cb === STR_FUNCTION) {
35
+ const callback = this.cb;
36
+ this.cb = undefined;
37
+ callback();
38
+ }
39
+ };
40
+ const pull = () => {
41
+ let packet;
42
+ if (this.buffer && this.buffer.length) {
43
+ if (typeof eof === "number") {
44
+ packet = this.buffer.slice(0, eof);
45
+ this.buffer = this.buffer.slice(eof);
46
+ eof -= packet.length;
47
+ done = done || !eof;
48
+ }
49
+ else {
50
+ let match = this.buffer.indexOf(eof);
51
+ if (match !== -1) {
52
+ // store signature match byte offset to allow us to reference
53
+ // this for zip64 offset
54
+ this.match = match;
55
+ if (includeEof) {
56
+ match = match + eof.length;
57
+ }
58
+ packet = this.buffer.slice(0, match);
59
+ this.buffer = this.buffer.slice(match);
60
+ done = true;
61
+ }
62
+ else {
63
+ const len = this.buffer.length - eof.length;
64
+ if (len <= 0) {
65
+ cb();
66
+ }
67
+ else {
68
+ packet = this.buffer.slice(0, len);
69
+ this.buffer = this.buffer.slice(len);
70
+ }
71
+ }
72
+ }
73
+ if (packet) {
74
+ p.write(packet, () => {
75
+ if (this.buffer.length === 0 ||
76
+ (typeof eof !== "number" && eof.length && this.buffer.length <= eof.length)) {
77
+ cb();
78
+ }
79
+ });
80
+ }
81
+ }
82
+ if (!done) {
83
+ if (this.finished) {
84
+ this.removeListener("chunk", pull);
85
+ this.emit("error", new Error("FILE_ENDED"));
86
+ return;
87
+ }
88
+ }
89
+ else {
90
+ this.removeListener("chunk", pull);
91
+ p.end();
92
+ }
93
+ };
94
+ this.on("chunk", pull);
95
+ pull();
96
+ return p;
97
+ }
98
+ pull(eof, includeEof) {
99
+ if (eof === 0) {
100
+ return Promise.resolve(Buffer.from(""));
101
+ }
102
+ // If we already have the required data in buffer
103
+ // we can resolve the request immediately
104
+ if (typeof eof === "number" && this.buffer.length > eof) {
105
+ const data = this.buffer.slice(0, eof);
106
+ this.buffer = this.buffer.slice(eof);
107
+ return Promise.resolve(data);
108
+ }
109
+ // Otherwise we stream until we have it
110
+ let buffer = Buffer.from("");
111
+ const concatStream = new Transform({
112
+ transform(d, _e, cb) {
113
+ buffer = Buffer.concat([buffer, d]);
114
+ cb();
115
+ }
116
+ });
117
+ let rejectHandler;
118
+ let pullStreamRejectHandler;
119
+ return new Promise((resolve, reject) => {
120
+ rejectHandler = reject;
121
+ pullStreamRejectHandler = (e) => {
122
+ this.__emittedError = e;
123
+ reject(e);
124
+ };
125
+ if (this.finished) {
126
+ return reject(new Error("FILE_ENDED"));
127
+ }
128
+ this.once("error", pullStreamRejectHandler); // reject any errors from pullstream itself
129
+ this.stream(eof, includeEof)
130
+ .on("error", reject)
131
+ .pipe(concatStream)
132
+ .on("finish", () => {
133
+ resolve(buffer);
134
+ })
135
+ .on("error", reject);
136
+ }).finally(() => {
137
+ this.removeListener("error", rejectHandler);
138
+ this.removeListener("error", pullStreamRejectHandler);
139
+ });
140
+ }
141
+ }
@@ -3,21 +3,6 @@ export function delay(ms) {
3
3
  return new Promise(resolve => setTimeout(resolve, ms));
4
4
  }
5
5
  export function nop() { }
6
- export function promiseImmediate(value) {
7
- return new Promise(resolve => {
8
- if (global.setImmediate) {
9
- setImmediate(() => {
10
- resolve(value);
11
- });
12
- }
13
- else {
14
- // poorman's setImmediate - must wait at least 1ms
15
- setTimeout(() => {
16
- resolve(value);
17
- }, 1);
18
- }
19
- });
20
- }
21
6
  // useful stuff
22
7
  export const inherits = function (cls, superCtor, statics, prototype) {
23
8
  cls.super_ = superCtor;
@@ -189,7 +174,6 @@ export function objectFromProps(props, value = null) {
189
174
  /** @deprecated Import functions directly instead of using the utils object */
190
175
  export const utils = {
191
176
  nop,
192
- promiseImmediate,
193
177
  inherits,
194
178
  dateToExcel,
195
179
  excelToDate,
@@ -208,3 +192,15 @@ export const utils = {
208
192
  toSortedArray,
209
193
  objectFromProps
210
194
  };
195
+ // TextDecoder is available in ES2020+ and all modern browsers/Node.js
196
+ const textDecoder = new TextDecoder("utf-8");
197
+ /**
198
+ * Convert a Buffer or ArrayBuffer to a UTF-8 string
199
+ * Works in both Node.js and browser environments
200
+ */
201
+ export function bufferToString(chunk) {
202
+ if (typeof chunk === "string") {
203
+ return chunk;
204
+ }
205
+ return textDecoder.decode(chunk);
206
+ }
@@ -1,8 +1,6 @@
1
1
  import events from "events";
2
- import { Zip, ZipPassThrough } from "fflate";
2
+ import { Zip, ZipPassThrough, ZipDeflate } from "fflate";
3
3
  import { StreamBuf } from "./stream-buf.js";
4
- import { stringToBuffer } from "./browser-buffer-encode.js";
5
- import { isBrowser } from "./browser.js";
6
4
  // =============================================================================
7
5
  // The ZipWriter class
8
6
  // Packs streamed data into an output zip stream
@@ -13,6 +11,10 @@ class ZipWriter extends events.EventEmitter {
13
11
  type: "nodebuffer",
14
12
  compression: "DEFLATE"
15
13
  }, options);
14
+ // Default compression level is 6 (good balance of speed and size)
15
+ // 0 = no compression, 9 = best compression
16
+ const level = this.options.compressionOptions?.level ?? 6;
17
+ this.compressionLevel = Math.max(0, Math.min(9, level));
16
18
  this.files = {};
17
19
  this.stream = new StreamBuf();
18
20
  this.finalized = false;
@@ -32,42 +34,36 @@ class ZipWriter extends events.EventEmitter {
32
34
  append(data, options) {
33
35
  let buffer;
34
36
  if (Object.prototype.hasOwnProperty.call(options, "base64") && options.base64) {
35
- // Use Buffer.from for efficient base64 decoding
37
+ // Decode base64 data - Buffer.from works in both Node.js and browser (via polyfill)
36
38
  const base64Data = typeof data === "string" ? data : data.toString();
37
- if (isBrowser) {
38
- // Browser: use atob with optimized Uint8Array conversion
39
- const binaryString = atob(base64Data);
40
- const len = binaryString.length;
41
- buffer = new Uint8Array(len);
42
- // Use a single loop with cached length for better performance
43
- for (let i = 0; i < len; i++) {
44
- buffer[i] = binaryString.charCodeAt(i);
45
- }
46
- }
47
- else {
48
- // Node.js: use efficient Buffer.from
49
- buffer = Buffer.from(base64Data, "base64");
50
- }
39
+ buffer = Buffer.from(base64Data, "base64");
40
+ }
41
+ else if (typeof data === "string") {
42
+ // Convert string to Buffer - works in both environments
43
+ buffer = Buffer.from(data, "utf8");
44
+ }
45
+ else if (Buffer.isBuffer(data)) {
46
+ // Buffer extends Uint8Array, fflate can use it directly - no copy needed
47
+ buffer = data;
48
+ }
49
+ else if (ArrayBuffer.isView(data)) {
50
+ // Handle typed arrays - create view without copy
51
+ buffer = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
52
+ }
53
+ else if (data instanceof ArrayBuffer) {
54
+ // Handle ArrayBuffer directly
55
+ buffer = new Uint8Array(data);
51
56
  }
52
57
  else {
53
- if (typeof data === "string") {
54
- // Convert string to Uint8Array
55
- if (isBrowser) {
56
- buffer = stringToBuffer(data);
57
- }
58
- else {
59
- buffer = Buffer.from(data, "utf8");
60
- }
61
- }
62
- else if (Buffer.isBuffer(data)) {
63
- buffer = new Uint8Array(data);
64
- }
65
- else {
66
- buffer = data;
67
- }
58
+ // Assume it's already a Uint8Array or compatible type
59
+ buffer = data;
68
60
  }
69
61
  // Add file to zip using streaming API
70
- const zipFile = new ZipPassThrough(options.name);
62
+ // Use ZipDeflate for compression or ZipPassThrough for no compression
63
+ const useCompression = this.options.compression !== "STORE";
64
+ const zipFile = useCompression
65
+ ? new ZipDeflate(options.name, { level: this.compressionLevel })
66
+ : new ZipPassThrough(options.name);
71
67
  this.zip.add(zipFile);
72
68
  zipFile.push(buffer, true); // true = final chunk
73
69
  }
@@ -3,9 +3,8 @@ import { Unzip, UnzipInflate } from "fflate";
3
3
  import { PassThrough } from "stream";
4
4
  import { ZipWriter } from "../utils/zip-stream.js";
5
5
  import { StreamBuf } from "../utils/stream-buf.js";
6
- import { fileExists } from "../utils/utils.js";
6
+ import { fileExists, bufferToString } from "../utils/utils.js";
7
7
  import { XmlStream } from "../utils/xml-stream.js";
8
- import { bufferToString } from "../utils/browser-buffer-decode.js";
9
8
  import { StylesXform } from "./xform/style/styles-xform.js";
10
9
  import { CoreXform } from "./xform/core/core-xform.js";
11
10
  import { SharedStringsXform } from "./xform/strings/shared-strings-xform.js";
@@ -21,7 +21,7 @@ declare class Column {
21
21
  _number: number;
22
22
  _header: any;
23
23
  _key: string | undefined;
24
- width: number | undefined;
24
+ width?: number;
25
25
  _hidden: boolean | undefined;
26
26
  _outlineLevel: number | undefined;
27
27
  style: any;
@@ -90,7 +90,7 @@ declare class Worksheet {
90
90
  _name: string;
91
91
  state: string;
92
92
  _rows: any[];
93
- _columns: any[] | null;
93
+ _columns: any[];
94
94
  _keys: {
95
95
  [key: string]: any;
96
96
  };
@@ -118,7 +118,7 @@ declare class Worksheet {
118
118
  get workbook(): any;
119
119
  destroy(): void;
120
120
  get dimensions(): Range;
121
- get columns(): any[] | null;
121
+ get columns(): any[];
122
122
  set columns(value: any[]);
123
123
  getColumnKey(key: string): any;
124
124
  setColumnKey(key: string, value: any): void;
@@ -1,4 +1,5 @@
1
1
  export { Workbook } from "./doc/workbook.js";
2
2
  export * from "./doc/enums.js";
3
3
  export * from "./types.js";
4
+ export * from "./utils/sheet-utils.js";
4
5
  export type { FastCsvParserOptionsArgs, FastCsvFormatterOptionsArgs, CsvReadOptions, CsvWriteOptions } from "./csv/csv.js";
@@ -15,4 +15,5 @@ export { Table } from "./doc/table.js";
15
15
  export { DataValidations } from "./doc/data-validations.js";
16
16
  export * from "./doc/enums.js";
17
17
  export * from "./types.js";
18
+ export * from "./utils/sheet-utils.js";
18
19
  export type { FastCsvParserOptionsArgs, FastCsvFormatterOptionsArgs, CsvReadOptions, CsvWriteOptions } from "./csv/csv.js";
@@ -24,6 +24,7 @@ declare class WorkbookWriter {
24
24
  _worksheets: any[];
25
25
  views: any[];
26
26
  zipOptions?: any;
27
+ compressionLevel: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
27
28
  media: any[];
28
29
  commentRefs: any[];
29
30
  zip: any;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Excel Cell Format Parser
3
+ * A simplified implementation for formatting cell values according to Excel numFmt patterns
4
+ * Supports: General, percentages, decimals, thousands separators, dates, currencies,
5
+ * scientific notation, fractions, elapsed time, and more
6
+ */
7
+ /**
8
+ * Get format string from numFmtId
9
+ * Handles default mappings for certain format IDs
10
+ */
11
+ export declare function getFormat(numFmtId: number): string;
12
+ /**
13
+ * Check if format is "General"
14
+ */
15
+ declare function isGeneral(fmt: string): boolean;
16
+ /**
17
+ * Check if format is a date format
18
+ */
19
+ declare function isDateFormat(fmt: string): boolean;
20
+ /**
21
+ * Main format function - formats a value according to Excel numFmt
22
+ * @param fmt The Excel number format string (e.g., "0.00%", "#,##0", "yyyy-mm-dd")
23
+ * @param val The value to format
24
+ */
25
+ export declare function format(fmt: string, val: number | string | boolean): string;
26
+ export declare const cellFormat: {
27
+ format: typeof format;
28
+ getFormat: typeof getFormat;
29
+ isDateFormat: typeof isDateFormat;
30
+ isGeneral: typeof isGeneral;
31
+ };
32
+ export {};
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Utility functions for ExcelTS
3
+ * Provides convenient helper functions for common spreadsheet operations
4
+ */
5
+ import { Workbook } from "../doc/workbook.js";
6
+ import type { Worksheet } from "../doc/worksheet.js";
7
+ import type { CellValue } from "../types.js";
8
+ /**
9
+ * Cell address object (0-indexed)
10
+ */
11
+ export interface CellAddress {
12
+ /** 0-indexed column number */
13
+ c: number;
14
+ /** 0-indexed row number */
15
+ r: number;
16
+ }
17
+ /**
18
+ * Range object with start and end addresses
19
+ */
20
+ export interface Range {
21
+ /** Start cell (top-left) */
22
+ s: CellAddress;
23
+ /** End cell (bottom-right) */
24
+ e: CellAddress;
25
+ }
26
+ /**
27
+ * Row data for JSON conversion
28
+ */
29
+ export type JSONRow = Record<string, CellValue>;
30
+ /**
31
+ * Decode column string to 0-indexed number
32
+ * @example decodeCol("A") => 0, decodeCol("Z") => 25, decodeCol("AA") => 26
33
+ */
34
+ export declare function decodeCol(colstr: string): number;
35
+ /**
36
+ * Encode 0-indexed column number to string
37
+ * @example encodeCol(0) => "A", encodeCol(25) => "Z", encodeCol(26) => "AA"
38
+ */
39
+ export declare function encodeCol(col: number): string;
40
+ /**
41
+ * Decode row string to 0-indexed number
42
+ * @example decodeRow("1") => 0, decodeRow("10") => 9
43
+ */
44
+ export declare function decodeRow(rowstr: string): number;
45
+ /**
46
+ * Encode 0-indexed row number to string
47
+ * @example encodeRow(0) => "1", encodeRow(9) => "10"
48
+ */
49
+ export declare function encodeRow(row: number): string;
50
+ /**
51
+ * Decode cell address string to CellAddress object
52
+ * @example decodeCell("A1") => {c: 0, r: 0}, decodeCell("B2") => {c: 1, r: 1}
53
+ */
54
+ export declare function decodeCell(cstr: string): CellAddress;
55
+ /**
56
+ * Encode CellAddress object to cell address string
57
+ * @example encodeCell({c: 0, r: 0}) => "A1", encodeCell({c: 1, r: 1}) => "B2"
58
+ */
59
+ export declare function encodeCell(cell: CellAddress): string;
60
+ /**
61
+ * Decode range string to Range object
62
+ * @example decodeRange("A1:B2") => {s: {c: 0, r: 0}, e: {c: 1, r: 1}}
63
+ */
64
+ export declare function decodeRange(range: string): Range;
65
+ /**
66
+ * Encode Range object to range string
67
+ */
68
+ export declare function encodeRange(range: Range): string;
69
+ export declare function encodeRange(start: CellAddress, end: CellAddress): string;
70
+ /** Origin can be cell address string, cell object, row number, or -1 to append */
71
+ export type Origin = string | CellAddress | number;
72
+ export interface JSON2SheetOpts {
73
+ /** Use specified field order (default Object.keys) */
74
+ header?: string[];
75
+ /** Use specified date format in string output */
76
+ dateNF?: string;
77
+ /** Store dates as type d (default is n) */
78
+ cellDates?: boolean;
79
+ /** If true, do not include header row in output */
80
+ skipHeader?: boolean;
81
+ /** If true, emit #NULL! error cells for null values */
82
+ nullError?: boolean;
83
+ }
84
+ export interface SheetAddJSONOpts extends JSON2SheetOpts {
85
+ /** Use specified cell as starting point */
86
+ origin?: Origin;
87
+ }
88
+ /**
89
+ * Create a worksheet from an array of objects (xlsx compatible)
90
+ * @example
91
+ * const ws = jsonToSheet([{name: "Alice", age: 30}, {name: "Bob", age: 25}])
92
+ */
93
+ export declare function jsonToSheet(data: JSONRow[], opts?: JSON2SheetOpts): Worksheet;
94
+ /**
95
+ * Add data from an array of objects to an existing worksheet (xlsx compatible)
96
+ */
97
+ export declare function sheetAddJson(worksheet: Worksheet, data: JSONRow[], opts?: SheetAddJSONOpts): Worksheet;
98
+ export interface Sheet2JSONOpts {
99
+ /**
100
+ * Control output format:
101
+ * - 1: Generate an array of arrays
102
+ * - "A": Row object keys are literal column labels (A, B, C, ...)
103
+ * - string[]: Use specified strings as keys in row objects
104
+ * - undefined: Read and disambiguate first row as keys
105
+ */
106
+ header?: 1 | "A" | string[];
107
+ /**
108
+ * Override Range:
109
+ * - number: Use worksheet range but set starting row to the value
110
+ * - string: Use specified range (A1-Style bounded range string)
111
+ * - undefined: Use worksheet range
112
+ */
113
+ range?: number | string;
114
+ /** Use raw values (true, default) or formatted text strings with trim (false) */
115
+ raw?: boolean;
116
+ /** Default value for empty cells */
117
+ defval?: CellValue;
118
+ /** Include blank lines in the output */
119
+ blankrows?: boolean;
120
+ }
121
+ /**
122
+ * Convert worksheet to JSON array (xlsx compatible)
123
+ * @example
124
+ * // Default: array of objects with first row as headers
125
+ * const data = sheetToJson(worksheet)
126
+ * // => [{name: "Alice", age: 30}, {name: "Bob", age: 25}]
127
+ *
128
+ * // Array of arrays
129
+ * const aoa = sheetToJson(worksheet, { header: 1 })
130
+ * // => [["name", "age"], ["Alice", 30], ["Bob", 25]]
131
+ *
132
+ * // Column letters as keys
133
+ * const cols = sheetToJson(worksheet, { header: "A" })
134
+ * // => [{A: "name", B: "age"}, {A: "Alice", B: 30}]
135
+ */
136
+ export declare function sheetToJson<T = JSONRow>(worksheet: Worksheet, opts?: Sheet2JSONOpts): T[];
137
+ export interface Sheet2CSVOpts {
138
+ /** Field separator (default: ",") */
139
+ FS?: string;
140
+ /** Record separator (default: "\n") */
141
+ RS?: string;
142
+ /** Skip blank rows */
143
+ blankrows?: boolean;
144
+ /** Force quote all fields */
145
+ forceQuotes?: boolean;
146
+ }
147
+ /**
148
+ * Convert worksheet to CSV string
149
+ */
150
+ export declare function sheetToCsv(worksheet: Worksheet, opts?: Sheet2CSVOpts): string;
151
+ /**
152
+ * Create a new workbook
153
+ */
154
+ export declare function bookNew(): Workbook;
155
+ /**
156
+ * Append worksheet to workbook (xlsx compatible)
157
+ * @example
158
+ * const wb = bookNew();
159
+ * const ws = jsonToSheet([{a: 1, b: 2}]);
160
+ * bookAppendSheet(wb, ws, "Sheet1");
161
+ */
162
+ export declare function bookAppendSheet(workbook: Workbook, worksheet: Worksheet, name?: string): void;
163
+ export interface AOA2SheetOpts {
164
+ /** Use specified cell as starting point */
165
+ origin?: Origin;
166
+ /** Use specified date format in string output */
167
+ dateNF?: string;
168
+ /** Store dates as type d (default is n) */
169
+ cellDates?: boolean;
170
+ }
171
+ /**
172
+ * Create a worksheet from an array of arrays (xlsx compatible)
173
+ * @example
174
+ * const ws = aoaToSheet([["Name", "Age"], ["Alice", 30], ["Bob", 25]])
175
+ */
176
+ export declare function aoaToSheet(data: CellValue[][], opts?: AOA2SheetOpts): Worksheet;
177
+ /**
178
+ * Add data from an array of arrays to an existing worksheet (xlsx compatible)
179
+ */
180
+ export declare function sheetAddAoa(worksheet: Worksheet, data: CellValue[][], opts?: AOA2SheetOpts): Worksheet;
181
+ /**
182
+ * Convert worksheet to array of arrays
183
+ */
184
+ export declare function sheetToAoa(worksheet: Worksheet): CellValue[][];
185
+ export declare const utils: {
186
+ decodeCol: typeof decodeCol;
187
+ encodeCol: typeof encodeCol;
188
+ decodeRow: typeof decodeRow;
189
+ encodeRow: typeof encodeRow;
190
+ decodeCell: typeof decodeCell;
191
+ encodeCell: typeof encodeCell;
192
+ decodeRange: typeof decodeRange;
193
+ encodeRange: typeof encodeRange;
194
+ jsonToSheet: typeof jsonToSheet;
195
+ sheetAddJson: typeof sheetAddJson;
196
+ sheetToJson: typeof sheetToJson;
197
+ sheetToCsv: typeof sheetToCsv;
198
+ aoaToSheet: typeof aoaToSheet;
199
+ sheetAddAoa: typeof sheetAddAoa;
200
+ sheetToAoa: typeof sheetToAoa;
201
+ bookNew: typeof bookNew;
202
+ bookAppendSheet: typeof bookAppendSheet;
203
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Unzipper buffer-stream module
3
+ * Original source: https://github.com/ZJONSSON/node-unzipper
4
+ * License: MIT
5
+ * Copyright (c) 2012 - 2013 Near Infinity Corporation
6
+ * Commits in this fork are (c) Ziggy Jonsson (ziggy.jonsson.nyc@gmail.com)
7
+ */
8
+ import type { Readable } from "stream";
9
+ export declare function bufferStream(entry: Readable): Promise<Buffer>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Unzip utilities for parsing ZIP archives
3
+ * Original source: https://github.com/ZJONSSON/node-unzipper
4
+ * License: MIT
5
+ */
6
+ export { Parse, createParse, type ParseOptions, type ZipEntry } from "./parse.js";
7
+ export { PullStream } from "./pull-stream.js";
8
+ export { NoopStream } from "./noop-stream.js";
9
+ export { bufferStream } from "./buffer-stream.js";
10
+ export { parse as parseBuffer } from "./parse-buffer.js";
11
+ export { parseDateTime } from "./parse-datetime.js";
12
+ export { parseExtraField, type ExtraField, type ZipVars } from "./parse-extra-field.js";
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Unzipper noop-stream module
3
+ * Original source: https://github.com/ZJONSSON/node-unzipper
4
+ * License: MIT
5
+ * Copyright (c) 2012 - 2013 Near Infinity Corporation
6
+ * Commits in this fork are (c) Ziggy Jonsson (ziggy.jonsson.nyc@gmail.com)
7
+ */
8
+ import { Transform } from "stream";
9
+ import type { TransformCallback } from "stream";
10
+ export declare class NoopStream extends Transform {
11
+ constructor();
12
+ _transform(_chunk: any, _encoding: BufferEncoding, cb: TransformCallback): void;
13
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Unzipper parse-buffer module
3
+ * Original source: https://github.com/ZJONSSON/node-unzipper
4
+ * License: MIT
5
+ * Copyright (c) 2012 - 2013 Near Infinity Corporation
6
+ * Commits in this fork are (c) Ziggy Jonsson (ziggy.jonsson.nyc@gmail.com)
7
+ */
8
+ /**
9
+ * Parses sequential unsigned little endian numbers from the head of the passed buffer according to
10
+ * the specified format passed. If the buffer is not large enough to satisfy the full format,
11
+ * null values will be assigned to the remaining keys.
12
+ * @param buffer The buffer to sequentially extract numbers from.
13
+ * @param format Expected format to follow when extracting values from the buffer. A list of list entries
14
+ * with the following structure:
15
+ * [
16
+ * [
17
+ * <key>, // Name of the key to assign the extracted number to.
18
+ * <size> // The size in bytes of the number to extract. possible values are 1, 2, 4, 8.
19
+ * ],
20
+ * ...
21
+ * ]
22
+ * @returns An object with keys set to their associated extracted values.
23
+ */
24
+ export declare function parse(buffer: Buffer, format: [string, number][]): Record<string, number | null>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Unzipper parse-datetime module
3
+ * Original source: https://github.com/ZJONSSON/node-unzipper
4
+ * License: MIT
5
+ * Copyright (c) 2012 - 2013 Near Infinity Corporation
6
+ * Commits in this fork are (c) Ziggy Jonsson (ziggy.jonsson.nyc@gmail.com)
7
+ */
8
+ /**
9
+ * Dates in zip file entries are stored as DosDateTime
10
+ * Spec is here: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-dosdatetimetofiletime
11
+ */
12
+ export declare function parseDateTime(date: number, time?: number): Date;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Unzipper parse-extra-field module
3
+ * Original source: https://github.com/ZJONSSON/node-unzipper
4
+ * License: MIT
5
+ * Copyright (c) 2012 - 2013 Near Infinity Corporation
6
+ * Commits in this fork are (c) Ziggy Jonsson (ziggy.jonsson.nyc@gmail.com)
7
+ */
8
+ export interface ZipVars {
9
+ uncompressedSize: number;
10
+ compressedSize: number;
11
+ offsetToLocalFileHeader?: number;
12
+ }
13
+ export interface ExtraField {
14
+ uncompressedSize?: number;
15
+ compressedSize?: number;
16
+ offsetToLocalFileHeader?: number;
17
+ }
18
+ export declare function parseExtraField(extraField: Buffer, vars: ZipVars): ExtraField;