@shbernal/ts-xlsx 1.3.1 → 2.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 +20 -10
- package/dist/bytes.d.ts +24 -0
- package/dist/bytes.js +34 -0
- package/dist/core/address.d.ts +72 -3
- package/dist/core/address.js +50 -10
- package/dist/core/autofilter.d.ts +13 -2
- package/dist/core/autofilter.js +35 -10
- package/dist/core/cell.d.ts +17 -16
- package/dist/core/cell.js +3 -7
- package/dist/core/color-resolution.d.ts +8 -8
- package/dist/core/color-resolution.js +7 -8
- package/dist/core/column.d.ts +8 -9
- package/dist/core/column.js +2 -4
- package/dist/core/comment-thread.d.ts +32 -23
- package/dist/core/comment-thread.js +4 -4
- package/dist/core/conditional-formatting-overlay.d.ts +6 -1
- package/dist/core/conditional-formatting-overlay.js +11 -0
- package/dist/core/conditional-formatting.d.ts +48 -8
- package/dist/core/conditional-formatting.js +88 -0
- package/dist/core/data-validation-overlay.d.ts +12 -1
- package/dist/core/data-validation-overlay.js +21 -2
- package/dist/core/data-validation.d.ts +12 -5
- package/dist/core/data-validation.js +34 -0
- package/dist/core/date.d.ts +3 -3
- package/dist/core/formula.d.ts +6 -6
- package/dist/core/grid-edits.d.ts +16 -0
- package/dist/core/grid-edits.js +29 -11
- package/dist/core/grid-shift.d.ts +19 -0
- package/dist/core/grid-shift.js +8 -0
- package/dist/core/image.d.ts +39 -2
- package/dist/core/image.js +10 -0
- package/dist/core/internal.d.ts +9 -1
- package/dist/core/limits.d.ts +4 -4
- package/dist/core/merge.d.ts +17 -12
- package/dist/core/merge.js +36 -5
- package/dist/core/page-setup.d.ts +20 -6
- package/dist/core/page-setup.js +8 -1
- package/dist/core/pivot-table.d.ts +4 -4
- package/dist/core/pivot-table.js +29 -20
- package/dist/core/preserved.d.ts +3 -3
- package/dist/core/protection.d.ts +7 -4
- package/dist/core/protection.js +20 -14
- package/dist/core/range.d.ts +16 -14
- package/dist/core/range.js +5 -5
- package/dist/core/row-input.d.ts +9 -8
- package/dist/core/row-input.js +12 -10
- package/dist/core/row.d.ts +7 -8
- package/dist/core/row.js +2 -4
- package/dist/core/style.d.ts +41 -14
- package/dist/core/style.js +82 -67
- package/dist/core/table-style.d.ts +9 -9
- package/dist/core/table-style.js +1 -1
- package/dist/core/table.d.ts +53 -51
- package/dist/core/table.js +83 -41
- package/dist/core/theme.d.ts +16 -44
- package/dist/core/theme.js +6 -148
- package/dist/core/value.d.ts +7 -7
- package/dist/core/workbook-protection.d.ts +2 -2
- package/dist/core/workbook-styles.d.ts +26 -0
- package/dist/core/workbook-styles.js +48 -0
- package/dist/core/workbook-theme.d.ts +25 -0
- package/dist/core/workbook-theme.js +49 -0
- package/dist/core/workbook-vba.d.ts +17 -0
- package/dist/core/workbook-vba.js +79 -0
- package/dist/core/workbook.d.ts +133 -87
- package/dist/core/workbook.js +74 -133
- package/dist/core/worksheet-comments.d.ts +17 -0
- package/dist/core/worksheet-comments.js +70 -0
- package/dist/core/worksheet-model.d.ts +4 -4
- package/dist/core/worksheet-model.js +1 -0
- package/dist/core/worksheet-pictures.d.ts +29 -0
- package/dist/core/worksheet-pictures.js +42 -0
- package/dist/core/worksheet.d.ts +100 -79
- package/dist/core/worksheet.js +63 -142
- package/dist/customui/errors.d.ts +1 -1
- package/dist/customui/ribbon.d.ts +3 -3
- package/dist/customui/ribbon.js +24 -23
- package/dist/entries/core.d.ts +7 -7
- package/dist/entries/core.js +1 -1
- package/dist/entries/csv.d.ts +1 -1
- package/dist/entries/node-unavailable.d.ts +15 -0
- package/dist/entries/node-unavailable.js +20 -0
- package/dist/entries/node.d.ts +1 -0
- package/dist/entries/node.js +1 -0
- package/dist/entries/vba.d.ts +1 -1
- package/dist/entries/vba.js +1 -1
- package/dist/entries/xlsx.d.ts +1 -1
- package/dist/entries/xlsx.js +1 -1
- package/dist/errors.d.ts +12 -12
- package/dist/io/csv/read.js +2 -3
- package/dist/io/csv/write.d.ts +19 -4
- package/dist/io/csv/write.js +34 -4
- package/dist/io/opc/errors.d.ts +6 -6
- package/dist/io/opc/inflate.d.ts +1 -1
- package/dist/io/opc/inflate.js +2 -12
- package/dist/io/opc/namespaces.d.ts +1 -1
- package/dist/io/opc/read-opc.d.ts +19 -3
- package/dist/io/opc/read-opc.js +14 -8
- package/dist/io/opc/read-options.d.ts +2 -2
- package/dist/io/opc/rels.d.ts +11 -0
- package/dist/io/opc/rels.js +3 -2
- package/dist/io/opc/sniff-format.d.ts +2 -2
- package/dist/io/style/xf-style.d.ts +44 -7
- package/dist/io/style/xf-style.js +27 -0
- package/dist/io/xlsb/errors.d.ts +1 -1
- package/dist/io/xlsb/formula.d.ts +4 -4
- package/dist/io/xlsb/primitives.d.ts +8 -8
- package/dist/io/xlsb/ptg-functions.d.ts +1 -1
- package/dist/io/xlsb/read-styles.js +2 -20
- package/dist/io/xlsb/read.d.ts +2 -2
- package/dist/io/xlsx/cell-accumulator.d.ts +26 -9
- package/dist/io/xlsx/cell-accumulator.js +89 -46
- package/dist/io/xlsx/cell-value.d.ts +3 -3
- package/dist/io/xlsx/cell-value.js +9 -6
- package/dist/io/xlsx/color-xml.d.ts +1 -1
- package/dist/io/xlsx/color-xml.js +18 -23
- package/dist/io/xlsx/comments.d.ts +5 -5
- package/dist/io/xlsx/comments.js +17 -8
- package/dist/io/xlsx/conditional-formatting.d.ts +4 -4
- package/dist/io/xlsx/conditional-formatting.js +64 -58
- package/dist/io/xlsx/data-validation.d.ts +3 -3
- package/dist/io/xlsx/data-validation.js +35 -33
- package/dist/io/xlsx/errors.d.ts +3 -3
- package/dist/io/xlsx/hyperlinks.d.ts +4 -2
- package/dist/io/xlsx/hyperlinks.js +10 -18
- package/dist/io/xlsx/images.d.ts +1 -1
- package/dist/io/xlsx/images.js +25 -28
- package/dist/io/xlsx/namespaces.d.ts +2 -2
- package/dist/io/xlsx/package-plan.js +5 -2
- package/dist/io/xlsx/read-pivot.js +4 -13
- package/dist/io/xlsx/read-rows.d.ts +13 -13
- package/dist/io/xlsx/read-rows.js +19 -55
- package/dist/io/xlsx/read-shared-strings.js +7 -44
- package/dist/io/xlsx/read-styles.d.ts +3 -3
- package/dist/io/xlsx/read-styles.js +42 -66
- package/dist/io/xlsx/read-worksheet.js +73 -129
- package/dist/io/xlsx/read.d.ts +4 -6
- package/dist/io/xlsx/read.js +104 -142
- package/dist/io/xlsx/rich-runs.d.ts +41 -7
- package/dist/io/xlsx/rich-runs.js +94 -30
- package/dist/io/xlsx/rich-text.d.ts +1 -1
- package/dist/io/xlsx/shared-strings.d.ts +2 -2
- package/dist/io/xlsx/sheet-properties.d.ts +1 -1
- package/dist/io/xlsx/sheet-properties.js +14 -10
- package/dist/io/xlsx/styles.d.ts +9 -22
- package/dist/io/xlsx/styles.js +65 -89
- package/dist/io/xlsx/tables.d.ts +2 -2
- package/dist/io/xlsx/tables.js +20 -25
- package/dist/io/xlsx/theme-xml.d.ts +37 -0
- package/dist/io/xlsx/theme-xml.js +145 -0
- package/dist/io/xlsx/threaded-comments.d.ts +18 -27
- package/dist/io/xlsx/threaded-comments.js +26 -38
- package/dist/io/xlsx/workbook-xml.js +14 -8
- package/dist/io/xlsx/worksheet-xml.d.ts +2 -2
- package/dist/io/xlsx/worksheet-xml.js +40 -48
- package/dist/io/xlsx/write-stream.d.ts +23 -16
- package/dist/io/xlsx/write-stream.js +13 -14
- package/dist/io/xlsx/write.d.ts +8 -7
- package/dist/io/xlsx/write.js +6 -3
- package/dist/io/xlsx/x14-ext.d.ts +1 -1
- package/dist/sha512.d.ts +2 -0
- package/dist/sha512.js +146 -0
- package/dist/vba/bytes.d.ts +11 -0
- package/dist/vba/bytes.js +29 -0
- package/dist/vba/cfb-writer.d.ts +1 -1
- package/dist/vba/cfb.d.ts +1 -1
- package/dist/vba/cfb.js +15 -51
- package/dist/vba/codepage.d.ts +2 -2
- package/dist/vba/dir-records.d.ts +53 -0
- package/dist/vba/dir-records.js +28 -0
- package/dist/vba/errors.d.ts +2 -2
- package/dist/vba/index.d.ts +2 -2
- package/dist/vba/index.js +2 -2
- package/dist/vba/ms-ovba.d.ts +1 -1
- package/dist/vba/ms-ovba.js +1 -3
- package/dist/vba/project-editor.d.ts +9 -9
- package/dist/vba/project-editor.js +6 -44
- package/dist/vba/project.d.ts +5 -5
- package/dist/vba/project.js +3 -28
- package/dist/vba/vba-encoding.d.ts +1 -1
- package/dist/xml/errors.d.ts +1 -1
- package/dist/xml/xml-read.d.ts +98 -9
- package/dist/xml/xml-read.js +70 -0
- package/dist/xml/xml.d.ts +74 -10
- package/dist/xml/xml.js +39 -7
- package/package.json +59 -36
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MAX_COLUMN, MAX_ROW, tryDecodeRange } from '../../core/address.js';
|
|
2
2
|
import { isCustomFilterOperator, } from '../../core/autofilter.js';
|
|
3
3
|
import { INTERNAL } from '../../core/internal.js';
|
|
4
|
+
import { isPageOrder, isPageOrientation, } from '../../core/page-setup.js';
|
|
4
5
|
import { SHEET_PROTECTION_FLAGS, } from '../../core/protection.js';
|
|
5
6
|
import { assignStyleFacets } from '../../core/style.js';
|
|
6
|
-
import { boolPresent, boolStrict, boolTristate, localName, parseXml, } from '../../xml/xml-read.js';
|
|
7
|
+
import { boolPresent, boolStrict, boolTristate, decodeSpreadsheetText, enumToken, localName, numFinite, numInteger, parseXml, } from '../../xml/xml-read.js';
|
|
7
8
|
import { CellAccumulator } from './cell-accumulator.js';
|
|
8
9
|
import { parseColor } from './color-xml.js';
|
|
9
10
|
const MARGIN_SIDES = ['left', 'right', 'top', 'bottom', 'header', 'footer'];
|
|
@@ -27,20 +28,18 @@ function parseSheetProtection(attrs) {
|
|
|
27
28
|
flags[key] = !boolStrict(raw);
|
|
28
29
|
}
|
|
29
30
|
const { algorithmName, hashValue, saltValue, spinCount } = attrs;
|
|
31
|
+
const spin = numInteger(spinCount, 0);
|
|
30
32
|
if (algorithmName !== undefined &&
|
|
31
33
|
hashValue !== undefined &&
|
|
32
34
|
saltValue !== undefined &&
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
return { flags, credential };
|
|
43
|
-
}
|
|
35
|
+
spin !== undefined) {
|
|
36
|
+
const credential = {
|
|
37
|
+
algorithmName,
|
|
38
|
+
hashValue,
|
|
39
|
+
saltValue,
|
|
40
|
+
spinCount: spin,
|
|
41
|
+
};
|
|
42
|
+
return { flags, credential };
|
|
44
43
|
}
|
|
45
44
|
return { flags };
|
|
46
45
|
}
|
|
@@ -57,7 +56,7 @@ class AutoFilterAccumulator {
|
|
|
57
56
|
this.#columns = [];
|
|
58
57
|
}
|
|
59
58
|
beginColumn(attrs) {
|
|
60
|
-
this.#colId = attrs.colId
|
|
59
|
+
this.#colId = numInteger(attrs.colId, 0) ?? -1;
|
|
61
60
|
this.#values = null;
|
|
62
61
|
this.#blank = false;
|
|
63
62
|
this.#predicates = null;
|
|
@@ -92,13 +91,13 @@ class AutoFilterAccumulator {
|
|
|
92
91
|
commit(sheet) {
|
|
93
92
|
if (this.#ref === null)
|
|
94
93
|
return;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
const decoded = tryDecodeRange(this.#ref);
|
|
95
|
+
const left = decoded?.left;
|
|
96
|
+
const right = decoded?.right;
|
|
97
|
+
if (left !== undefined && right !== undefined) {
|
|
98
|
+
const width = right - left + 1;
|
|
98
99
|
sheet.autoFilter = { ref: this.#ref, columns: this.#columns.filter((c) => c.colId < width) };
|
|
99
100
|
}
|
|
100
|
-
catch {
|
|
101
|
-
}
|
|
102
101
|
this.#ref = null;
|
|
103
102
|
this.#columns = [];
|
|
104
103
|
}
|
|
@@ -114,12 +113,12 @@ class PageBreakAccumulator {
|
|
|
114
113
|
add(attrs) {
|
|
115
114
|
if (this.#target === null)
|
|
116
115
|
return;
|
|
117
|
-
const id =
|
|
118
|
-
if (
|
|
116
|
+
const id = numInteger(attrs.id, 1);
|
|
117
|
+
if (id === undefined)
|
|
119
118
|
return;
|
|
120
119
|
const brk = { id };
|
|
121
|
-
const max =
|
|
122
|
-
if (
|
|
120
|
+
const max = numInteger(attrs.max, 0);
|
|
121
|
+
if (max !== undefined)
|
|
123
122
|
brk.max = max;
|
|
124
123
|
if (boolStrict(attrs.man))
|
|
125
124
|
brk.man = true;
|
|
@@ -127,10 +126,7 @@ class PageBreakAccumulator {
|
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
128
|
export function parseWorksheet(xml, sheet, sharedStrings, xfStyles) {
|
|
130
|
-
const cell = new CellAccumulator();
|
|
131
|
-
let inInlineString = false;
|
|
132
|
-
let capture = false;
|
|
133
|
-
let text = '';
|
|
129
|
+
const cell = new CellAccumulator({ richRuns: true });
|
|
134
130
|
let rowStyle = -1;
|
|
135
131
|
let rowCustomFormat = false;
|
|
136
132
|
const autoFilter = new AutoFilterAccumulator();
|
|
@@ -148,46 +144,24 @@ export function parseWorksheet(xml, sheet, sharedStrings, xfStyles) {
|
|
|
148
144
|
parseXml(xml, {
|
|
149
145
|
onOpen(name, attrs, selfClosing) {
|
|
150
146
|
const local = localName(name);
|
|
151
|
-
|
|
152
|
-
|
|
147
|
+
if (cell.openElement(local, attrs, selfClosing))
|
|
148
|
+
return;
|
|
153
149
|
switch (local) {
|
|
154
150
|
case 'col':
|
|
155
151
|
applyColumn(sheet, attrs, xfStyles, columnStyle);
|
|
156
152
|
break;
|
|
157
153
|
case 'row':
|
|
158
154
|
applyRow(sheet, attrs);
|
|
159
|
-
rowStyle = attrs.s
|
|
155
|
+
rowStyle = numInteger(attrs.s, 0) ?? -1;
|
|
160
156
|
rowCustomFormat = boolStrict(attrs.customFormat);
|
|
161
157
|
break;
|
|
162
|
-
case 'c':
|
|
163
|
-
cell.beginCell(attrs);
|
|
164
|
-
break;
|
|
165
|
-
case 'is':
|
|
166
|
-
inInlineString = true;
|
|
167
|
-
cell.beginInlineString();
|
|
168
|
-
break;
|
|
169
|
-
case 'r':
|
|
170
|
-
if (inInlineString)
|
|
171
|
-
cell.runs.beginRun();
|
|
172
|
-
break;
|
|
173
|
-
case 'rPr':
|
|
174
|
-
cell.runs.beginProperties();
|
|
175
|
-
break;
|
|
176
|
-
case 'f':
|
|
177
|
-
capture = true;
|
|
178
|
-
cell.beginFormula(attrs, selfClosing);
|
|
179
|
-
break;
|
|
180
|
-
case 'v':
|
|
181
|
-
case 't':
|
|
182
|
-
capture = true;
|
|
183
|
-
break;
|
|
184
158
|
case 'oddHeader':
|
|
185
159
|
case 'oddFooter':
|
|
186
160
|
case 'evenHeader':
|
|
187
161
|
case 'evenFooter':
|
|
188
162
|
case 'firstHeader':
|
|
189
163
|
case 'firstFooter':
|
|
190
|
-
capture
|
|
164
|
+
cell.capture();
|
|
191
165
|
break;
|
|
192
166
|
case 'mergeCell':
|
|
193
167
|
if (attrs.ref !== undefined && attrs.ref !== '') {
|
|
@@ -241,45 +215,28 @@ export function parseWorksheet(xml, sheet, sharedStrings, xfStyles) {
|
|
|
241
215
|
case 'customFilter':
|
|
242
216
|
autoFilter.addCustom(attrs);
|
|
243
217
|
break;
|
|
244
|
-
default:
|
|
245
|
-
cell.runs.applyProperty(local, attrs);
|
|
246
|
-
break;
|
|
247
218
|
}
|
|
248
|
-
if (selfClosing && (local === 'f' || local === 'v'))
|
|
249
|
-
capture = false;
|
|
250
219
|
},
|
|
251
220
|
onText(chunk) {
|
|
252
|
-
|
|
253
|
-
text += chunk;
|
|
221
|
+
cell.appendChunk(chunk);
|
|
254
222
|
},
|
|
255
223
|
onClose(name) {
|
|
256
224
|
const local = localName(name);
|
|
225
|
+
const claimed = cell.closeElement(local);
|
|
226
|
+
if (claimed === 'cell') {
|
|
227
|
+
finalizeCellFromState();
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (claimed === 'claimed')
|
|
231
|
+
return;
|
|
257
232
|
switch (local) {
|
|
258
|
-
case 'f':
|
|
259
|
-
cell.setFormula(text);
|
|
260
|
-
break;
|
|
261
|
-
case 'v':
|
|
262
|
-
cell.setValue(text);
|
|
263
|
-
break;
|
|
264
|
-
case 't':
|
|
265
|
-
cell.appendText(text, inInlineString);
|
|
266
|
-
break;
|
|
267
|
-
case 'r':
|
|
268
|
-
cell.runs.endRun();
|
|
269
|
-
break;
|
|
270
|
-
case 'is':
|
|
271
|
-
inInlineString = false;
|
|
272
|
-
break;
|
|
273
233
|
case 'oddHeader':
|
|
274
234
|
case 'oddFooter':
|
|
275
235
|
case 'evenHeader':
|
|
276
236
|
case 'evenFooter':
|
|
277
237
|
case 'firstHeader':
|
|
278
238
|
case 'firstFooter':
|
|
279
|
-
sheet.headerFooter[local] =
|
|
280
|
-
break;
|
|
281
|
-
case 'c':
|
|
282
|
-
finalizeCellFromState();
|
|
239
|
+
sheet.headerFooter[local] = decodeSpreadsheetText(cell.capturedText);
|
|
283
240
|
break;
|
|
284
241
|
case 'row':
|
|
285
242
|
rowStyle = -1;
|
|
@@ -298,7 +255,6 @@ export function parseWorksheet(xml, sheet, sharedStrings, xfStyles) {
|
|
|
298
255
|
default:
|
|
299
256
|
break;
|
|
300
257
|
}
|
|
301
|
-
capture = false;
|
|
302
258
|
},
|
|
303
259
|
}, { closeEmptyElements: WORKSHEET_EMPTY_CLOSES });
|
|
304
260
|
}
|
|
@@ -321,10 +277,12 @@ function applySheetProperties(local, attrs, sheet) {
|
|
|
321
277
|
case 'pane':
|
|
322
278
|
if (attrs.state === 'frozen' || attrs.state === 'frozenSplit') {
|
|
323
279
|
sheet.view.state = 'frozen';
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
if (
|
|
327
|
-
sheet.view.
|
|
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;
|
|
328
286
|
if (attrs.topLeftCell !== undefined)
|
|
329
287
|
sheet.view.topLeftCell = attrs.topLeftCell;
|
|
330
288
|
}
|
|
@@ -345,25 +303,24 @@ function applySheetProperties(local, attrs, sheet) {
|
|
|
345
303
|
}
|
|
346
304
|
}
|
|
347
305
|
function applyColumn(sheet, attrs, xfStyles, columnStyle) {
|
|
348
|
-
const min =
|
|
349
|
-
const max =
|
|
350
|
-
if (
|
|
306
|
+
const min = numInteger(attrs.min, 1);
|
|
307
|
+
const max = numInteger(attrs.max, 1);
|
|
308
|
+
if (min === undefined || max === undefined || min > MAX_COLUMN)
|
|
351
309
|
return;
|
|
352
|
-
const
|
|
310
|
+
const last = Math.min(max, MAX_COLUMN);
|
|
311
|
+
const width = numFinite(attrs.width);
|
|
353
312
|
const hidden = boolStrict(attrs.hidden);
|
|
354
|
-
const styleIndex = attrs.style
|
|
313
|
+
const styleIndex = numInteger(attrs.style, 0) ?? -1;
|
|
355
314
|
const style = styleIndex >= 0 ? xfStyles[styleIndex] : undefined;
|
|
356
|
-
for (let index = min; index <=
|
|
315
|
+
for (let index = min; index <= last; index++) {
|
|
357
316
|
const column = sheet.getColumn(index);
|
|
358
|
-
if (width !== undefined &&
|
|
317
|
+
if (width !== undefined && boolPresent(attrs.customWidth))
|
|
359
318
|
column.width = width;
|
|
360
319
|
if (hidden)
|
|
361
320
|
column.hidden = true;
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
column.outlineLevel = level;
|
|
366
|
-
}
|
|
321
|
+
const outlineLevel = numInteger(attrs.outlineLevel, 1);
|
|
322
|
+
if (outlineLevel !== undefined)
|
|
323
|
+
column.outlineLevel = outlineLevel;
|
|
367
324
|
if (boolStrict(attrs.collapsed))
|
|
368
325
|
column.collapsed = true;
|
|
369
326
|
if (style !== undefined)
|
|
@@ -373,22 +330,18 @@ function applyColumn(sheet, attrs, xfStyles, columnStyle) {
|
|
|
373
330
|
}
|
|
374
331
|
}
|
|
375
332
|
function applyRow(sheet, attrs) {
|
|
376
|
-
const number =
|
|
377
|
-
if (
|
|
333
|
+
const number = numInteger(attrs.r, 1);
|
|
334
|
+
if (number === undefined || number > MAX_ROW)
|
|
378
335
|
return;
|
|
379
336
|
const row = sheet.getRow(number);
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
row.height = height;
|
|
384
|
-
}
|
|
337
|
+
const height = numFinite(attrs.ht);
|
|
338
|
+
if (height !== undefined && boolPresent(attrs.customHeight))
|
|
339
|
+
row.height = height;
|
|
385
340
|
if (boolStrict(attrs.hidden))
|
|
386
341
|
row.hidden = true;
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
row.outlineLevel = level;
|
|
391
|
-
}
|
|
342
|
+
const outlineLevel = numInteger(attrs.outlineLevel, 1);
|
|
343
|
+
if (outlineLevel !== undefined)
|
|
344
|
+
row.outlineLevel = outlineLevel;
|
|
392
345
|
if (boolStrict(attrs.collapsed))
|
|
393
346
|
row.collapsed = true;
|
|
394
347
|
}
|
|
@@ -411,37 +364,28 @@ function applyPrintOptions(printOptions, attrs) {
|
|
|
411
364
|
}
|
|
412
365
|
function applyMargins(margins, attrs) {
|
|
413
366
|
for (const side of MARGIN_SIDES) {
|
|
414
|
-
const
|
|
415
|
-
if (
|
|
416
|
-
continue;
|
|
417
|
-
const value = Number(raw);
|
|
418
|
-
if (Number.isFinite(value))
|
|
367
|
+
const value = numFinite(attrs[side]);
|
|
368
|
+
if (value !== undefined)
|
|
419
369
|
margins[side] = value;
|
|
420
370
|
}
|
|
421
371
|
}
|
|
422
372
|
function applyPageSetup(pageSetup, attrs) {
|
|
423
|
-
const
|
|
424
|
-
if (raw === undefined)
|
|
425
|
-
return undefined;
|
|
426
|
-
const value = Number(raw);
|
|
427
|
-
return Number.isFinite(value) ? value : undefined;
|
|
428
|
-
};
|
|
429
|
-
const paperSize = num(attrs.paperSize);
|
|
373
|
+
const paperSize = numInteger(attrs.paperSize, 0);
|
|
430
374
|
if (paperSize !== undefined)
|
|
431
375
|
pageSetup.paperSize = paperSize;
|
|
432
|
-
const scale =
|
|
376
|
+
const scale = numInteger(attrs.scale, 0);
|
|
433
377
|
if (scale !== undefined)
|
|
434
378
|
pageSetup.scale = scale;
|
|
435
|
-
const fitToWidth =
|
|
379
|
+
const fitToWidth = numInteger(attrs.fitToWidth, 0);
|
|
436
380
|
if (fitToWidth !== undefined)
|
|
437
381
|
pageSetup.fitToWidth = fitToWidth;
|
|
438
|
-
const fitToHeight =
|
|
382
|
+
const fitToHeight = numInteger(attrs.fitToHeight, 0);
|
|
439
383
|
if (fitToHeight !== undefined)
|
|
440
384
|
pageSetup.fitToHeight = fitToHeight;
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
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;
|
|
447
391
|
}
|
package/dist/io/xlsx/read.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Workbook, type WorkbookView } from '../../core/workbook.ts';
|
|
2
|
-
import { type
|
|
3
|
-
import type { WorksheetState } from '../../core/worksheet.ts';
|
|
2
|
+
import { type WorksheetState } from '../../core/worksheet.ts';
|
|
4
3
|
import { type ReadXlsxOptions } from '../opc/read-options.ts';
|
|
5
4
|
export { parseRelationships, resolveWorkbookPart } from '../opc/read-opc.ts';
|
|
6
5
|
export { DEFAULT_MAX_UNCOMPRESSED, type ReadXlsxOptions } from '../opc/read-options.ts';
|
|
@@ -11,14 +10,14 @@ export { parseStyleTable } from './read-styles.ts';
|
|
|
11
10
|
*
|
|
12
11
|
* Both OOXML serialisations are accepted: an XML `.xlsx`, and a binary `.xlsb` (BIFF12), which is the
|
|
13
12
|
* same OPC container with binary office-document parts. The two are auto-detected from the package
|
|
14
|
-
* itself rather than from a file extension, so a caller never branches on which form it holds
|
|
13
|
+
* itself rather than from a file extension, so a caller never branches on which form it holds, and
|
|
15
14
|
* the model produced is the same either way. See `../xlsb/read.ts` for what the binary path does not
|
|
16
15
|
* yet decode.
|
|
17
16
|
*
|
|
18
|
-
* @throws {UnsupportedFormatError} if the input is neither
|
|
17
|
+
* @throws {UnsupportedFormatError} if the input is neither: a legacy `.xls` (`.format === 'xls'`) or
|
|
19
18
|
* an unrecognised/non-ZIP blob (`'unknown'`).
|
|
20
19
|
* @throws {XlsbParseError} if a binary `.xlsb` part is malformed.
|
|
21
|
-
* @throws {PackageReadError} if the input is a ZIP that cannot be unpacked
|
|
20
|
+
* @throws {PackageReadError} if the input is a ZIP that cannot be unpacked: a corrupt or
|
|
22
21
|
* truncated archive, or one exceeding the inflate bound (a probable zip bomb).
|
|
23
22
|
*/
|
|
24
23
|
export declare function readXlsx(data: Uint8Array, options?: ReadXlsxOptions): Workbook;
|
|
@@ -28,5 +27,4 @@ export interface SheetEntry {
|
|
|
28
27
|
readonly state?: WorksheetState['state'];
|
|
29
28
|
}
|
|
30
29
|
export declare function parseWorkbookSheets(xml: string): SheetEntry[];
|
|
31
|
-
export declare function parseWorkbookProtection(xml: string): WorkbookProtection | undefined;
|
|
32
30
|
export declare function applyWorkbookView(view: WorkbookView, xml: string): void;
|