@shbernal/ts-xlsx 3.1.0 → 3.2.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 +30 -23
- package/dist/bytes.d.ts +3 -2
- package/dist/core/address.d.ts +36 -0
- package/dist/core/address.js +47 -9
- package/dist/core/array-formula-ranges.d.ts +33 -0
- package/dist/core/array-formula-ranges.js +62 -0
- package/dist/core/color-resolution.js +2 -2
- package/dist/core/column.js +3 -2
- package/dist/core/comment-thread.d.ts +7 -3
- package/dist/core/conditional-formatting-overlay.d.ts +9 -0
- package/dist/core/conditional-formatting-overlay.js +28 -1
- package/dist/core/conditional-formatting.d.ts +98 -10
- package/dist/core/conditional-formatting.js +42 -1
- package/dist/core/data-validation-overlay.d.ts +5 -0
- package/dist/core/data-validation-overlay.js +15 -0
- package/dist/core/data-validation.d.ts +16 -0
- package/dist/core/data-validation.js +15 -0
- package/dist/core/date-format.js +14 -4
- package/dist/core/date.js +1 -1
- package/dist/core/formula-references.d.ts +26 -0
- package/dist/core/formula-references.js +173 -0
- package/dist/core/formula-scan.d.ts +2 -0
- package/dist/core/formula-scan.js +58 -0
- package/dist/core/formula.d.ts +51 -18
- package/dist/core/formula.js +77 -86
- package/dist/core/function-values.d.ts +4 -0
- package/dist/core/function-values.js +58 -0
- package/dist/core/future-functions.d.ts +3 -0
- package/dist/core/{modern-functions.js → future-functions.js} +119 -88
- package/dist/core/grid-edits.d.ts +28 -0
- package/dist/core/grid-edits.js +193 -25
- package/dist/core/hyperlink.d.ts +39 -0
- package/dist/core/hyperlink.js +88 -0
- package/dist/core/image.d.ts +36 -5
- package/dist/core/image.js +9 -0
- package/dist/core/internal.d.ts +3 -1
- package/dist/core/limits.d.ts +5 -3
- package/dist/core/merge.d.ts +13 -0
- package/dist/core/merge.js +15 -1
- package/dist/core/page-setup.d.ts +26 -11
- package/dist/core/pivot-table.d.ts +49 -10
- package/dist/core/pivot-table.js +55 -21
- package/dist/core/protection.d.ts +66 -4
- package/dist/core/protection.js +4 -0
- package/dist/core/row.js +3 -2
- package/dist/core/structured-reference.d.ts +7 -0
- package/dist/core/structured-reference.js +7 -0
- package/dist/core/table.d.ts +38 -8
- package/dist/core/table.js +37 -7
- package/dist/core/theme.d.ts +2 -0
- package/dist/core/theme.js +4 -1
- package/dist/core/value.d.ts +51 -28
- package/dist/core/value.js +15 -12
- package/dist/core/workbook-styles.d.ts +17 -1
- package/dist/core/workbook-styles.js +4 -0
- package/dist/core/workbook-theme.js +5 -3
- package/dist/core/workbook.d.ts +20 -3
- package/dist/core/workbook.js +26 -5
- package/dist/core/worksheet-merges.d.ts +9 -4
- package/dist/core/worksheet-merges.js +17 -11
- package/dist/core/worksheet-model.d.ts +1 -1
- package/dist/core/worksheet-model.js +4 -0
- package/dist/core/worksheet-pictures.d.ts +3 -3
- package/dist/core/worksheet-pictures.js +7 -6
- package/dist/core/worksheet.d.ts +110 -21
- package/dist/core/worksheet.js +174 -49
- package/dist/entries/core.d.ts +7 -5
- package/dist/entries/core.js +4 -3
- package/dist/entries/errors.d.ts +1 -0
- package/dist/entries/errors.js +1 -0
- package/dist/errors.js +1 -1
- package/dist/io/cell-metadata/metadata.d.ts +42 -0
- package/dist/io/cell-metadata/metadata.js +35 -0
- package/dist/io/cell-metadata/rich-values.d.ts +11 -0
- package/dist/io/cell-metadata/rich-values.js +80 -0
- package/dist/io/csv/delimiter.d.ts +14 -2
- package/dist/io/csv/delimiter.js +12 -0
- package/dist/io/csv/errors.d.ts +14 -0
- package/dist/io/csv/errors.js +5 -0
- package/dist/io/csv/read.d.ts +6 -1
- package/dist/io/csv/read.js +46 -24
- package/dist/io/csv/write.d.ts +10 -3
- package/dist/io/csv/write.js +16 -7
- package/dist/io/opc/part-paths.js +4 -4
- package/dist/io/opc/read-opc.d.ts +4 -0
- package/dist/io/opc/read-opc.js +10 -4
- package/dist/io/opc/strict-relationships.d.ts +2 -0
- package/dist/io/opc/strict-relationships.js +12 -0
- package/dist/io/read-policy/column-budget.d.ts +26 -0
- package/dist/io/{xlsx → read-policy}/column-budget.js +4 -8
- package/dist/io/read-policy/read-repair.d.ts +74 -0
- package/dist/io/read-policy/read-repair.js +119 -0
- package/dist/io/style/cell-style-resolution.d.ts +25 -0
- package/dist/io/style/cell-style-resolution.js +30 -0
- package/dist/io/xlsb/formula.js +4 -2
- package/dist/io/xlsb/ptg-functions.js +110 -0
- package/dist/io/xlsb/read-metadata.d.ts +7 -0
- package/dist/io/xlsb/read-metadata.js +69 -0
- package/dist/io/xlsb/read-worksheet.d.ts +6 -0
- package/dist/io/xlsb/read-worksheet.js +95 -37
- package/dist/io/xlsb/read.js +26 -8
- package/dist/io/xlsb/record-types.d.ts +13 -0
- package/dist/io/xlsb/record-types.js +13 -0
- package/dist/io/xlsb/sheet-protection.d.ts +20 -0
- package/dist/io/xlsb/sheet-protection.js +60 -0
- package/dist/io/xlsx/cell-accumulator.d.ts +20 -12
- package/dist/io/xlsx/cell-accumulator.js +49 -19
- package/dist/io/xlsx/cell-metadata.d.ts +39 -0
- package/dist/io/xlsx/cell-metadata.js +162 -0
- package/dist/io/xlsx/cell-value.d.ts +16 -4
- package/dist/io/xlsx/cell-value.js +38 -21
- package/dist/io/xlsx/color-xml.js +1 -1
- package/dist/io/xlsx/column-span.d.ts +11 -0
- package/dist/io/xlsx/column-span.js +9 -0
- package/dist/io/xlsx/comments.d.ts +3 -28
- package/dist/io/xlsx/comments.js +3 -65
- package/dist/io/xlsx/conditional-formatting.d.ts +42 -25
- package/dist/io/xlsx/conditional-formatting.js +424 -129
- package/dist/io/xlsx/data-validation.d.ts +12 -7
- package/dist/io/xlsx/data-validation.js +41 -29
- package/dist/io/xlsx/edit-vba.js +43 -36
- package/dist/io/xlsx/hyperlinks.d.ts +16 -50
- package/dist/io/xlsx/hyperlinks.js +8 -37
- package/dist/io/xlsx/images.d.ts +49 -16
- package/dist/io/xlsx/images.js +145 -44
- package/dist/io/xlsx/namespaces.d.ts +8 -0
- package/dist/io/xlsx/namespaces.js +4 -0
- package/dist/io/xlsx/package-plan.d.ts +48 -15
- package/dist/io/xlsx/package-plan.js +46 -9
- package/dist/io/xlsx/part-names.d.ts +6 -8
- package/dist/io/xlsx/part-names.js +3 -7
- package/dist/io/xlsx/pivot.d.ts +5 -5
- package/dist/io/xlsx/pivot.js +23 -22
- package/dist/io/xlsx/preserved-splices.d.ts +6 -0
- package/dist/io/xlsx/preserved-splices.js +74 -0
- package/dist/io/xlsx/read-comments.d.ts +29 -0
- package/dist/io/xlsx/read-comments.js +75 -0
- package/dist/io/xlsx/read-parts.d.ts +2 -2
- package/dist/io/xlsx/read-parts.js +44 -37
- package/dist/io/xlsx/read-pivot.js +9 -3
- package/dist/io/xlsx/read-rich-runs.d.ts +8 -5
- package/dist/io/xlsx/read-rich-runs.js +18 -1
- package/dist/io/xlsx/read-rows.d.ts +18 -7
- package/dist/io/xlsx/read-rows.js +47 -37
- package/dist/io/xlsx/read-styles.d.ts +0 -25
- package/dist/io/xlsx/read-styles.js +39 -34
- package/dist/io/xlsx/read-workbook-xml.d.ts +6 -0
- package/dist/io/xlsx/read-workbook-xml.js +9 -4
- package/dist/io/xlsx/read-worksheet.d.ts +8 -3
- package/dist/io/xlsx/read-worksheet.js +45 -23
- package/dist/io/xlsx/read.d.ts +0 -4
- package/dist/io/xlsx/read.js +17 -21
- package/dist/io/xlsx/relationships.d.ts +3 -0
- package/dist/io/xlsx/relationships.js +4 -0
- package/dist/io/xlsx/row-position.d.ts +3 -1
- package/dist/io/xlsx/row-xml.d.ts +18 -7
- package/dist/io/xlsx/row-xml.js +54 -35
- package/dist/io/xlsx/sheet-properties.js +68 -42
- package/dist/io/xlsx/strict-parts.d.ts +7 -0
- package/dist/io/xlsx/strict-parts.js +171 -0
- package/dist/io/xlsx/style-elements.d.ts +0 -2
- package/dist/io/xlsx/style-elements.js +9 -29
- package/dist/io/xlsx/styles.d.ts +5 -0
- package/dist/io/xlsx/styles.js +11 -5
- package/dist/io/xlsx/tables.d.ts +10 -2
- package/dist/io/xlsx/tables.js +49 -42
- package/dist/io/xlsx/theme-xml.d.ts +6 -0
- package/dist/io/xlsx/theme-xml.js +16 -19
- package/dist/io/xlsx/threaded-comments.d.ts +6 -1
- package/dist/io/xlsx/threaded-comments.js +14 -7
- package/dist/io/xlsx/workbook-xml.d.ts +13 -24
- package/dist/io/xlsx/workbook-xml.js +15 -33
- package/dist/io/xlsx/worksheet-xml.d.ts +5 -2
- package/dist/io/xlsx/worksheet-xml.js +37 -69
- package/dist/io/xlsx/write-stream.d.ts +28 -6
- package/dist/io/xlsx/write-stream.js +42 -17
- package/dist/io/xlsx/write.d.ts +11 -4
- package/dist/io/xlsx/write.js +153 -90
- package/dist/rel-type.d.ts +9 -0
- package/dist/rel-type.js +3 -0
- package/dist/vba/bytes.d.ts +2 -0
- package/dist/vba/bytes.js +11 -0
- package/dist/vba/cfb-format.d.ts +47 -0
- package/dist/vba/cfb-format.js +34 -0
- package/dist/vba/cfb-writer.d.ts +1 -2
- package/dist/vba/cfb-writer.js +33 -36
- package/dist/vba/cfb.d.ts +9 -4
- package/dist/vba/cfb.js +55 -43
- package/dist/vba/dir-records.d.ts +6 -0
- package/dist/vba/dir-records.js +10 -2
- package/dist/vba/errors.d.ts +4 -4
- package/dist/vba/index.d.ts +0 -2
- package/dist/vba/index.js +0 -2
- package/dist/vba/ms-ovba.d.ts +6 -2
- package/dist/vba/ms-ovba.js +15 -6
- package/dist/vba/project-editor.js +102 -87
- package/dist/vba/project.d.ts +4 -0
- package/dist/vba/project.js +12 -6
- package/dist/vba/vba-encoding.d.ts +4 -10
- package/dist/vba/vba-encoding.js +2 -15
- package/dist/xml/xml-read.d.ts +29 -1
- package/dist/xml/xml-read.js +56 -0
- package/dist/xml/xml-scan.d.ts +13 -0
- package/dist/xml/xml-scan.js +58 -7
- package/dist/xml/xml.d.ts +33 -1
- package/dist/xml/xml.js +22 -0
- package/package.json +5 -4
- package/skills/ts-xlsx-upstream/SKILL.md +21 -13
- package/dist/core/modern-functions.d.ts +0 -1
- package/dist/io/xlsx/cell-style-resolution.d.ts +0 -25
- package/dist/io/xlsx/cell-style-resolution.js +0 -29
- package/dist/io/xlsx/column-budget.d.ts +0 -26
- package/dist/io/xlsx/read-repair.d.ts +0 -26
- package/dist/io/xlsx/read-repair.js +0 -39
package/dist/xml/xml.js
CHANGED
|
@@ -46,6 +46,12 @@ export function textElement(value) {
|
|
|
46
46
|
const space = needsSpacePreserve(value) ? ' xml:space="preserve"' : '';
|
|
47
47
|
return `<t${space}>${escapeSpreadsheetText(value)}</t>`;
|
|
48
48
|
}
|
|
49
|
+
export function startTag(name, attrs, selfClosing) {
|
|
50
|
+
let out = `<${name}`;
|
|
51
|
+
for (const key in attrs)
|
|
52
|
+
out += ` ${key}="${escapeAttr(attrs[key] ?? '')}"`;
|
|
53
|
+
return `${out}${selfClosing ? '/>' : '>'}`;
|
|
54
|
+
}
|
|
49
55
|
export function boolAttr(name, value) {
|
|
50
56
|
return value === undefined ? '' : ` ${name}="${value ? 1 : 0}"`;
|
|
51
57
|
}
|
|
@@ -61,6 +67,22 @@ export function checkedToken(value, isValid, kind) {
|
|
|
61
67
|
export function numAttr(name, value) {
|
|
62
68
|
return value === undefined ? '' : ` ${name}="${numberText(value)}"`;
|
|
63
69
|
}
|
|
70
|
+
export function intAttr(name, value, min = -Number.MAX_SAFE_INTEGER) {
|
|
71
|
+
if (value === undefined)
|
|
72
|
+
return '';
|
|
73
|
+
assertWritableNumber(value);
|
|
74
|
+
if (!Number.isSafeInteger(value) || value < min) {
|
|
75
|
+
const floor = min === -Number.MAX_SAFE_INTEGER ? '' : ` of at least ${min}`;
|
|
76
|
+
throw new AuthoringError(`cannot write ${name}="${value}": expected an integer${floor}`);
|
|
77
|
+
}
|
|
78
|
+
return ` ${name}="${value}"`;
|
|
79
|
+
}
|
|
80
|
+
export function nonDefaultNumAttr(name, value, defaultValue) {
|
|
81
|
+
if (value === undefined)
|
|
82
|
+
return '';
|
|
83
|
+
const text = numberText(value);
|
|
84
|
+
return value === defaultValue ? '' : ` ${name}="${text}"`;
|
|
85
|
+
}
|
|
64
86
|
export function assertWritableDate(date, property) {
|
|
65
87
|
const time = date.getTime();
|
|
66
88
|
if (Number.isNaN(time)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shbernal/ts-xlsx",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "A TypeScript-first library for reading and writing xlsx (OOXML) spreadsheets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"csv",
|
|
@@ -90,6 +90,7 @@
|
|
|
90
90
|
"docs:check": "node scripts/gen-docs.ts && git add --intent-to-add -- docs/api && git diff --exit-code -- docs/api",
|
|
91
91
|
"constitution:check": "node scripts/check-constitution.ts",
|
|
92
92
|
"layering:check": "node scripts/check-layering.ts",
|
|
93
|
+
"corpus-blind:check": "node scripts/check-corpus-blind.ts",
|
|
93
94
|
"entries:check": "node scripts/check-entries.ts",
|
|
94
95
|
"public-types:check": "node scripts/check-public-types.ts",
|
|
95
96
|
"facet-register:check": "node scripts/check-facet-register.ts",
|
|
@@ -129,8 +130,8 @@
|
|
|
129
130
|
"jszip": "^3.10.1",
|
|
130
131
|
"lefthook": "^2.1.12",
|
|
131
132
|
"ooxml-validate": "^0.0.3",
|
|
132
|
-
"oxfmt": "^0.
|
|
133
|
-
"oxlint": "^1.
|
|
133
|
+
"oxfmt": "^0.67.0",
|
|
134
|
+
"oxlint": "^1.82.0",
|
|
134
135
|
"oxlint-tsgolint": "7.0.2001",
|
|
135
136
|
"shiki": "^4.4.3",
|
|
136
137
|
"typescript": "^7.0.2",
|
|
@@ -140,5 +141,5 @@
|
|
|
140
141
|
"engines": {
|
|
141
142
|
"node": ">=24"
|
|
142
143
|
},
|
|
143
|
-
"packageManager": "pnpm@
|
|
144
|
+
"packageManager": "pnpm@12.3.4"
|
|
144
145
|
}
|
|
@@ -5,7 +5,7 @@ description: Report a ts-xlsx (@shbernal/ts-xlsx) bug, gap, or wrong output to i
|
|
|
5
5
|
|
|
6
6
|
# Reporting a ts-xlsx problem upstream
|
|
7
7
|
|
|
8
|
-
You are in a project that
|
|
8
|
+
You are in a project that _uses_ `@shbernal/ts-xlsx`, not the project that builds it.
|
|
9
9
|
This skill is how a defect you hit here becomes a permanent regression test there.
|
|
10
10
|
|
|
11
11
|
The library's maintainers turn reports with a minimal reproduction into corpus cases,
|
|
@@ -20,12 +20,12 @@ builds its own input.** Everything below is in service of that.
|
|
|
20
20
|
Catch the error and read `code` — the taxonomy is deliberately coarse and each answer
|
|
21
21
|
means something different about whose bug it is.
|
|
22
22
|
|
|
23
|
-
| `error.code`
|
|
24
|
-
|
|
|
25
|
-
| `internal`
|
|
26
|
-
| `unsupported-format`
|
|
27
|
-
| `malformed-input`
|
|
28
|
-
| `authoring`
|
|
23
|
+
| `error.code` | Whose bug | Report it? |
|
|
24
|
+
| -------------------- | ---------------- | --------------------------------------------------------------- |
|
|
25
|
+
| `internal` | **ts-xlsx** | Always. The library says so itself in the message. |
|
|
26
|
+
| `unsupported-format` | usually the file | Only if the file opens **cleanly in Excel**. Then it's our gap. |
|
|
27
|
+
| `malformed-input` | usually the file | Same test: clean in Excel but rejected here means it's ours. |
|
|
28
|
+
| `authoring` | usually you | Only if the document it refused is one Excel can express. |
|
|
29
29
|
|
|
30
30
|
Not every defect throws. These are ours too, and are worth reporting:
|
|
31
31
|
|
|
@@ -34,7 +34,7 @@ Not every defect throws. These are ours too, and are worth reporting:
|
|
|
34
34
|
- Types that make correct code fail to compile, or admit code that throws at runtime.
|
|
35
35
|
- Documented behaviour that does not match observed behaviour.
|
|
36
36
|
|
|
37
|
-
If the problem is that ts-xlsx does not
|
|
37
|
+
If the problem is that ts-xlsx does not _have_ a feature, that is still worth filing —
|
|
38
38
|
as a feature request rather than a bug.
|
|
39
39
|
|
|
40
40
|
## 2. Collect the facts
|
|
@@ -54,7 +54,7 @@ salaries, customer lists, and unreleased numbers. Treat every file in this repo
|
|
|
54
54
|
confidential unless the user tells you otherwise, and never upload one to a public
|
|
55
55
|
tracker — including "just a screenshot of the sheet".
|
|
56
56
|
|
|
57
|
-
Instead, write a self-contained script that
|
|
57
|
+
Instead, write a self-contained script that _constructs_ its input and fails:
|
|
58
58
|
|
|
59
59
|
```ts
|
|
60
60
|
import {Workbook, writeXlsx, readXlsx} from '@shbernal/ts-xlsx';
|
|
@@ -72,13 +72,13 @@ Then cut it down: remove rows, styles, sheets, and options one at a time, re-run
|
|
|
72
72
|
after each cut, until removing anything more makes the failure disappear. What is left
|
|
73
73
|
is the report.
|
|
74
74
|
|
|
75
|
-
If the failure only reproduces with a
|
|
75
|
+
If the failure only reproduces with a _specific file_ you cannot share, do not ask for
|
|
76
76
|
permission to share it — file without the file. Say exactly that in the report and describe
|
|
77
77
|
the structural feature you believe is responsible (a shared formula, a pivot cache, an
|
|
78
78
|
inline string, a particular namespace prefix). A maintainer can usually synthesize a file
|
|
79
79
|
from that description; they can never unsee an attachment.
|
|
80
80
|
|
|
81
|
-
If you need a file attached, build one: reproduce the
|
|
81
|
+
If you need a file attached, build one: reproduce the _structure_ you suspect in a workbook
|
|
82
82
|
you generate, with invented values. A synthesized file is always safe to attach. A redacted
|
|
83
83
|
one is not yours to judge — redaction fails quietly, and a public tracker is permanent.
|
|
84
84
|
|
|
@@ -105,7 +105,7 @@ file from this project is attached. When you cannot manage a self-contained repr
|
|
|
105
105
|
the answer is a thinner report — the prose description from step 3 — not a question and not
|
|
106
106
|
an attachment.
|
|
107
107
|
|
|
108
|
-
`gh` defaults to the
|
|
108
|
+
`gh` defaults to the _current_ repository — which here is the consumer's, not ts-xlsx's.
|
|
109
109
|
Always pass `--repo shbernal/ts-xlsx` explicitly, or you will file the bug into the wrong
|
|
110
110
|
tracker.
|
|
111
111
|
|
|
@@ -121,31 +121,39 @@ issue forms, so mirror its sections in the body file so both routes land the sam
|
|
|
121
121
|
|
|
122
122
|
````markdown
|
|
123
123
|
### ts-xlsx version
|
|
124
|
+
|
|
124
125
|
<x.y.z>
|
|
125
126
|
|
|
126
127
|
### Node version
|
|
128
|
+
|
|
127
129
|
<vXX.Y.Z>
|
|
128
130
|
|
|
129
131
|
### Error code and class
|
|
130
|
-
|
|
132
|
+
|
|
133
|
+
<code> / <ClassName> (or: no error thrown — wrong output)
|
|
131
134
|
|
|
132
135
|
### What happened
|
|
136
|
+
|
|
133
137
|
<observed>
|
|
134
138
|
|
|
135
139
|
### What should have happened
|
|
140
|
+
|
|
136
141
|
<expected, and why you believe that — a spec clause, Excel's own behaviour, or the docs>
|
|
137
142
|
|
|
138
143
|
### Minimal reproduction
|
|
144
|
+
|
|
139
145
|
```ts
|
|
140
146
|
<the script from step 3>
|
|
141
147
|
```
|
|
142
148
|
|
|
143
149
|
### Error output
|
|
150
|
+
|
|
144
151
|
```
|
|
145
152
|
<verbatim message and stack>
|
|
146
153
|
```
|
|
147
154
|
|
|
148
155
|
### Attached file
|
|
156
|
+
|
|
149
157
|
<none / synthesized — describe how it was generated>
|
|
150
158
|
````
|
|
151
159
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const MODERN_FUNCTIONS: ReadonlySet<string>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/** The attributes this resolver reads, the subset both readers' scanners already hand it. */
|
|
2
|
-
interface StyleAttributes {
|
|
3
|
-
readonly [key: string]: string | undefined;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* The cell → row → column style resolution for one worksheet, fed by the same elements in the same
|
|
7
|
-
* order both readers already visit them: `<col>` before any cell references it, `<row>` before its
|
|
8
|
-
* own cells.
|
|
9
|
-
*/
|
|
10
|
-
export declare class CellStyleResolver {
|
|
11
|
-
#private;
|
|
12
|
-
/** Record a `<col min max style>` span's default for the columns it covers. */
|
|
13
|
-
noteColumnSpan(first: number, last: number, attrs: StyleAttributes): void;
|
|
14
|
-
/** Open a `<row>`, taking the format it declares for its own bare cells. */
|
|
15
|
-
openRow(attrs: StyleAttributes): void;
|
|
16
|
-
/** Close the row, so a cell outside one never inherits the last row's format. */
|
|
17
|
-
closeRow(): void;
|
|
18
|
-
/**
|
|
19
|
-
* The `xfStyles` index a cell's format resolves to, or `-1` when nothing declares one. A row's
|
|
20
|
-
* format applies only when the row is marked `customFormat`; without that flag the `s` on a `<row>`
|
|
21
|
-
* describes the row itself and is not inherited by its cells.
|
|
22
|
-
*/
|
|
23
|
-
indexFor(col: number, cellStyleIndex: number): number;
|
|
24
|
-
}
|
|
25
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { numInteger } from '../../xml/xml-attrs.js';
|
|
2
|
-
import { boolStrict } from '../../xml/xml-scan.js';
|
|
3
|
-
export class CellStyleResolver {
|
|
4
|
-
#columnStyle = new Map();
|
|
5
|
-
#rowStyle = -1;
|
|
6
|
-
#rowCustomFormat = false;
|
|
7
|
-
noteColumnSpan(first, last, attrs) {
|
|
8
|
-
const styleIndex = numInteger(attrs.style, 0) ?? -1;
|
|
9
|
-
if (styleIndex < 0)
|
|
10
|
-
return;
|
|
11
|
-
for (let index = first; index <= last; index++)
|
|
12
|
-
this.#columnStyle.set(index, styleIndex);
|
|
13
|
-
}
|
|
14
|
-
openRow(attrs) {
|
|
15
|
-
this.#rowStyle = numInteger(attrs.s, 0) ?? -1;
|
|
16
|
-
this.#rowCustomFormat = boolStrict(attrs.customFormat);
|
|
17
|
-
}
|
|
18
|
-
closeRow() {
|
|
19
|
-
this.#rowStyle = -1;
|
|
20
|
-
this.#rowCustomFormat = false;
|
|
21
|
-
}
|
|
22
|
-
indexFor(col, cellStyleIndex) {
|
|
23
|
-
if (cellStyleIndex >= 0)
|
|
24
|
-
return cellStyleIndex;
|
|
25
|
-
if (this.#rowCustomFormat && this.#rowStyle >= 0)
|
|
26
|
-
return this.#rowStyle;
|
|
27
|
-
return this.#columnStyle.get(col) ?? -1;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type XmlAttributes } from '../../xml/xml-scan.ts';
|
|
2
|
-
/**
|
|
3
|
-
* A per-sheet allowance of column touches, spent by each `<col>` span the reader applies.
|
|
4
|
-
*
|
|
5
|
-
* A span past the allowance is truncated, and one starting past it is dropped, rather than the read
|
|
6
|
-
* being refused: that is the stance both readers already take on an out-of-grid span, and it means a
|
|
7
|
-
* hostile file loses formatting it could not have meant while a real one is untouched.
|
|
8
|
-
*/
|
|
9
|
-
export declare class ColumnRecordBudget {
|
|
10
|
-
#private;
|
|
11
|
-
/** The last column of `[first, last]` this sheet can still afford, or `undefined` when none is. */
|
|
12
|
-
take(first: number, last: number): number | undefined;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* The columns a `<col min max>` element actually applies to, or `undefined` for one that applies to
|
|
16
|
-
* none: unreadable bounds, a span starting past the grid, or a budget already spent.
|
|
17
|
-
*
|
|
18
|
-
* Beside the budget because the two decisions are one decision. Both readers had their own copy, and
|
|
19
|
-
* the copies had already drifted: one tested `min > MAX_COLUMN` and the other did not, which happened
|
|
20
|
-
* not to matter only because `budget.take` returns `undefined` when `first > last` - an accident of
|
|
21
|
-
* this class's contract rather than an agreement between the readers.
|
|
22
|
-
*/
|
|
23
|
-
export declare function takeColumnSpan(attrs: XmlAttributes, budget: ColumnRecordBudget): {
|
|
24
|
-
first: number;
|
|
25
|
-
last: number;
|
|
26
|
-
} | undefined;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A sheet name from a file, rewritten into one the model will accept.
|
|
3
|
-
*
|
|
4
|
-
* Excel's own repair, in the order the constraints interact: forbidden characters go first (they
|
|
5
|
-
* can be anywhere), then the length ceiling, then the apostrophe rule *again*, because truncating
|
|
6
|
-
* can expose an interior apostrophe at the new edge. An empty result becomes `Sheet{n}`, and a
|
|
7
|
-
* collision takes a ` (2)` suffix that is itself made to fit inside the 31-character limit.
|
|
8
|
-
*
|
|
9
|
-
* @param taken the lower-cased names already in the workbook; sheet names collide
|
|
10
|
-
* case-insensitively, which is the comparison `Workbook.getWorksheet` makes.
|
|
11
|
-
*/
|
|
12
|
-
export declare function repairSheetName(name: string, taken: ReadonlySet<string>): string;
|
|
13
|
-
/**
|
|
14
|
-
* Run a model call that is being handed foreign input, and answer `undefined` where the model
|
|
15
|
-
* refuses it.
|
|
16
|
-
*
|
|
17
|
-
* The three caught types are the three a model method raises *about its argument*: an
|
|
18
|
-
* `AuthoringError` for a composite that cannot exist, and the native `RangeError` / `SyntaxError`
|
|
19
|
-
* the taxonomy assigns to a single scalar that is out of range or does not parse. Every one of them
|
|
20
|
-
* is a statement about the caller, and on this path the caller is a file.
|
|
21
|
-
*
|
|
22
|
-
* Nothing else is caught. An `XlsxError` raised by a layer below is a real failure of the read and
|
|
23
|
-
* keeps its identity; an `InternalError` is a bug of ours and must not be swallowed by a reader
|
|
24
|
-
* being tolerant about somebody else's file.
|
|
25
|
-
*/
|
|
26
|
-
export declare function admitting<T>(build: () => T): T | undefined;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { INVALID_SHEET_NAME_CHARS, MAX_SHEET_NAME_LENGTH } from '../../core/limits.js';
|
|
2
|
-
import { AuthoringError } from '../../errors.js';
|
|
3
|
-
const INVALID_SHEET_NAME_CHARS_GLOBAL = new RegExp(INVALID_SHEET_NAME_CHARS.source, 'g');
|
|
4
|
-
export function repairSheetName(name, taken) {
|
|
5
|
-
const stripped = trimApostrophes(name.replace(INVALID_SHEET_NAME_CHARS_GLOBAL, '')).slice(0, MAX_SHEET_NAME_LENGTH);
|
|
6
|
-
const base = trimApostrophes(stripped);
|
|
7
|
-
if (base.length === 0)
|
|
8
|
-
return firstFree((n) => `Sheet${n}`, taken);
|
|
9
|
-
if (!taken.has(base.toLowerCase()))
|
|
10
|
-
return base;
|
|
11
|
-
return firstFree((n) => withSuffix(base, ` (${n})`), taken, 2);
|
|
12
|
-
}
|
|
13
|
-
function trimApostrophes(name) {
|
|
14
|
-
return name.replace(/^'+/, '').replace(/'+$/, '');
|
|
15
|
-
}
|
|
16
|
-
function firstFree(candidate, taken, from = 1) {
|
|
17
|
-
for (let n = from;; n++) {
|
|
18
|
-
const name = candidate(n);
|
|
19
|
-
if (!taken.has(name.toLowerCase()))
|
|
20
|
-
return name;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function withSuffix(base, suffix) {
|
|
24
|
-
const room = MAX_SHEET_NAME_LENGTH - suffix.length;
|
|
25
|
-
return trimApostrophes(base.slice(0, room)) + suffix;
|
|
26
|
-
}
|
|
27
|
-
export function admitting(build) {
|
|
28
|
-
try {
|
|
29
|
-
return build();
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
if (error instanceof AuthoringError ||
|
|
33
|
-
error instanceof RangeError ||
|
|
34
|
-
error instanceof SyntaxError) {
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
}
|