@cj-tech-master/excelts 4.2.2 → 4.2.3-canary.20260122073152.a9bb6b0
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/utils/parse-sax.d.ts +3 -0
- package/dist/browser/modules/excel/utils/parse-sax.js +32 -13
- 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 +8 -0
- package/dist/browser/modules/excel/workbook.js +9 -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/core/app-xform.js +3 -3
- package/dist/browser/modules/excel/xlsx/xform/core/content-types-xform.js +16 -10
- package/dist/browser/modules/excel/xlsx/xform/core/core-xform.js +56 -68
- package/dist/browser/modules/excel/xlsx/xform/list-xform.js +8 -10
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.d.ts +34 -11
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +256 -86
- package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +38 -11
- package/dist/browser/modules/excel/xlsx/xform/strings/shared-string-xform.js +2 -3
- package/dist/browser/modules/excel/xlsx/xform/strings/text-xform.js +5 -7
- package/dist/browser/modules/excel/xlsx/xlsx.browser.d.ts +36 -1
- package/dist/browser/modules/excel/xlsx/xlsx.browser.js +213 -127
- 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/utils/parse-sax.js +32 -13
- package/dist/cjs/modules/excel/utils/passthrough-manager.js +133 -0
- package/dist/cjs/modules/excel/workbook.js +9 -1
- package/dist/cjs/modules/excel/worksheet.js +4 -1
- package/dist/cjs/modules/excel/xlsx/xform/core/app-xform.js +3 -3
- package/dist/cjs/modules/excel/xlsx/xform/core/content-types-xform.js +16 -10
- package/dist/cjs/modules/excel/xlsx/xform/core/core-xform.js +56 -68
- package/dist/cjs/modules/excel/xlsx/xform/list-xform.js +8 -10
- package/dist/cjs/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +256 -86
- package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +38 -11
- package/dist/cjs/modules/excel/xlsx/xform/strings/shared-string-xform.js +2 -3
- package/dist/cjs/modules/excel/xlsx/xform/strings/text-xform.js +5 -7
- package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +213 -127
- 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/utils/parse-sax.js +32 -13
- package/dist/esm/modules/excel/utils/passthrough-manager.js +129 -0
- package/dist/esm/modules/excel/workbook.js +9 -1
- package/dist/esm/modules/excel/worksheet.js +4 -1
- package/dist/esm/modules/excel/xlsx/xform/core/app-xform.js +3 -3
- package/dist/esm/modules/excel/xlsx/xform/core/content-types-xform.js +16 -10
- package/dist/esm/modules/excel/xlsx/xform/core/core-xform.js +56 -68
- package/dist/esm/modules/excel/xlsx/xform/list-xform.js +8 -10
- package/dist/esm/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +256 -86
- package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +38 -11
- package/dist/esm/modules/excel/xlsx/xform/strings/shared-string-xform.js +2 -3
- package/dist/esm/modules/excel/xlsx/xform/strings/text-xform.js +5 -7
- package/dist/esm/modules/excel/xlsx/xlsx.browser.js +213 -127
- package/dist/esm/modules/stream/streams.browser.js +0 -3
- package/dist/iife/excelts.iife.js +603 -333
- 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/utils/parse-sax.d.ts +3 -0
- package/dist/types/modules/excel/utils/passthrough-manager.d.ts +77 -0
- package/dist/types/modules/excel/workbook.d.ts +8 -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 +34 -11
- package/dist/types/modules/excel/xlsx/xlsx.browser.d.ts +36 -1
- package/package.json +2 -2
|
@@ -3,31 +3,50 @@ import { BaseXform } from "../base-xform.js";
|
|
|
3
3
|
import { DateXform } from "../simple/date-xform.js";
|
|
4
4
|
import { StringXform } from "../simple/string-xform.js";
|
|
5
5
|
import { IntegerXform } from "../simple/integer-xform.js";
|
|
6
|
+
// Rendering uses namespace prefixes, parsing uses unqualified names (SAX strips prefixes)
|
|
7
|
+
const PROPS = {
|
|
8
|
+
creator: "dc:creator",
|
|
9
|
+
title: "dc:title",
|
|
10
|
+
subject: "dc:subject",
|
|
11
|
+
description: "dc:description",
|
|
12
|
+
identifier: "dc:identifier",
|
|
13
|
+
language: "dc:language",
|
|
14
|
+
keywords: "cp:keywords",
|
|
15
|
+
category: "cp:category",
|
|
16
|
+
lastModifiedBy: "cp:lastModifiedBy",
|
|
17
|
+
lastPrinted: "cp:lastPrinted",
|
|
18
|
+
revision: "cp:revision",
|
|
19
|
+
version: "cp:version",
|
|
20
|
+
contentStatus: "cp:contentStatus",
|
|
21
|
+
contentType: "cp:contentType",
|
|
22
|
+
created: "dcterms:created",
|
|
23
|
+
modified: "dcterms:modified"
|
|
24
|
+
};
|
|
6
25
|
class CoreXform extends BaseXform {
|
|
7
26
|
constructor() {
|
|
8
27
|
super();
|
|
9
28
|
this.map = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
tag:
|
|
29
|
+
creator: new StringXform({ tag: PROPS.creator }),
|
|
30
|
+
title: new StringXform({ tag: PROPS.title }),
|
|
31
|
+
subject: new StringXform({ tag: PROPS.subject }),
|
|
32
|
+
description: new StringXform({ tag: PROPS.description }),
|
|
33
|
+
identifier: new StringXform({ tag: PROPS.identifier }),
|
|
34
|
+
language: new StringXform({ tag: PROPS.language }),
|
|
35
|
+
keywords: new StringXform({ tag: PROPS.keywords }),
|
|
36
|
+
category: new StringXform({ tag: PROPS.category }),
|
|
37
|
+
lastModifiedBy: new StringXform({ tag: PROPS.lastModifiedBy }),
|
|
38
|
+
lastPrinted: new DateXform({ tag: PROPS.lastPrinted, format: CoreXform.DateFormat }),
|
|
39
|
+
revision: new IntegerXform({ tag: PROPS.revision }),
|
|
40
|
+
version: new StringXform({ tag: PROPS.version }),
|
|
41
|
+
contentStatus: new StringXform({ tag: PROPS.contentStatus }),
|
|
42
|
+
contentType: new StringXform({ tag: PROPS.contentType }),
|
|
43
|
+
created: new DateXform({
|
|
44
|
+
tag: PROPS.created,
|
|
26
45
|
attrs: CoreXform.DateAttrs,
|
|
27
46
|
format: CoreXform.DateFormat
|
|
28
47
|
}),
|
|
29
|
-
|
|
30
|
-
tag:
|
|
48
|
+
modified: new DateXform({
|
|
49
|
+
tag: PROPS.modified,
|
|
31
50
|
attrs: CoreXform.DateAttrs,
|
|
32
51
|
format: CoreXform.DateFormat
|
|
33
52
|
})
|
|
@@ -36,22 +55,9 @@ class CoreXform extends BaseXform {
|
|
|
36
55
|
render(xmlStream, model) {
|
|
37
56
|
xmlStream.openXml(XmlStream.StdDocAttributes);
|
|
38
57
|
xmlStream.openNode("cp:coreProperties", CoreXform.CORE_PROPERTY_ATTRIBUTES);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this.map["dc:description"].render(xmlStream, model.description);
|
|
43
|
-
this.map["dc:identifier"].render(xmlStream, model.identifier);
|
|
44
|
-
this.map["dc:language"].render(xmlStream, model.language);
|
|
45
|
-
this.map["cp:keywords"].render(xmlStream, model.keywords);
|
|
46
|
-
this.map["cp:category"].render(xmlStream, model.category);
|
|
47
|
-
this.map["cp:lastModifiedBy"].render(xmlStream, model.lastModifiedBy);
|
|
48
|
-
this.map["cp:lastPrinted"].render(xmlStream, model.lastPrinted);
|
|
49
|
-
this.map["cp:revision"].render(xmlStream, model.revision);
|
|
50
|
-
this.map["cp:version"].render(xmlStream, model.version);
|
|
51
|
-
this.map["cp:contentStatus"].render(xmlStream, model.contentStatus);
|
|
52
|
-
this.map["cp:contentType"].render(xmlStream, model.contentType);
|
|
53
|
-
this.map["dcterms:created"].render(xmlStream, model.created);
|
|
54
|
-
this.map["dcterms:modified"].render(xmlStream, model.modified);
|
|
58
|
+
for (const key of Object.keys(PROPS)) {
|
|
59
|
+
this.map[key].render(xmlStream, model[key]);
|
|
60
|
+
}
|
|
55
61
|
xmlStream.closeNode();
|
|
56
62
|
}
|
|
57
63
|
parseOpen(node) {
|
|
@@ -59,18 +65,13 @@ class CoreXform extends BaseXform {
|
|
|
59
65
|
this.parser.parseOpen(node);
|
|
60
66
|
return true;
|
|
61
67
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
this.parser = this.map[node.name];
|
|
68
|
-
if (this.parser) {
|
|
69
|
-
this.parser.parseOpen(node);
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
throw new Error(`Unexpected xml node in parseOpen: ${JSON.stringify(node)}`);
|
|
68
|
+
if (node.name !== "coreProperties") {
|
|
69
|
+
this.parser = this.map[node.name];
|
|
70
|
+
if (this.parser) {
|
|
71
|
+
this.parser.parseOpen(node);
|
|
72
|
+
}
|
|
73
73
|
}
|
|
74
|
+
return true;
|
|
74
75
|
}
|
|
75
76
|
parseText(text) {
|
|
76
77
|
if (this.parser) {
|
|
@@ -84,30 +85,17 @@ class CoreXform extends BaseXform {
|
|
|
84
85
|
}
|
|
85
86
|
return true;
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
this.model
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
language: this.map["dc:language"].model,
|
|
97
|
-
keywords: this.map["cp:keywords"].model,
|
|
98
|
-
category: this.map["cp:category"].model,
|
|
99
|
-
lastModifiedBy: this.map["cp:lastModifiedBy"].model,
|
|
100
|
-
lastPrinted: this.map["cp:lastPrinted"].model,
|
|
101
|
-
revision: this.map["cp:revision"].model,
|
|
102
|
-
contentStatus: this.map["cp:contentStatus"].model,
|
|
103
|
-
contentType: this.map["cp:contentType"].model,
|
|
104
|
-
created: this.map["dcterms:created"].model,
|
|
105
|
-
modified: this.map["dcterms:modified"].model
|
|
106
|
-
};
|
|
107
|
-
return false;
|
|
108
|
-
default:
|
|
109
|
-
throw new Error(`Unexpected xml node in parseClose: ${name}`);
|
|
88
|
+
if (name === "coreProperties") {
|
|
89
|
+
this.model = {};
|
|
90
|
+
for (const key of Object.keys(PROPS)) {
|
|
91
|
+
const val = this.map[key].model;
|
|
92
|
+
if (val !== undefined && val !== "") {
|
|
93
|
+
this.model[key] = val;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
110
97
|
}
|
|
98
|
+
return true;
|
|
111
99
|
}
|
|
112
100
|
}
|
|
113
101
|
CoreXform.DateFormat = function (dt) {
|
|
@@ -41,17 +41,15 @@ class ListXform extends BaseXform {
|
|
|
41
41
|
this.parser.parseOpen(node);
|
|
42
42
|
return true;
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return true;
|
|
48
|
-
default:
|
|
49
|
-
if (this.childXform.parseOpen(node)) {
|
|
50
|
-
this.parser = this.childXform;
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
return false;
|
|
44
|
+
if (node.name === this.tag) {
|
|
45
|
+
this.model = [];
|
|
46
|
+
return true;
|
|
54
47
|
}
|
|
48
|
+
if (this.childXform.parseOpen(node)) {
|
|
49
|
+
this.parser = this.childXform;
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
55
53
|
}
|
|
56
54
|
parseText(text) {
|
|
57
55
|
if (this.parser) {
|
|
@@ -67,26 +67,45 @@ interface ParsedPivotTableModel {
|
|
|
67
67
|
compact?: boolean;
|
|
68
68
|
compactData?: boolean;
|
|
69
69
|
multipleFieldFilters?: boolean;
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
outline?: boolean;
|
|
71
|
+
outlineData?: boolean;
|
|
72
|
+
chartFormat?: number;
|
|
73
|
+
rowItems?: RowColItem[];
|
|
74
|
+
colItems?: RowColItem[];
|
|
75
|
+
chartFormats?: ChartFormatItem[];
|
|
72
76
|
isLoaded?: boolean;
|
|
73
77
|
extensions?: any[];
|
|
74
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Row or column item in pivot table
|
|
81
|
+
*/
|
|
82
|
+
interface RowColItem {
|
|
83
|
+
t?: string;
|
|
84
|
+
x: Array<{
|
|
85
|
+
v: number;
|
|
86
|
+
}>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Chart format item for pivot charts
|
|
90
|
+
*/
|
|
91
|
+
interface ChartFormatItem {
|
|
92
|
+
chart: number;
|
|
93
|
+
format: number;
|
|
94
|
+
series?: boolean;
|
|
95
|
+
pivotAreaXml?: string;
|
|
96
|
+
}
|
|
75
97
|
declare class PivotTableXform extends BaseXform {
|
|
76
98
|
map: {
|
|
77
99
|
[key: string]: any;
|
|
78
100
|
};
|
|
79
101
|
model: ParsedPivotTableModel | null;
|
|
80
|
-
private
|
|
81
|
-
private inRowFields;
|
|
82
|
-
private inColFields;
|
|
83
|
-
private inDataFields;
|
|
84
|
-
private inRowItems;
|
|
85
|
-
private inColItems;
|
|
86
|
-
private inLocation;
|
|
102
|
+
private state;
|
|
87
103
|
private currentPivotField;
|
|
88
|
-
private
|
|
89
|
-
private
|
|
104
|
+
private currentRowItem;
|
|
105
|
+
private currentColItem;
|
|
106
|
+
private currentChartFormat;
|
|
107
|
+
private pivotAreaXmlBuffer;
|
|
108
|
+
private pivotAreaDepth;
|
|
90
109
|
constructor();
|
|
91
110
|
prepare(_model: any): void;
|
|
92
111
|
get tag(): string;
|
|
@@ -104,6 +123,10 @@ declare class PivotTableXform extends BaseXform {
|
|
|
104
123
|
* Render loaded pivot table (preserving original structure)
|
|
105
124
|
*/
|
|
106
125
|
private renderLoaded;
|
|
126
|
+
/**
|
|
127
|
+
* Render a row or column item element
|
|
128
|
+
*/
|
|
129
|
+
private renderRowColItem;
|
|
107
130
|
/**
|
|
108
131
|
* Render a loaded pivot field
|
|
109
132
|
*/
|