@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.
- package/dist/browser/excelts.iife.js +2568 -1188
- package/dist/browser/excelts.iife.js.map +1 -1
- package/dist/browser/excelts.iife.min.js +21 -19
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/stream/xlsx/workbook-reader.js +2 -2
- package/dist/cjs/stream/xlsx/workbook-writer.js +8 -4
- package/dist/cjs/utils/cell-format.js +815 -0
- package/dist/cjs/utils/cell-matrix.js +37 -2
- package/dist/cjs/utils/parse-sax.js +2 -2
- package/dist/cjs/utils/sheet-utils.js +615 -0
- package/dist/cjs/utils/stream-buf.js +15 -4
- package/dist/cjs/utils/unzip/buffer-stream.js +27 -0
- package/dist/cjs/utils/unzip/index.js +23 -0
- package/dist/cjs/utils/unzip/noop-stream.js +20 -0
- package/dist/cjs/utils/unzip/parse-buffer.js +60 -0
- package/dist/cjs/utils/unzip/parse-datetime.js +23 -0
- package/dist/cjs/utils/unzip/parse-extra-field.js +52 -0
- package/dist/cjs/utils/unzip/parse.js +340 -0
- package/dist/cjs/utils/unzip/pull-stream.js +145 -0
- package/dist/cjs/utils/utils.js +13 -17
- package/dist/cjs/utils/zip-stream.js +29 -33
- package/dist/cjs/xlsx/xlsx.js +1 -2
- package/dist/esm/index.browser.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/stream/xlsx/workbook-reader.js +2 -2
- package/dist/esm/stream/xlsx/workbook-writer.js +9 -5
- package/dist/esm/utils/cell-format.js +810 -0
- package/dist/esm/utils/cell-matrix.js +37 -2
- package/dist/esm/utils/parse-sax.js +1 -1
- package/dist/esm/utils/sheet-utils.js +595 -0
- package/dist/esm/utils/stream-buf.js +15 -4
- package/dist/esm/utils/unzip/buffer-stream.js +24 -0
- package/dist/esm/utils/unzip/index.js +12 -0
- package/dist/esm/utils/unzip/noop-stream.js +16 -0
- package/dist/esm/utils/unzip/parse-buffer.js +57 -0
- package/dist/esm/utils/unzip/parse-datetime.js +20 -0
- package/dist/esm/utils/unzip/parse-extra-field.js +49 -0
- package/dist/esm/utils/unzip/parse.js +332 -0
- package/dist/esm/utils/unzip/pull-stream.js +141 -0
- package/dist/esm/utils/utils.js +12 -16
- package/dist/esm/utils/zip-stream.js +30 -34
- package/dist/esm/xlsx/xlsx.js +1 -2
- package/dist/types/doc/column.d.ts +1 -1
- package/dist/types/doc/worksheet.d.ts +2 -2
- package/dist/types/index.browser.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stream/xlsx/workbook-writer.d.ts +1 -0
- package/dist/types/utils/cell-format.d.ts +32 -0
- package/dist/types/utils/sheet-utils.d.ts +203 -0
- package/dist/types/utils/unzip/buffer-stream.d.ts +9 -0
- package/dist/types/utils/unzip/index.d.ts +12 -0
- package/dist/types/utils/unzip/noop-stream.d.ts +13 -0
- package/dist/types/utils/unzip/parse-buffer.d.ts +24 -0
- package/dist/types/utils/unzip/parse-datetime.d.ts +12 -0
- package/dist/types/utils/unzip/parse-extra-field.d.ts +18 -0
- package/dist/types/utils/unzip/parse.d.ts +70 -0
- package/dist/types/utils/unzip/pull-stream.d.ts +24 -0
- package/dist/types/utils/utils.d.ts +5 -2
- package/dist/types/utils/zip-stream.d.ts +5 -1
- package/package.json +35 -32
- package/dist/cjs/utils/browser-buffer-decode.js +0 -13
- package/dist/cjs/utils/browser-buffer-encode.js +0 -13
- package/dist/cjs/utils/browser.js +0 -6
- package/dist/esm/utils/browser-buffer-decode.js +0 -11
- package/dist/esm/utils/browser-buffer-encode.js +0 -11
- package/dist/esm/utils/browser.js +0 -3
- package/dist/types/utils/browser-buffer-decode.d.ts +0 -2
- package/dist/types/utils/browser-buffer-encode.d.ts +0 -2
- package/dist/types/utils/browser.d.ts +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -9,7 +9,6 @@ const events_1 = require("events");
|
|
|
9
9
|
const stream_1 = require("stream");
|
|
10
10
|
const os_1 = __importDefault(require("os"));
|
|
11
11
|
const path_1 = require("path");
|
|
12
|
-
const unzipper_1 = require("unzipper");
|
|
13
12
|
const iterate_stream_js_1 = require("../../utils/iterate-stream");
|
|
14
13
|
const parse_sax_js_1 = require("../../utils/parse-sax");
|
|
15
14
|
const styles_xform_js_1 = require("../../xlsx/xform/style/styles-xform");
|
|
@@ -17,6 +16,7 @@ const workbook_xform_js_1 = require("../../xlsx/xform/book/workbook-xform");
|
|
|
17
16
|
const relationships_xform_js_1 = require("../../xlsx/xform/core/relationships-xform");
|
|
18
17
|
const worksheet_reader_js_1 = require("./worksheet-reader");
|
|
19
18
|
const hyperlink_reader_js_1 = require("./hyperlink-reader");
|
|
19
|
+
const parse_js_1 = require("../../utils/unzip/parse");
|
|
20
20
|
class WorkbookReader extends events_1.EventEmitter {
|
|
21
21
|
constructor(input, options = {}) {
|
|
22
22
|
super();
|
|
@@ -76,7 +76,7 @@ class WorkbookReader extends events_1.EventEmitter {
|
|
|
76
76
|
this.options = options;
|
|
77
77
|
}
|
|
78
78
|
const stream = (this.stream = this._getStream(input || this.input));
|
|
79
|
-
const zip = (0,
|
|
79
|
+
const zip = (0, parse_js_1.createParse)({ forceStream: true });
|
|
80
80
|
// Handle pipe errors to prevent unhandled rejection
|
|
81
81
|
stream.on("error", (err) => {
|
|
82
82
|
zip.emit("error", err);
|
|
@@ -36,6 +36,10 @@ class WorkbookWriter {
|
|
|
36
36
|
this._worksheets = [];
|
|
37
37
|
this.views = [];
|
|
38
38
|
this.zipOptions = options.zip;
|
|
39
|
+
// Extract compression level from zip options (supports both zlib.level and compressionOptions.level)
|
|
40
|
+
// Default compression level is 6 (good balance of speed and size)
|
|
41
|
+
const level = options.zip?.zlib?.level ?? options.zip?.compressionOptions?.level ?? 6;
|
|
42
|
+
this.compressionLevel = Math.max(0, Math.min(9, level));
|
|
39
43
|
this.media = [];
|
|
40
44
|
this.commentRefs = [];
|
|
41
45
|
// Create fflate Zip instance
|
|
@@ -67,8 +71,8 @@ class WorkbookWriter {
|
|
|
67
71
|
}
|
|
68
72
|
_openStream(path) {
|
|
69
73
|
const stream = new stream_buf_js_1.StreamBuf({ bufSize: 65536, batch: true });
|
|
70
|
-
// Create a
|
|
71
|
-
const zipFile = new fflate_1.
|
|
74
|
+
// Create a ZipDeflate for this file with compression
|
|
75
|
+
const zipFile = new fflate_1.ZipDeflate(path, { level: this.compressionLevel });
|
|
72
76
|
this.zip.add(zipFile);
|
|
73
77
|
// Don't pause the stream - we need data events to flow
|
|
74
78
|
// The original implementation used archiver which consumed the stream internally
|
|
@@ -87,8 +91,8 @@ class WorkbookWriter {
|
|
|
87
91
|
return stream;
|
|
88
92
|
}
|
|
89
93
|
_addFile(data, name, base64) {
|
|
90
|
-
// Helper method to add a file to the zip using fflate
|
|
91
|
-
const zipFile = new fflate_1.
|
|
94
|
+
// Helper method to add a file to the zip using fflate with compression
|
|
95
|
+
const zipFile = new fflate_1.ZipDeflate(name, { level: this.compressionLevel });
|
|
92
96
|
this.zip.add(zipFile);
|
|
93
97
|
let buffer;
|
|
94
98
|
if (base64) {
|