@cj-tech-master/excelts 4.2.3 → 5.0.0-canary.20260123012457.1fdf506
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/modules/csv/csv-core.d.ts +0 -9
- package/dist/browser/modules/csv/csv.browser.js +3 -3
- package/dist/browser/modules/excel/column.d.ts +5 -0
- package/dist/browser/modules/excel/column.js +10 -2
- package/dist/browser/modules/excel/row.d.ts +2 -0
- package/dist/browser/modules/excel/row.js +3 -1
- package/dist/browser/modules/excel/utils/parse-sax.d.ts +0 -3
- package/dist/browser/modules/excel/utils/parse-sax.js +13 -32
- package/dist/browser/modules/excel/utils/passthrough-manager.d.ts +77 -0
- package/dist/browser/modules/excel/utils/passthrough-manager.js +129 -0
- package/dist/browser/modules/excel/workbook.d.ts +12 -0
- package/dist/browser/modules/excel/workbook.js +12 -1
- package/dist/browser/modules/excel/worksheet.d.ts +4 -0
- package/dist/browser/modules/excel/worksheet.js +4 -1
- package/dist/browser/modules/excel/xlsx/xform/base-xform.js +68 -1
- package/dist/browser/modules/excel/xlsx/xform/core/content-types-xform.js +16 -10
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.d.ts +35 -11
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +271 -94
- package/dist/browser/modules/excel/xlsx/xform/sheet/row-xform.d.ts +1 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/row-xform.js +7 -1
- package/dist/browser/modules/excel/xlsx/xform/sheet/sheet-format-properties-xform.d.ts +1 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/sheet-format-properties-xform.js +9 -4
- package/dist/browser/modules/excel/xlsx/xform/sheet/sheet-view-xform.js +4 -2
- package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +40 -12
- package/dist/browser/modules/excel/xlsx/xform/style/style-xform.d.ts +7 -0
- package/dist/browser/modules/excel/xlsx/xform/style/style-xform.js +26 -6
- package/dist/browser/modules/excel/xlsx/xform/style/styles-xform.d.ts +6 -0
- package/dist/browser/modules/excel/xlsx/xform/style/styles-xform.js +52 -4
- package/dist/browser/modules/excel/xlsx/xlsx.browser.d.ts +36 -1
- package/dist/browser/modules/excel/xlsx/xlsx.browser.js +220 -131
- package/dist/browser/modules/stream/streams.browser.js +0 -3
- package/dist/cjs/modules/csv/csv.browser.js +3 -3
- package/dist/cjs/modules/excel/column.js +10 -2
- package/dist/cjs/modules/excel/row.js +3 -1
- package/dist/cjs/modules/excel/utils/parse-sax.js +13 -32
- package/dist/cjs/modules/excel/utils/passthrough-manager.js +133 -0
- package/dist/cjs/modules/excel/workbook.js +12 -1
- package/dist/cjs/modules/excel/worksheet.js +4 -1
- package/dist/cjs/modules/excel/xlsx/xform/base-xform.js +68 -1
- package/dist/cjs/modules/excel/xlsx/xform/core/content-types-xform.js +16 -10
- package/dist/cjs/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +271 -94
- package/dist/cjs/modules/excel/xlsx/xform/sheet/row-xform.js +7 -1
- package/dist/cjs/modules/excel/xlsx/xform/sheet/sheet-format-properties-xform.js +9 -4
- package/dist/cjs/modules/excel/xlsx/xform/sheet/sheet-view-xform.js +4 -2
- package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +40 -12
- package/dist/cjs/modules/excel/xlsx/xform/style/style-xform.js +26 -6
- package/dist/cjs/modules/excel/xlsx/xform/style/styles-xform.js +52 -4
- package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +220 -131
- package/dist/cjs/modules/stream/streams.browser.js +0 -3
- package/dist/esm/modules/csv/csv.browser.js +3 -3
- package/dist/esm/modules/excel/column.js +10 -2
- package/dist/esm/modules/excel/row.js +3 -1
- package/dist/esm/modules/excel/utils/parse-sax.js +13 -32
- package/dist/esm/modules/excel/utils/passthrough-manager.js +129 -0
- package/dist/esm/modules/excel/workbook.js +12 -1
- package/dist/esm/modules/excel/worksheet.js +4 -1
- package/dist/esm/modules/excel/xlsx/xform/base-xform.js +68 -1
- package/dist/esm/modules/excel/xlsx/xform/core/content-types-xform.js +16 -10
- package/dist/esm/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +271 -94
- package/dist/esm/modules/excel/xlsx/xform/sheet/row-xform.js +7 -1
- package/dist/esm/modules/excel/xlsx/xform/sheet/sheet-format-properties-xform.js +9 -4
- package/dist/esm/modules/excel/xlsx/xform/sheet/sheet-view-xform.js +4 -2
- package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +40 -12
- package/dist/esm/modules/excel/xlsx/xform/style/style-xform.js +26 -6
- package/dist/esm/modules/excel/xlsx/xform/style/styles-xform.js +52 -4
- package/dist/esm/modules/excel/xlsx/xlsx.browser.js +220 -131
- package/dist/esm/modules/stream/streams.browser.js +0 -3
- package/dist/iife/excelts.iife.js +1009 -650
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +25 -52
- package/dist/types/modules/csv/csv-core.d.ts +0 -9
- package/dist/types/modules/excel/column.d.ts +5 -0
- package/dist/types/modules/excel/row.d.ts +2 -0
- package/dist/types/modules/excel/utils/parse-sax.d.ts +0 -3
- package/dist/types/modules/excel/utils/passthrough-manager.d.ts +77 -0
- package/dist/types/modules/excel/workbook.d.ts +12 -0
- package/dist/types/modules/excel/worksheet.d.ts +4 -0
- package/dist/types/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.d.ts +35 -11
- package/dist/types/modules/excel/xlsx/xform/sheet/row-xform.d.ts +1 -0
- package/dist/types/modules/excel/xlsx/xform/sheet/sheet-format-properties-xform.d.ts +1 -0
- package/dist/types/modules/excel/xlsx/xform/style/style-xform.d.ts +7 -0
- package/dist/types/modules/excel/xlsx/xform/style/styles-xform.d.ts +6 -0
- package/dist/types/modules/excel/xlsx/xlsx.browser.d.ts +36 -1
- package/package.json +15 -15
|
@@ -191,6 +191,23 @@ class WorkSheetXform extends base_xform_1.BaseXform {
|
|
|
191
191
|
vmlDrawing: `vmlDrawing${model.id}`
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
|
+
// Handle pre-loaded drawing (from file read) that may contain charts or other non-image content
|
|
195
|
+
// This preserves drawings through round-trip even if they don't contain images
|
|
196
|
+
// Note: Always assign a new rId since rels are rebuilt during write
|
|
197
|
+
if (model.drawing && model.drawing.anchors) {
|
|
198
|
+
// This is a loaded drawing that needs to be added to relationships
|
|
199
|
+
const drawing = model.drawing;
|
|
200
|
+
drawing.rId = nextRid(rels);
|
|
201
|
+
if (!drawing.name) {
|
|
202
|
+
drawing.name = `drawing${++options.drawingsCount}`;
|
|
203
|
+
}
|
|
204
|
+
options.drawings.push(drawing);
|
|
205
|
+
rels.push({
|
|
206
|
+
Id: drawing.rId,
|
|
207
|
+
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",
|
|
208
|
+
Target: (0, ooxml_paths_1.drawingRelTargetFromWorksheet)(drawing.name)
|
|
209
|
+
});
|
|
210
|
+
}
|
|
194
211
|
const drawingRelsHash = [];
|
|
195
212
|
let bookImage;
|
|
196
213
|
model.media.forEach(medium => {
|
|
@@ -370,7 +387,8 @@ class WorkSheetXform extends base_xform_1.BaseXform {
|
|
|
370
387
|
defaultRowHeight: model.properties.defaultRowHeight,
|
|
371
388
|
dyDescent: model.properties.dyDescent,
|
|
372
389
|
outlineLevelCol: model.properties.outlineLevelCol,
|
|
373
|
-
outlineLevelRow: model.properties.outlineLevelRow
|
|
390
|
+
outlineLevelRow: model.properties.outlineLevelRow,
|
|
391
|
+
customHeight: model.properties.customHeight
|
|
374
392
|
}
|
|
375
393
|
: undefined;
|
|
376
394
|
if (model.properties && model.properties.defaultColWidth) {
|
|
@@ -602,17 +620,27 @@ class WorkSheetXform extends base_xform_1.BaseXform {
|
|
|
602
620
|
if (match) {
|
|
603
621
|
const drawingName = match[1];
|
|
604
622
|
const drawing = options.drawings[drawingName];
|
|
605
|
-
drawing
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
623
|
+
if (drawing) {
|
|
624
|
+
// Preserve the drawing object for round-trip (charts, etc.)
|
|
625
|
+
// This includes the name, anchors, and rels
|
|
626
|
+
model.drawing = {
|
|
627
|
+
...drawing,
|
|
628
|
+
name: drawingName,
|
|
629
|
+
rels: options.drawingRels?.[drawingName] || drawing.rels || []
|
|
630
|
+
};
|
|
631
|
+
// Also extract images to model.media for backward compatibility
|
|
632
|
+
drawing.anchors.forEach(anchor => {
|
|
633
|
+
if (anchor.medium) {
|
|
634
|
+
const image = {
|
|
635
|
+
type: "image",
|
|
636
|
+
imageId: anchor.medium.index,
|
|
637
|
+
range: anchor.range,
|
|
638
|
+
hyperlinks: anchor.picture.hyperlinks
|
|
639
|
+
};
|
|
640
|
+
model.media.push(image);
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
}
|
|
616
644
|
}
|
|
617
645
|
}
|
|
618
646
|
const backgroundRel = model.background && rels[model.background.rId];
|
|
@@ -27,24 +27,27 @@ class StyleXform extends base_xform_1.BaseXform {
|
|
|
27
27
|
if (this.xfId) {
|
|
28
28
|
xmlStream.addAttribute("xfId", model.xfId || 0);
|
|
29
29
|
}
|
|
30
|
-
if (model.numFmtId) {
|
|
30
|
+
if (model.applyNumberFormat || model.numFmtId) {
|
|
31
31
|
xmlStream.addAttribute("applyNumberFormat", "1");
|
|
32
32
|
}
|
|
33
|
-
if (model.fontId) {
|
|
33
|
+
if (model.applyFont || model.fontId) {
|
|
34
34
|
xmlStream.addAttribute("applyFont", "1");
|
|
35
35
|
}
|
|
36
|
-
if (model.fillId) {
|
|
36
|
+
if (model.applyFill || model.fillId) {
|
|
37
37
|
xmlStream.addAttribute("applyFill", "1");
|
|
38
38
|
}
|
|
39
|
-
if (model.borderId) {
|
|
39
|
+
if (model.applyBorder || model.borderId) {
|
|
40
40
|
xmlStream.addAttribute("applyBorder", "1");
|
|
41
41
|
}
|
|
42
|
-
if (model.alignment) {
|
|
42
|
+
if (model.applyAlignment || model.alignment) {
|
|
43
43
|
xmlStream.addAttribute("applyAlignment", "1");
|
|
44
44
|
}
|
|
45
|
-
if (model.protection) {
|
|
45
|
+
if (model.applyProtection || model.protection) {
|
|
46
46
|
xmlStream.addAttribute("applyProtection", "1");
|
|
47
47
|
}
|
|
48
|
+
if (model.pivotButton) {
|
|
49
|
+
xmlStream.addAttribute("pivotButton", "1");
|
|
50
|
+
}
|
|
48
51
|
/**
|
|
49
52
|
* Rendering tags causes close of XML stream.
|
|
50
53
|
* Therefore adding attributes must be done before rendering tags.
|
|
@@ -85,6 +88,23 @@ class StyleXform extends base_xform_1.BaseXform {
|
|
|
85
88
|
if (this.xfId) {
|
|
86
89
|
this.model.xfId = parseInt(node.attributes.xfId, 10);
|
|
87
90
|
}
|
|
91
|
+
if (node.attributes.pivotButton === "1") {
|
|
92
|
+
this.model.pivotButton = true;
|
|
93
|
+
}
|
|
94
|
+
// Preserve apply* flags from original file
|
|
95
|
+
const applyFlags = [
|
|
96
|
+
"applyNumberFormat",
|
|
97
|
+
"applyFont",
|
|
98
|
+
"applyFill",
|
|
99
|
+
"applyBorder",
|
|
100
|
+
"applyAlignment",
|
|
101
|
+
"applyProtection"
|
|
102
|
+
];
|
|
103
|
+
for (const flag of applyFlags) {
|
|
104
|
+
if (node.attributes[flag] === "1") {
|
|
105
|
+
this.model[flag] = true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
88
108
|
return true;
|
|
89
109
|
case "alignment":
|
|
90
110
|
this.parser = this.map.alignment;
|
|
@@ -87,6 +87,13 @@ class StylesXform extends base_xform_1.BaseXform {
|
|
|
87
87
|
this.weakMap = new WeakMap();
|
|
88
88
|
this._hasCheckboxes = false;
|
|
89
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Set the default font to use when no font is explicitly specified.
|
|
92
|
+
* This preserves the original file's default font during round-trip.
|
|
93
|
+
*/
|
|
94
|
+
setDefaultFont(font) {
|
|
95
|
+
this.defaultFont = font;
|
|
96
|
+
}
|
|
90
97
|
render(xmlStream, model) {
|
|
91
98
|
const renderModel = model || this.model;
|
|
92
99
|
//
|
|
@@ -103,8 +110,8 @@ class StylesXform extends base_xform_1.BaseXform {
|
|
|
103
110
|
xmlStream.closeNode();
|
|
104
111
|
}
|
|
105
112
|
if (!renderModel.fonts.length) {
|
|
106
|
-
// default (zero) font
|
|
107
|
-
this._addFont({
|
|
113
|
+
// default (zero) font - use preserved font or fallback to Calibri
|
|
114
|
+
this._addFont(this.defaultFont || {
|
|
108
115
|
size: 11,
|
|
109
116
|
color: { theme: 1 },
|
|
110
117
|
name: "Calibri",
|
|
@@ -196,6 +203,10 @@ class StylesXform extends base_xform_1.BaseXform {
|
|
|
196
203
|
add("borders", this.map.borders);
|
|
197
204
|
add("styles", this.map.cellXfs);
|
|
198
205
|
add("dxfs", this.map.dxfs);
|
|
206
|
+
// preserve the default (first) font from the original file
|
|
207
|
+
if (this.map.fonts.model && this.map.fonts.model.length > 0) {
|
|
208
|
+
this.defaultFont = this.map.fonts.model[0];
|
|
209
|
+
}
|
|
199
210
|
// index numFmts
|
|
200
211
|
this.index = {
|
|
201
212
|
model: [],
|
|
@@ -223,8 +234,14 @@ class StylesXform extends base_xform_1.BaseXform {
|
|
|
223
234
|
}
|
|
224
235
|
// if we have no default font, add it here now
|
|
225
236
|
if (!this.model.fonts.length) {
|
|
226
|
-
// default (zero) font
|
|
227
|
-
this._addFont(
|
|
237
|
+
// default (zero) font - use preserved font or fallback to Calibri
|
|
238
|
+
this._addFont(this.defaultFont || {
|
|
239
|
+
size: 11,
|
|
240
|
+
color: { theme: 1 },
|
|
241
|
+
name: "Calibri",
|
|
242
|
+
family: 2,
|
|
243
|
+
scheme: "minor"
|
|
244
|
+
});
|
|
228
245
|
}
|
|
229
246
|
const type = cellType || enums_1.Enums.ValueType.Number;
|
|
230
247
|
// If we have seen this style object before, assume it has the same styleId.
|
|
@@ -265,6 +282,21 @@ class StylesXform extends base_xform_1.BaseXform {
|
|
|
265
282
|
if (model.protection) {
|
|
266
283
|
style.protection = model.protection;
|
|
267
284
|
}
|
|
285
|
+
// Preserve xf-level attributes (pivotButton, apply* flags)
|
|
286
|
+
const xfFlags = [
|
|
287
|
+
"pivotButton",
|
|
288
|
+
"applyNumberFormat",
|
|
289
|
+
"applyFont",
|
|
290
|
+
"applyFill",
|
|
291
|
+
"applyBorder",
|
|
292
|
+
"applyAlignment",
|
|
293
|
+
"applyProtection"
|
|
294
|
+
];
|
|
295
|
+
for (const flag of xfFlags) {
|
|
296
|
+
if (model[flag]) {
|
|
297
|
+
style[flag] = true;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
268
300
|
if (type === enums_1.Enums.ValueType.Checkbox) {
|
|
269
301
|
// Checkbox rendering relies on style extensions (extLst) and workbook-level parts.
|
|
270
302
|
// Force applyAlignment="1" (without emitting an <alignment/> node) by providing
|
|
@@ -325,6 +357,22 @@ class StylesXform extends base_xform_1.BaseXform {
|
|
|
325
357
|
if (style.protection) {
|
|
326
358
|
model.protection = style.protection;
|
|
327
359
|
}
|
|
360
|
+
// -------------------------------------------------------
|
|
361
|
+
// xf-level attributes (pivotButton, apply* flags)
|
|
362
|
+
const xfFlags = [
|
|
363
|
+
"pivotButton",
|
|
364
|
+
"applyNumberFormat",
|
|
365
|
+
"applyFont",
|
|
366
|
+
"applyFill",
|
|
367
|
+
"applyBorder",
|
|
368
|
+
"applyAlignment",
|
|
369
|
+
"applyProtection"
|
|
370
|
+
];
|
|
371
|
+
for (const flag of xfFlags) {
|
|
372
|
+
if (style[flag]) {
|
|
373
|
+
model[flag] = true;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
328
376
|
return model;
|
|
329
377
|
}
|
|
330
378
|
addDxfStyle(style) {
|