@shbernal/ts-xlsx 2.1.0 → 3.1.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/README.md +4 -1
- package/dist/bytes.d.ts +7 -0
- package/dist/bytes.js +22 -0
- package/dist/core/address.d.ts +60 -2
- package/dist/core/address.js +40 -24
- package/dist/core/autofilter.d.ts +5 -4
- package/dist/core/autofilter.js +34 -35
- package/dist/core/axis-handle.d.ts +10 -0
- package/dist/core/axis-handle.js +17 -0
- package/dist/core/cell.d.ts +25 -0
- package/dist/core/cell.js +9 -3
- package/dist/core/clone.d.ts +29 -0
- package/dist/core/clone.js +24 -0
- package/dist/core/color-resolution.js +2 -4
- package/dist/core/column.d.ts +5 -1
- package/dist/core/column.js +34 -35
- package/dist/core/comment-thread.js +2 -1
- package/dist/core/conditional-formatting-overlay.d.ts +2 -1
- package/dist/core/conditional-formatting-overlay.js +2 -2
- package/dist/core/conditional-formatting.d.ts +14 -6
- package/dist/core/conditional-formatting.js +45 -43
- package/dist/core/containers.d.ts +12 -0
- package/dist/core/containers.js +5 -0
- package/dist/core/data-validation-overlay.d.ts +2 -1
- package/dist/core/data-validation-overlay.js +4 -4
- package/dist/core/data-validation.d.ts +9 -3
- package/dist/core/data-validation.js +21 -18
- package/dist/core/date-format.d.ts +20 -0
- package/dist/core/date-format.js +160 -0
- package/dist/core/date.d.ts +43 -8
- package/dist/core/date.js +18 -2
- package/dist/core/formula.d.ts +26 -0
- package/dist/core/formula.js +20 -4
- package/dist/core/grid-edits.d.ts +2 -3
- package/dist/core/grid-edits.js +69 -70
- package/dist/core/grid-shift.d.ts +58 -9
- package/dist/core/grid-shift.js +26 -4
- package/dist/core/image.d.ts +14 -10
- package/dist/core/image.js +9 -9
- package/dist/core/internal.d.ts +8 -2
- package/dist/core/limits.d.ts +23 -0
- package/dist/core/limits.js +4 -0
- package/dist/core/merge-index.d.ts +31 -0
- package/dist/core/merge-index.js +60 -0
- package/dist/core/merge.d.ts +5 -14
- package/dist/core/merge.js +18 -27
- package/dist/core/page-setup.d.ts +72 -2
- package/dist/core/page-setup.js +34 -8
- package/dist/core/pivot-table.d.ts +1 -1
- package/dist/core/pivot-table.js +67 -53
- package/dist/core/protection.js +2 -11
- package/dist/core/range.js +34 -30
- package/dist/core/row-input.js +2 -2
- package/dist/core/row.d.ts +5 -1
- package/dist/core/row.js +22 -23
- package/dist/core/style.d.ts +134 -75
- package/dist/core/style.js +112 -53
- package/dist/core/table-style.d.ts +1 -1
- package/dist/core/table-style.js +4 -4
- package/dist/core/table.d.ts +28 -10
- package/dist/core/table.js +54 -39
- package/dist/core/theme.js +6 -5
- package/dist/core/used-extent.d.ts +44 -0
- package/dist/core/used-extent.js +102 -0
- package/dist/core/value.d.ts +9 -0
- package/dist/core/value.js +36 -34
- package/dist/core/workbook-media.d.ts +34 -0
- package/dist/core/workbook-media.js +44 -0
- package/dist/core/workbook-styles.d.ts +67 -1
- package/dist/core/workbook-vba.js +3 -2
- package/dist/core/workbook.d.ts +23 -2
- package/dist/core/workbook.js +24 -40
- package/dist/core/worksheet-comments.d.ts +2 -1
- package/dist/core/worksheet-comments.js +20 -13
- package/dist/core/worksheet-merges.d.ts +44 -0
- package/dist/core/worksheet-merges.js +59 -0
- package/dist/core/worksheet-model.d.ts +9 -1
- package/dist/core/worksheet-model.js +24 -9
- package/dist/core/worksheet.d.ts +72 -12
- package/dist/core/worksheet.js +68 -70
- package/dist/customui/ribbon.js +6 -7
- package/dist/entries/core.d.ts +18 -13
- package/dist/entries/core.js +12 -6
- package/dist/entries/xlsx.d.ts +1 -1
- package/dist/errors.d.ts +64 -0
- package/dist/errors.js +22 -0
- package/dist/hex.d.ts +8 -0
- package/dist/hex.js +3 -0
- package/dist/io/csv/delimiter.d.ts +9 -0
- package/dist/io/csv/delimiter.js +6 -0
- package/dist/io/csv/read.js +11 -4
- package/dist/io/csv/write.d.ts +9 -2
- package/dist/io/csv/write.js +9 -38
- package/dist/io/opc/inflate.js +15 -1
- package/dist/io/opc/namespaces.d.ts +16 -0
- package/dist/io/opc/namespaces.js +4 -0
- package/dist/io/opc/part-paths.d.ts +10 -0
- package/dist/io/opc/part-paths.js +16 -1
- package/dist/io/opc/read-opc.d.ts +69 -10
- package/dist/io/opc/read-opc.js +49 -55
- package/dist/io/opc/read-options.d.ts +5 -1
- package/dist/io/opc/rels.d.ts +1 -6
- package/dist/io/opc/rels.js +1 -4
- package/dist/io/opc/sniff-format.d.ts +3 -3
- package/dist/io/opc/sniff-format.js +2 -2
- package/dist/io/style/xf-style.d.ts +48 -2
- package/dist/io/style/xf-style.js +14 -0
- package/dist/io/xlsb/formula.d.ts +2 -2
- package/dist/io/xlsb/formula.js +49 -34
- package/dist/io/xlsb/primitives.js +8 -14
- package/dist/io/xlsb/ptg-functions.d.ts +19 -10
- package/dist/io/xlsb/ptg-functions.js +385 -596
- package/dist/io/xlsb/read-styles.js +50 -83
- package/dist/io/xlsb/read-worksheet.d.ts +20 -1
- package/dist/io/xlsb/read-worksheet.js +73 -89
- package/dist/io/xlsb/read.d.ts +6 -3
- package/dist/io/xlsb/read.js +47 -29
- package/dist/io/xlsb/record-stream.d.ts +30 -0
- package/dist/io/xlsb/record-stream.js +20 -0
- package/dist/io/xlsb/record-types.d.ts +1 -5
- package/dist/io/xlsb/record-types.js +1 -5
- package/dist/io/xlsx/cell-accumulator.d.ts +9 -2
- package/dist/io/xlsx/cell-accumulator.js +32 -9
- package/dist/io/xlsx/cell-style-resolution.d.ts +25 -0
- package/dist/io/xlsx/cell-style-resolution.js +29 -0
- package/dist/io/xlsx/cell-value.d.ts +5 -3
- package/dist/io/xlsx/cell-value.js +13 -15
- package/dist/io/xlsx/color-xml.js +3 -2
- package/dist/io/xlsx/column-budget.d.ts +26 -0
- package/dist/io/xlsx/column-budget.js +22 -0
- package/dist/io/xlsx/comments.d.ts +6 -2
- package/dist/io/xlsx/comments.js +36 -31
- package/dist/io/xlsx/conditional-formatting.d.ts +9 -5
- package/dist/io/xlsx/conditional-formatting.js +51 -46
- package/dist/io/xlsx/data-validation.d.ts +9 -7
- package/dist/io/xlsx/data-validation.js +38 -35
- package/dist/io/xlsx/edit-vba.d.ts +7 -2
- package/dist/io/xlsx/edit-vba.js +15 -29
- package/dist/io/xlsx/font-xml.d.ts +7 -0
- package/dist/io/xlsx/font-xml.js +104 -0
- package/dist/io/xlsx/hyperlinks.d.ts +41 -7
- package/dist/io/xlsx/hyperlinks.js +40 -28
- package/dist/io/xlsx/images.js +24 -25
- package/dist/io/xlsx/namespaces.d.ts +16 -0
- package/dist/io/xlsx/namespaces.js +7 -0
- package/dist/io/xlsx/package-plan.d.ts +23 -3
- package/dist/io/xlsx/package-plan.js +66 -25
- package/dist/io/xlsx/part-names.d.ts +41 -0
- package/dist/io/xlsx/part-names.js +46 -0
- package/dist/io/xlsx/pivot.js +8 -7
- package/dist/io/xlsx/read-parts.d.ts +59 -0
- package/dist/io/xlsx/read-parts.js +252 -0
- package/dist/io/xlsx/read-pivot.js +3 -1
- package/dist/io/xlsx/read-repair.d.ts +26 -0
- package/dist/io/xlsx/read-repair.js +39 -0
- package/dist/io/xlsx/{rich-runs.d.ts → read-rich-runs.d.ts} +1 -1
- package/dist/io/xlsx/{rich-runs.js → read-rich-runs.js} +7 -3
- package/dist/io/xlsx/read-rows.d.ts +18 -5
- package/dist/io/xlsx/read-rows.js +50 -37
- package/dist/io/xlsx/read-shared-strings.js +5 -3
- package/dist/io/xlsx/read-styles.d.ts +1 -6
- package/dist/io/xlsx/read-styles.js +65 -109
- package/dist/io/xlsx/read-workbook-xml.d.ts +36 -0
- package/dist/io/xlsx/read-workbook-xml.js +170 -0
- package/dist/io/xlsx/read-worksheet.d.ts +11 -1
- package/dist/io/xlsx/read-worksheet.js +51 -193
- package/dist/io/xlsx/read.d.ts +5 -13
- package/dist/io/xlsx/read.js +111 -436
- package/dist/io/xlsx/rich-text.js +1 -1
- package/dist/io/xlsx/row-position.d.ts +18 -0
- package/dist/io/xlsx/row-position.js +11 -0
- package/dist/io/xlsx/row-xml.d.ts +128 -0
- package/dist/io/xlsx/row-xml.js +203 -0
- package/dist/io/xlsx/shared-formulas.js +2 -2
- package/dist/io/xlsx/sheet-properties.d.ts +10 -1
- package/dist/io/xlsx/sheet-properties.js +166 -37
- package/dist/io/xlsx/style-elements.d.ts +43 -0
- package/dist/io/xlsx/style-elements.js +156 -0
- package/dist/io/xlsx/styles.d.ts +12 -3
- package/dist/io/xlsx/styles.js +5 -204
- package/dist/io/xlsx/tables.js +11 -14
- package/dist/io/xlsx/theme-xml.d.ts +26 -4
- package/dist/io/xlsx/theme-xml.js +107 -69
- package/dist/io/xlsx/threaded-comments.d.ts +8 -10
- package/dist/io/xlsx/threaded-comments.js +3 -1
- package/dist/io/xlsx/workbook-xml.d.ts +54 -4
- package/dist/io/xlsx/workbook-xml.js +84 -57
- package/dist/io/xlsx/worksheet-xml.d.ts +23 -70
- package/dist/io/xlsx/worksheet-xml.js +59 -242
- package/dist/io/xlsx/write-stream.d.ts +71 -16
- package/dist/io/xlsx/write-stream.js +79 -41
- package/dist/io/xlsx/write.d.ts +6 -2
- package/dist/io/xlsx/write.js +217 -153
- package/dist/rel-type.d.ts +16 -0
- package/dist/rel-type.js +6 -0
- package/dist/token-set.d.ts +28 -0
- package/dist/token-set.js +7 -0
- package/dist/vba/bytes.d.ts +14 -5
- package/dist/vba/bytes.js +16 -6
- package/dist/vba/cfb-format.d.ts +32 -0
- package/dist/vba/cfb-format.js +13 -0
- package/dist/vba/cfb-writer.d.ts +9 -0
- package/dist/vba/cfb-writer.js +28 -25
- package/dist/vba/cfb.d.ts +13 -1
- package/dist/vba/cfb.js +73 -57
- package/dist/vba/codepage.js +2 -1
- package/dist/vba/errors.d.ts +7 -0
- package/dist/vba/ms-ovba.js +79 -23
- package/dist/vba/project-editor.js +35 -40
- package/dist/vba/project.d.ts +11 -1
- package/dist/vba/project.js +40 -21
- package/dist/vba/vba-encoding.js +5 -6
- package/dist/xml/xml-attrs.d.ts +37 -0
- package/dist/xml/xml-attrs.js +30 -0
- package/dist/xml/xml-chars.d.ts +40 -0
- package/dist/xml/xml-chars.js +12 -0
- package/dist/xml/xml-namespaces.d.ts +31 -0
- package/dist/xml/xml-namespaces.js +50 -0
- package/dist/xml/xml-read.d.ts +128 -81
- package/dist/xml/xml-read.js +161 -178
- package/dist/xml/xml-scan.d.ts +78 -0
- package/dist/xml/xml-scan.js +180 -0
- package/dist/xml/xml.d.ts +29 -28
- package/dist/xml/xml.js +24 -24
- package/package.json +13 -9
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tryDecodeRange } from '../../core/address.js';
|
|
2
2
|
import { isCustomFilterOperator, } from '../../core/autofilter.js';
|
|
3
3
|
import { INTERNAL } from '../../core/internal.js';
|
|
4
|
-
import {
|
|
5
|
-
import { SHEET_PROTECTION_FLAGS, } from '../../core/protection.js';
|
|
4
|
+
import { HEADER_FOOTER_ELEMENTS } from '../../core/page-setup.js';
|
|
6
5
|
import { assignStyleFacets } from '../../core/style.js';
|
|
7
|
-
import {
|
|
6
|
+
import { decodeSpreadsheetText, numFinite, numInteger } from '../../xml/xml-attrs.js';
|
|
7
|
+
import {} from '../../xml/xml-read.js';
|
|
8
|
+
import { boolPresent, boolStrict, localName } from '../../xml/xml-scan.js';
|
|
8
9
|
import { CellAccumulator } from './cell-accumulator.js';
|
|
9
|
-
import {
|
|
10
|
-
|
|
10
|
+
import { CellStyleResolver } from './cell-style-resolution.js';
|
|
11
|
+
import { ColumnRecordBudget, takeColumnSpan } from './column-budget.js';
|
|
12
|
+
import { admitting } from './read-repair.js';
|
|
13
|
+
import { RowPositionTracker } from './row-position.js';
|
|
14
|
+
import { applySheetProperties, PageBreakAccumulator, parseSheetProtection, } from './sheet-properties.js';
|
|
15
|
+
const HEADER_FOOTER_CHILDREN = new Set(HEADER_FOOTER_ELEMENTS);
|
|
16
|
+
function isHeaderFooterElement(local) {
|
|
17
|
+
return HEADER_FOOTER_CHILDREN.has(local);
|
|
18
|
+
}
|
|
11
19
|
const WORKSHEET_EMPTY_CLOSES = new Set(['c', 'autoFilter']);
|
|
12
20
|
function pendingFilterCriteria(values, blank, predicates, and) {
|
|
13
21
|
if (values !== null && (values.length > 0 || blank)) {
|
|
@@ -18,31 +26,6 @@ function pendingFilterCriteria(values, blank, predicates, and) {
|
|
|
18
26
|
}
|
|
19
27
|
return null;
|
|
20
28
|
}
|
|
21
|
-
function parseSheetProtection(attrs) {
|
|
22
|
-
if (attrs.sheet === '0' || attrs.sheet === 'false')
|
|
23
|
-
return undefined;
|
|
24
|
-
const flags = {};
|
|
25
|
-
for (const { key } of SHEET_PROTECTION_FLAGS) {
|
|
26
|
-
const raw = attrs[key];
|
|
27
|
-
if (raw !== undefined)
|
|
28
|
-
flags[key] = !boolStrict(raw);
|
|
29
|
-
}
|
|
30
|
-
const { algorithmName, hashValue, saltValue, spinCount } = attrs;
|
|
31
|
-
const spin = numInteger(spinCount, 0);
|
|
32
|
-
if (algorithmName !== undefined &&
|
|
33
|
-
hashValue !== undefined &&
|
|
34
|
-
saltValue !== undefined &&
|
|
35
|
-
spin !== undefined) {
|
|
36
|
-
const credential = {
|
|
37
|
-
algorithmName,
|
|
38
|
-
hashValue,
|
|
39
|
-
saltValue,
|
|
40
|
-
spinCount: spin,
|
|
41
|
-
};
|
|
42
|
-
return { flags, credential };
|
|
43
|
-
}
|
|
44
|
-
return { flags };
|
|
45
|
-
}
|
|
46
29
|
class AutoFilterAccumulator {
|
|
47
30
|
#ref = null;
|
|
48
31
|
#columns = [];
|
|
@@ -102,76 +85,48 @@ class AutoFilterAccumulator {
|
|
|
102
85
|
this.#columns = [];
|
|
103
86
|
}
|
|
104
87
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
begin(target) {
|
|
108
|
-
this.#target = target;
|
|
109
|
-
}
|
|
110
|
-
end() {
|
|
111
|
-
this.#target = null;
|
|
112
|
-
}
|
|
113
|
-
add(attrs) {
|
|
114
|
-
if (this.#target === null)
|
|
115
|
-
return;
|
|
116
|
-
const id = numInteger(attrs.id, 1);
|
|
117
|
-
if (id === undefined)
|
|
118
|
-
return;
|
|
119
|
-
const brk = { id };
|
|
120
|
-
const max = numInteger(attrs.max, 0);
|
|
121
|
-
if (max !== undefined)
|
|
122
|
-
brk.max = max;
|
|
123
|
-
if (boolStrict(attrs.man))
|
|
124
|
-
brk.man = true;
|
|
125
|
-
this.#target.push(brk);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
export function parseWorksheet(xml, sheet, sharedStrings, xfStyles) {
|
|
129
|
-
const cell = new CellAccumulator({ richRuns: true });
|
|
130
|
-
let rowStyle = -1;
|
|
131
|
-
let rowCustomFormat = false;
|
|
88
|
+
export function worksheetPass(sheet, sharedStrings, xfStyles, dateEpoch) {
|
|
89
|
+
const cell = new CellAccumulator({ richRuns: true, dateEpoch });
|
|
132
90
|
const autoFilter = new AutoFilterAccumulator();
|
|
133
91
|
const pageBreaks = new PageBreakAccumulator();
|
|
134
|
-
const
|
|
92
|
+
const styleResolution = new CellStyleResolver();
|
|
93
|
+
const columnBudget = new ColumnRecordBudget();
|
|
94
|
+
const rowPosition = new RowPositionTracker();
|
|
135
95
|
const finalizeCellFromState = () => {
|
|
136
|
-
const styleIndex = cell.styleIndex
|
|
137
|
-
? cell.styleIndex
|
|
138
|
-
: rowCustomFormat && rowStyle >= 0
|
|
139
|
-
? rowStyle
|
|
140
|
-
: (columnStyle.get(cell.col) ?? -1);
|
|
96
|
+
const styleIndex = styleResolution.indexFor(cell.col, cell.styleIndex);
|
|
141
97
|
const style = styleIndex >= 0 ? xfStyles[styleIndex] : xfStyles[0];
|
|
142
98
|
cell.finalize(sheet, sharedStrings, style);
|
|
143
99
|
};
|
|
144
|
-
|
|
100
|
+
const handlers = {
|
|
145
101
|
onOpen(name, attrs, selfClosing) {
|
|
146
102
|
const local = localName(name);
|
|
147
103
|
if (cell.openElement(local, attrs, selfClosing))
|
|
148
104
|
return;
|
|
105
|
+
if (HEADER_FOOTER_CHILDREN.has(local)) {
|
|
106
|
+
cell.capture();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
149
109
|
switch (local) {
|
|
150
110
|
case 'col':
|
|
151
|
-
applyColumn(sheet, attrs, xfStyles,
|
|
152
|
-
break;
|
|
153
|
-
case 'row':
|
|
154
|
-
applyRow(sheet, attrs);
|
|
155
|
-
rowStyle = numInteger(attrs.s, 0) ?? -1;
|
|
156
|
-
rowCustomFormat = boolStrict(attrs.customFormat);
|
|
111
|
+
applyColumn(sheet, attrs, xfStyles, styleResolution, columnBudget);
|
|
157
112
|
break;
|
|
158
|
-
case '
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
cell.capture();
|
|
113
|
+
case 'row': {
|
|
114
|
+
const { number, inGrid } = rowPosition.open(attrs);
|
|
115
|
+
if (inGrid)
|
|
116
|
+
applyRow(sheet, number, attrs);
|
|
117
|
+
cell.openRow(inGrid ? number : -1);
|
|
118
|
+
styleResolution.openRow(attrs);
|
|
165
119
|
break;
|
|
120
|
+
}
|
|
166
121
|
case 'mergeCell':
|
|
167
122
|
if (attrs.ref !== undefined && attrs.ref !== '') {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
123
|
+
const ref = attrs.ref;
|
|
124
|
+
admitting(() => {
|
|
125
|
+
sheet.mergeCells(ref);
|
|
126
|
+
});
|
|
173
127
|
}
|
|
174
128
|
break;
|
|
129
|
+
case 'sheetPr':
|
|
175
130
|
case 'tabColor':
|
|
176
131
|
case 'outlinePr':
|
|
177
132
|
case 'sheetView':
|
|
@@ -229,18 +184,13 @@ export function parseWorksheet(xml, sheet, sharedStrings, xfStyles) {
|
|
|
229
184
|
}
|
|
230
185
|
if (claimed === 'claimed')
|
|
231
186
|
return;
|
|
187
|
+
if (isHeaderFooterElement(local)) {
|
|
188
|
+
sheet.headerFooter[local] = decodeSpreadsheetText(cell.capturedText);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
232
191
|
switch (local) {
|
|
233
|
-
case 'oddHeader':
|
|
234
|
-
case 'oddFooter':
|
|
235
|
-
case 'evenHeader':
|
|
236
|
-
case 'evenFooter':
|
|
237
|
-
case 'firstHeader':
|
|
238
|
-
case 'firstFooter':
|
|
239
|
-
sheet.headerFooter[local] = decodeSpreadsheetText(cell.capturedText);
|
|
240
|
-
break;
|
|
241
192
|
case 'row':
|
|
242
|
-
|
|
243
|
-
rowCustomFormat = false;
|
|
193
|
+
styleResolution.closeRow();
|
|
244
194
|
break;
|
|
245
195
|
case 'filterColumn':
|
|
246
196
|
autoFilter.endColumn();
|
|
@@ -256,58 +206,14 @@ export function parseWorksheet(xml, sheet, sharedStrings, xfStyles) {
|
|
|
256
206
|
break;
|
|
257
207
|
}
|
|
258
208
|
},
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
function applySheetProperties(local, attrs, sheet) {
|
|
262
|
-
switch (local) {
|
|
263
|
-
case 'tabColor':
|
|
264
|
-
sheet.tabColor = parseColor(attrs);
|
|
265
|
-
break;
|
|
266
|
-
case 'outlinePr':
|
|
267
|
-
if (attrs.summaryBelow !== undefined)
|
|
268
|
-
sheet.outline.summaryBelow = boolPresent(attrs.summaryBelow);
|
|
269
|
-
if (attrs.summaryRight !== undefined)
|
|
270
|
-
sheet.outline.summaryRight = boolPresent(attrs.summaryRight);
|
|
271
|
-
break;
|
|
272
|
-
case 'sheetView':
|
|
273
|
-
if (attrs.showGridLines !== undefined && !boolPresent(attrs.showGridLines)) {
|
|
274
|
-
sheet.view.showGridLines = false;
|
|
275
|
-
}
|
|
276
|
-
break;
|
|
277
|
-
case 'pane':
|
|
278
|
-
if (attrs.state === 'frozen' || attrs.state === 'frozenSplit') {
|
|
279
|
-
sheet.view.state = 'frozen';
|
|
280
|
-
const xSplit = numInteger(attrs.xSplit, 0);
|
|
281
|
-
const ySplit = numInteger(attrs.ySplit, 0);
|
|
282
|
-
if (xSplit !== undefined)
|
|
283
|
-
sheet.view.xSplit = xSplit;
|
|
284
|
-
if (ySplit !== undefined)
|
|
285
|
-
sheet.view.ySplit = ySplit;
|
|
286
|
-
if (attrs.topLeftCell !== undefined)
|
|
287
|
-
sheet.view.topLeftCell = attrs.topLeftCell;
|
|
288
|
-
}
|
|
289
|
-
break;
|
|
290
|
-
case 'pageSetUpPr':
|
|
291
|
-
if (attrs.fitToPage !== undefined)
|
|
292
|
-
sheet.pageSetup.fitToPage = boolPresent(attrs.fitToPage);
|
|
293
|
-
break;
|
|
294
|
-
case 'printOptions':
|
|
295
|
-
applyPrintOptions(sheet.printOptions, attrs);
|
|
296
|
-
break;
|
|
297
|
-
case 'pageMargins':
|
|
298
|
-
applyMargins(sheet.pageMargins, attrs);
|
|
299
|
-
break;
|
|
300
|
-
case 'pageSetup':
|
|
301
|
-
applyPageSetup(sheet.pageSetup, attrs);
|
|
302
|
-
break;
|
|
303
|
-
}
|
|
209
|
+
};
|
|
210
|
+
return { handlers, closeEmptyElements: WORKSHEET_EMPTY_CLOSES };
|
|
304
211
|
}
|
|
305
|
-
function applyColumn(sheet, attrs, xfStyles,
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
if (min === undefined || max === undefined || min > MAX_COLUMN)
|
|
212
|
+
function applyColumn(sheet, attrs, xfStyles, styleResolution, budget) {
|
|
213
|
+
const span = takeColumnSpan(attrs, budget);
|
|
214
|
+
if (span === undefined)
|
|
309
215
|
return;
|
|
310
|
-
const
|
|
216
|
+
const { first: min, last } = span;
|
|
311
217
|
const width = numFinite(attrs.width);
|
|
312
218
|
const hidden = boolStrict(attrs.hidden);
|
|
313
219
|
const styleIndex = numInteger(attrs.style, 0) ?? -1;
|
|
@@ -325,14 +231,10 @@ function applyColumn(sheet, attrs, xfStyles, columnStyle) {
|
|
|
325
231
|
column.collapsed = true;
|
|
326
232
|
if (style !== undefined)
|
|
327
233
|
assignStyleFacets(column, style);
|
|
328
|
-
if (styleIndex >= 0)
|
|
329
|
-
columnStyle.set(index, styleIndex);
|
|
330
234
|
}
|
|
235
|
+
styleResolution.noteColumnSpan(min, last, attrs);
|
|
331
236
|
}
|
|
332
|
-
function applyRow(sheet, attrs) {
|
|
333
|
-
const number = numInteger(attrs.r, 1);
|
|
334
|
-
if (number === undefined || number > MAX_ROW)
|
|
335
|
-
return;
|
|
237
|
+
function applyRow(sheet, number, attrs) {
|
|
336
238
|
const row = sheet.getRow(number);
|
|
337
239
|
const height = numFinite(attrs.ht);
|
|
338
240
|
if (height !== undefined && boolPresent(attrs.customHeight))
|
|
@@ -345,47 +247,3 @@ function applyRow(sheet, attrs) {
|
|
|
345
247
|
if (boolStrict(attrs.collapsed))
|
|
346
248
|
row.collapsed = true;
|
|
347
249
|
}
|
|
348
|
-
function applyPrintOptions(printOptions, attrs) {
|
|
349
|
-
const horizontalCentered = boolTristate(attrs.horizontalCentered);
|
|
350
|
-
if (horizontalCentered !== undefined)
|
|
351
|
-
printOptions.horizontalCentered = horizontalCentered;
|
|
352
|
-
const verticalCentered = boolTristate(attrs.verticalCentered);
|
|
353
|
-
if (verticalCentered !== undefined)
|
|
354
|
-
printOptions.verticalCentered = verticalCentered;
|
|
355
|
-
const headings = boolTristate(attrs.headings);
|
|
356
|
-
if (headings !== undefined)
|
|
357
|
-
printOptions.headings = headings;
|
|
358
|
-
const gridLines = boolTristate(attrs.gridLines);
|
|
359
|
-
if (gridLines !== undefined)
|
|
360
|
-
printOptions.gridLines = gridLines;
|
|
361
|
-
const gridLinesSet = boolTristate(attrs.gridLinesSet);
|
|
362
|
-
if (gridLinesSet !== undefined)
|
|
363
|
-
printOptions.gridLinesSet = gridLinesSet;
|
|
364
|
-
}
|
|
365
|
-
function applyMargins(margins, attrs) {
|
|
366
|
-
for (const side of MARGIN_SIDES) {
|
|
367
|
-
const value = numFinite(attrs[side]);
|
|
368
|
-
if (value !== undefined)
|
|
369
|
-
margins[side] = value;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
function applyPageSetup(pageSetup, attrs) {
|
|
373
|
-
const paperSize = numInteger(attrs.paperSize, 0);
|
|
374
|
-
if (paperSize !== undefined)
|
|
375
|
-
pageSetup.paperSize = paperSize;
|
|
376
|
-
const scale = numInteger(attrs.scale, 0);
|
|
377
|
-
if (scale !== undefined)
|
|
378
|
-
pageSetup.scale = scale;
|
|
379
|
-
const fitToWidth = numInteger(attrs.fitToWidth, 0);
|
|
380
|
-
if (fitToWidth !== undefined)
|
|
381
|
-
pageSetup.fitToWidth = fitToWidth;
|
|
382
|
-
const fitToHeight = numInteger(attrs.fitToHeight, 0);
|
|
383
|
-
if (fitToHeight !== undefined)
|
|
384
|
-
pageSetup.fitToHeight = fitToHeight;
|
|
385
|
-
const pageOrder = enumToken(attrs.pageOrder, isPageOrder);
|
|
386
|
-
if (pageOrder !== undefined)
|
|
387
|
-
pageSetup.pageOrder = pageOrder;
|
|
388
|
-
const orientation = enumToken(attrs.orientation, isPageOrientation);
|
|
389
|
-
if (orientation !== undefined)
|
|
390
|
-
pageSetup.orientation = orientation;
|
|
391
|
-
}
|
package/dist/io/xlsx/read.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Workbook
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export { parseRelationships, resolveWorkbookPart } from '../opc/read-opc.ts';
|
|
5
|
-
export { DEFAULT_MAX_UNCOMPRESSED, type ReadXlsxOptions } from '../opc/read-options.ts';
|
|
1
|
+
import { Workbook } from '../../core/workbook.ts';
|
|
2
|
+
import type { ReadPackageOptions } from '../opc/read-options.ts';
|
|
3
|
+
export type { ReadPackageOptions } from '../opc/read-options.ts';
|
|
6
4
|
export type { StyleTable, XfStyle } from '../style/xf-style.ts';
|
|
7
5
|
export { parseStyleTable } from './read-styles.ts';
|
|
6
|
+
export { type SheetEntry, workbookPropertiesPass, workbookSheetsPass, workbookViewPass, } from './read-workbook-xml.ts';
|
|
8
7
|
/**
|
|
9
8
|
* Read a spreadsheet package into a {@link Workbook}.
|
|
10
9
|
*
|
|
@@ -20,11 +19,4 @@ export { parseStyleTable } from './read-styles.ts';
|
|
|
20
19
|
* @throws {PackageReadError} if the input is a ZIP that cannot be unpacked: a corrupt or
|
|
21
20
|
* truncated archive, or one exceeding the inflate bound (a probable zip bomb).
|
|
22
21
|
*/
|
|
23
|
-
export declare function readXlsx(data: Uint8Array, options?:
|
|
24
|
-
export interface SheetEntry {
|
|
25
|
-
readonly name: string;
|
|
26
|
-
readonly relId: string;
|
|
27
|
-
readonly state?: WorksheetState['state'];
|
|
28
|
-
}
|
|
29
|
-
export declare function parseWorkbookSheets(xml: string): SheetEntry[];
|
|
30
|
-
export declare function applyWorkbookView(view: WorkbookView, xml: string): void;
|
|
22
|
+
export declare function readXlsx(data: Uint8Array, options?: ReadPackageOptions): Workbook;
|