@shbernal/ts-xlsx 3.0.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 +34 -24
- package/dist/bytes.d.ts +10 -2
- package/dist/bytes.js +22 -0
- package/dist/core/address.d.ts +96 -2
- package/dist/core/address.js +87 -33
- package/dist/core/array-formula-ranges.d.ts +33 -0
- package/dist/core/array-formula-ranges.js +62 -0
- package/dist/core/autofilter.d.ts +4 -3
- package/dist/core/autofilter.js +31 -30
- package/dist/core/axis-handle.d.ts +2 -0
- package/dist/core/axis-handle.js +5 -2
- package/dist/core/cell.d.ts +4 -3
- package/dist/core/cell.js +4 -6
- package/dist/core/clone.d.ts +29 -0
- package/dist/core/clone.js +24 -0
- package/dist/core/color-resolution.js +4 -6
- package/dist/core/column.d.ts +1 -0
- package/dist/core/column.js +6 -2
- package/dist/core/comment-thread.d.ts +7 -3
- package/dist/core/comment-thread.js +2 -1
- package/dist/core/conditional-formatting-overlay.d.ts +11 -1
- package/dist/core/conditional-formatting-overlay.js +30 -3
- package/dist/core/conditional-formatting.d.ts +107 -11
- package/dist/core/conditional-formatting.js +76 -19
- package/dist/core/containers.d.ts +12 -0
- package/dist/core/containers.js +5 -0
- package/dist/core/data-validation-overlay.d.ts +7 -1
- package/dist/core/data-validation-overlay.js +19 -4
- package/dist/core/data-validation.d.ts +22 -0
- package/dist/core/data-validation.js +30 -4
- package/dist/core/date-format.d.ts +20 -0
- package/dist/core/date-format.js +170 -0
- package/dist/core/date.d.ts +43 -8
- package/dist/core/date.js +19 -3
- 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 +76 -17
- package/dist/core/formula.js +87 -80
- 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 +30 -3
- package/dist/core/grid-edits.js +248 -81
- package/dist/core/grid-shift.d.ts +58 -9
- package/dist/core/grid-shift.js +26 -4
- package/dist/core/hyperlink.d.ts +39 -0
- package/dist/core/hyperlink.js +88 -0
- package/dist/core/image.d.ts +49 -14
- package/dist/core/image.js +16 -5
- package/dist/core/internal.d.ts +10 -2
- package/dist/core/limits.d.ts +25 -0
- package/dist/core/limits.js +4 -0
- package/dist/core/merge.d.ts +18 -4
- package/dist/core/merge.js +33 -20
- package/dist/core/page-setup.d.ts +26 -11
- package/dist/core/pivot-table.d.ts +49 -10
- package/dist/core/pivot-table.js +112 -60
- package/dist/core/protection.d.ts +66 -4
- package/dist/core/protection.js +6 -11
- package/dist/core/range.js +34 -30
- package/dist/core/row-input.js +2 -2
- package/dist/core/row.d.ts +1 -0
- package/dist/core/row.js +6 -2
- package/dist/core/structured-reference.d.ts +7 -0
- package/dist/core/structured-reference.js +7 -0
- package/dist/core/style.d.ts +85 -70
- package/dist/core/style.js +92 -28
- package/dist/core/table-style.d.ts +1 -1
- package/dist/core/table-style.js +4 -4
- package/dist/core/table.d.ts +64 -16
- package/dist/core/table.js +87 -40
- package/dist/core/theme.d.ts +2 -0
- package/dist/core/theme.js +9 -5
- package/dist/core/value.d.ts +60 -28
- package/dist/core/value.js +48 -43
- package/dist/core/workbook-media.d.ts +34 -0
- package/dist/core/workbook-media.js +44 -0
- package/dist/core/workbook-styles.d.ts +83 -1
- package/dist/core/workbook-styles.js +4 -0
- package/dist/core/workbook-theme.js +5 -3
- package/dist/core/workbook-vba.js +3 -2
- package/dist/core/workbook.d.ts +41 -3
- package/dist/core/workbook.js +46 -41
- package/dist/core/worksheet-comments.d.ts +2 -1
- package/dist/core/worksheet-comments.js +20 -13
- package/dist/core/worksheet-merges.d.ts +49 -0
- package/dist/core/worksheet-merges.js +65 -0
- package/dist/core/worksheet-model.d.ts +10 -2
- package/dist/core/worksheet-model.js +28 -9
- package/dist/core/worksheet-pictures.d.ts +3 -3
- package/dist/core/worksheet-pictures.js +7 -6
- package/dist/core/worksheet.d.ts +165 -27
- package/dist/core/worksheet.js +206 -89
- package/dist/customui/ribbon.js +2 -1
- package/dist/entries/core.d.ts +21 -14
- package/dist/entries/core.js +14 -7
- package/dist/entries/errors.d.ts +1 -0
- package/dist/entries/errors.js +1 -0
- 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/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 +21 -0
- package/dist/io/csv/delimiter.js +18 -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 +51 -22
- package/dist/io/csv/write.d.ts +19 -5
- package/dist/io/csv/write.js +24 -44
- package/dist/io/opc/inflate.js +14 -0
- 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 +9 -0
- package/dist/io/opc/part-paths.js +5 -5
- package/dist/io/opc/read-opc.d.ts +58 -14
- package/dist/io/opc/read-opc.js +49 -21
- package/dist/io/opc/read-options.d.ts +5 -1
- package/dist/io/opc/sniff-format.d.ts +3 -3
- package/dist/io/opc/sniff-format.js +2 -2
- 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/read-policy/column-budget.js +18 -0
- 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/style/xf-style.d.ts +23 -1
- package/dist/io/style/xf-style.js +8 -0
- package/dist/io/xlsb/formula.d.ts +2 -2
- package/dist/io/xlsb/formula.js +52 -35
- 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 +495 -596
- package/dist/io/xlsb/read-metadata.d.ts +7 -0
- package/dist/io/xlsb/read-metadata.js +69 -0
- package/dist/io/xlsb/read-styles.js +45 -81
- package/dist/io/xlsb/read-worksheet.d.ts +26 -1
- package/dist/io/xlsb/read-worksheet.js +148 -106
- package/dist/io/xlsb/read.d.ts +6 -3
- package/dist/io/xlsb/read.js +70 -31
- 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 +14 -5
- package/dist/io/xlsb/record-types.js +14 -5
- 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 +24 -9
- package/dist/io/xlsx/cell-accumulator.js +74 -21
- 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 +19 -5
- package/dist/io/xlsx/cell-value.js +45 -30
- package/dist/io/xlsx/color-xml.js +3 -2
- 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 +9 -30
- package/dist/io/xlsx/comments.js +25 -83
- package/dist/io/xlsx/conditional-formatting.d.ts +43 -23
- package/dist/io/xlsx/conditional-formatting.js +437 -138
- package/dist/io/xlsx/data-validation.d.ts +12 -7
- package/dist/io/xlsx/data-validation.js +67 -53
- package/dist/io/xlsx/edit-vba.d.ts +7 -2
- package/dist/io/xlsx/edit-vba.js +52 -52
- 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 +19 -21
- package/dist/io/xlsx/hyperlinks.js +12 -32
- package/dist/io/xlsx/images.d.ts +49 -16
- package/dist/io/xlsx/images.js +149 -50
- package/dist/io/xlsx/namespaces.d.ts +24 -0
- package/dist/io/xlsx/namespaces.js +11 -0
- package/dist/io/xlsx/package-plan.d.ts +60 -15
- package/dist/io/xlsx/package-plan.js +83 -18
- 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 +26 -24
- 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 +59 -0
- package/dist/io/xlsx/read-parts.js +259 -0
- package/dist/io/xlsx/read-pivot.js +11 -4
- package/dist/io/xlsx/{rich-runs.d.ts → read-rich-runs.d.ts} +8 -5
- package/dist/io/xlsx/{rich-runs.js → read-rich-runs.js} +24 -4
- package/dist/io/xlsx/read-rows.d.ts +35 -11
- package/dist/io/xlsx/read-rows.js +73 -49
- package/dist/io/xlsx/read-shared-strings.js +3 -2
- package/dist/io/xlsx/read-styles.d.ts +0 -30
- package/dist/io/xlsx/read-styles.js +45 -105
- package/dist/io/xlsx/read-workbook-xml.d.ts +42 -0
- package/dist/io/xlsx/read-workbook-xml.js +175 -0
- package/dist/io/xlsx/read-worksheet.d.ts +9 -3
- package/dist/io/xlsx/read-worksheet.js +70 -177
- package/dist/io/xlsx/read.d.ts +3 -14
- package/dist/io/xlsx/read.js +74 -411
- package/dist/io/xlsx/relationships.d.ts +3 -0
- package/dist/io/xlsx/relationships.js +4 -0
- package/dist/io/xlsx/rich-text.js +1 -1
- package/dist/io/xlsx/row-position.d.ts +20 -0
- package/dist/io/xlsx/row-position.js +11 -0
- package/dist/io/xlsx/row-xml.d.ts +139 -0
- package/dist/io/xlsx/row-xml.js +222 -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 +182 -20
- 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 +41 -0
- package/dist/io/xlsx/style-elements.js +136 -0
- package/dist/io/xlsx/styles.d.ts +17 -3
- package/dist/io/xlsx/styles.js +13 -209
- package/dist/io/xlsx/tables.d.ts +10 -2
- package/dist/io/xlsx/tables.js +55 -52
- package/dist/io/xlsx/theme-xml.d.ts +32 -4
- package/dist/io/xlsx/theme-xml.js +106 -71
- package/dist/io/xlsx/threaded-comments.d.ts +14 -11
- package/dist/io/xlsx/threaded-comments.js +16 -8
- package/dist/io/xlsx/workbook-xml.d.ts +45 -6
- package/dist/io/xlsx/workbook-xml.js +62 -54
- package/dist/io/xlsx/worksheet-xml.d.ts +26 -70
- package/dist/io/xlsx/worksheet-xml.js +69 -282
- package/dist/io/xlsx/write-stream.d.ts +90 -19
- package/dist/io/xlsx/write-stream.js +80 -25
- package/dist/io/xlsx/write.d.ts +12 -6
- package/dist/io/xlsx/write.js +226 -123
- package/dist/rel-type.d.ts +25 -0
- package/dist/rel-type.js +9 -0
- package/dist/token-set.d.ts +13 -0
- package/dist/token-set.js +4 -1
- package/dist/vba/bytes.d.ts +16 -5
- package/dist/vba/bytes.js +27 -6
- package/dist/vba/cfb-format.d.ts +55 -0
- package/dist/vba/cfb-format.js +35 -0
- package/dist/vba/cfb-writer.d.ts +8 -0
- package/dist/vba/cfb-writer.js +40 -40
- package/dist/vba/cfb.d.ts +21 -4
- package/dist/vba/cfb.js +124 -90
- package/dist/vba/codepage.js +2 -1
- package/dist/vba/dir-records.d.ts +6 -0
- package/dist/vba/dir-records.js +10 -2
- package/dist/vba/errors.d.ts +11 -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 +66 -22
- package/dist/vba/project-editor.js +129 -119
- package/dist/vba/project.d.ts +15 -1
- package/dist/vba/project.js +38 -13
- package/dist/vba/vba-encoding.d.ts +4 -10
- package/dist/vba/vba-encoding.js +3 -17
- 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 +101 -11
- package/dist/xml/xml-read.js +150 -18
- package/dist/xml/xml-scan.d.ts +25 -34
- package/dist/xml/xml-scan.js +69 -46
- package/dist/xml/xml.d.ts +59 -26
- package/dist/xml/xml.js +45 -23
- package/package.json +15 -9
- package/skills/ts-xlsx-upstream/SKILL.md +21 -13
- package/dist/core/modern-functions.d.ts +0 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { AuthoringError, quoted } from '../errors.js';
|
|
2
|
+
import { boundedRect, decodeRange, encodeAddress, encodeRect, tryDecodeRange, } from './address.js';
|
|
3
|
+
import { replaceContents } from './containers.js';
|
|
4
|
+
import { shiftRect } from './grid-shift.js';
|
|
5
|
+
export class HyperlinkOverlay {
|
|
6
|
+
#entries = [];
|
|
7
|
+
#rects = [];
|
|
8
|
+
add(link) {
|
|
9
|
+
const rect = boundedRect(decodeRange(link.ref));
|
|
10
|
+
if (rect === undefined) {
|
|
11
|
+
throw new AuthoringError(`hyperlink range ${quoted(link.ref)} names a whole row or column, not cells`);
|
|
12
|
+
}
|
|
13
|
+
const stored = storedLink(link, refOf(rect));
|
|
14
|
+
this.#removeRef(stored.ref);
|
|
15
|
+
this.#entries.push(stored);
|
|
16
|
+
this.#rects.push(rect);
|
|
17
|
+
}
|
|
18
|
+
remove(ref) {
|
|
19
|
+
const decoded = tryDecodeRange(ref);
|
|
20
|
+
const rect = decoded === undefined ? undefined : boundedRect(decoded);
|
|
21
|
+
return rect !== undefined && this.#removeRef(refOf(rect));
|
|
22
|
+
}
|
|
23
|
+
get entries() {
|
|
24
|
+
return this.#entries;
|
|
25
|
+
}
|
|
26
|
+
at(col, row) {
|
|
27
|
+
for (let index = this.#entries.length - 1; index >= 0; index--) {
|
|
28
|
+
const rect = this.#rects[index];
|
|
29
|
+
if (rect !== undefined &&
|
|
30
|
+
col >= rect.left &&
|
|
31
|
+
col <= rect.right &&
|
|
32
|
+
row >= rect.top &&
|
|
33
|
+
row <= rect.bottom) {
|
|
34
|
+
return this.#entries[index];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
shift(splice) {
|
|
40
|
+
const entries = [];
|
|
41
|
+
const rects = [];
|
|
42
|
+
this.#entries.forEach((entry, index) => {
|
|
43
|
+
const rect = this.#rects[index];
|
|
44
|
+
const moved = rect === undefined ? undefined : shiftRect(rect, splice);
|
|
45
|
+
if (moved === undefined)
|
|
46
|
+
return;
|
|
47
|
+
const ref = refOf(moved);
|
|
48
|
+
entries.push(ref === entry.ref ? entry : storedLink(entry, ref));
|
|
49
|
+
rects.push(moved);
|
|
50
|
+
});
|
|
51
|
+
replaceContents(this.#entries, entries);
|
|
52
|
+
replaceContents(this.#rects, rects);
|
|
53
|
+
}
|
|
54
|
+
copyRow(from, to) {
|
|
55
|
+
const copies = this.#entries.flatMap((entry, index) => {
|
|
56
|
+
const rect = this.#rects[index];
|
|
57
|
+
return rect === undefined || rect.top !== from || rect.bottom !== from
|
|
58
|
+
? []
|
|
59
|
+
: [storedLink(entry, refOf({ ...rect, top: to, bottom: to }))];
|
|
60
|
+
});
|
|
61
|
+
for (const copy of copies)
|
|
62
|
+
this.add(copy);
|
|
63
|
+
}
|
|
64
|
+
clear() {
|
|
65
|
+
this.#entries.length = 0;
|
|
66
|
+
this.#rects.length = 0;
|
|
67
|
+
}
|
|
68
|
+
#removeRef(ref) {
|
|
69
|
+
const index = this.#entries.findIndex((entry) => entry.ref === ref);
|
|
70
|
+
if (index === -1)
|
|
71
|
+
return false;
|
|
72
|
+
this.#entries.splice(index, 1);
|
|
73
|
+
this.#rects.splice(index, 1);
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function refOf(rect) {
|
|
78
|
+
return rect.top === rect.bottom && rect.left === rect.right
|
|
79
|
+
? encodeAddress(rect.left, rect.top)
|
|
80
|
+
: encodeRect(rect);
|
|
81
|
+
}
|
|
82
|
+
function storedLink(link, ref) {
|
|
83
|
+
return {
|
|
84
|
+
ref,
|
|
85
|
+
target: link.target,
|
|
86
|
+
...(link.tooltip === undefined ? {} : { tooltip: link.tooltip }),
|
|
87
|
+
};
|
|
88
|
+
}
|
package/dist/core/image.d.ts
CHANGED
|
@@ -14,8 +14,9 @@ export interface AnchorPoint {
|
|
|
14
14
|
* DPI-independent by construction: a pixel extent is a fixed physical size regardless of screen. */
|
|
15
15
|
export declare const PX_TO_EMU = 9525;
|
|
16
16
|
/** How a two-cell-anchored image tracks edits to the cells it spans. `twoCell` moves and resizes with
|
|
17
|
-
* them; `oneCell` moves but keeps its size; `absolute` is pinned to the page and does neither.
|
|
18
|
-
*
|
|
17
|
+
* them; `oneCell` moves but keeps its size; `absolute` is pinned to the page and does neither. The
|
|
18
|
+
* schema default, which a file omitting the attribute means, is `twoCell`; an image authored here
|
|
19
|
+
* without one is written as `oneCell`, which is this library's own default. */
|
|
19
20
|
export type ImageEditAs = 'oneCell' | 'twoCell' | 'absolute';
|
|
20
21
|
/** Narrow a raw `<xdr:twoCellAnchor editAs>` token to a known {@link ImageEditAs}. */
|
|
21
22
|
export declare const isImageEditAs: (value: string) => value is ImageEditAs;
|
|
@@ -57,12 +58,42 @@ export type RowHeightLookup = (row: number) => number | undefined;
|
|
|
57
58
|
* the column's size. An already-integer point keeps a zero offset (unless one was given). The two
|
|
58
59
|
* lookups supply each column/row's size; a size they leave `undefined` falls back to Excel's default. */
|
|
59
60
|
export declare function resolveAnchorPoint(point: AnchorPoint, columnWidth: ColumnWidthLookup, rowHeight: RowHeightLookup): AnchorPoint;
|
|
60
|
-
/**
|
|
61
|
-
|
|
61
|
+
/**
|
|
62
|
+
* How much of a picture is cut away at each edge, as a fraction of the picture's own size: `0.1` crops
|
|
63
|
+
* a tenth, and a negative value pads the picture out. An absent edge is not cropped.
|
|
64
|
+
*/
|
|
65
|
+
export interface ImageCrop {
|
|
66
|
+
readonly left?: number;
|
|
67
|
+
readonly top?: number;
|
|
68
|
+
readonly right?: number;
|
|
69
|
+
readonly bottom?: number;
|
|
70
|
+
}
|
|
71
|
+
/** Where clicking a picture goes: a URL, or a `#`-prefixed place in this workbook (`#Sheet1!C3`), as a
|
|
72
|
+
* sheet hyperlink's `target` spells one. */
|
|
73
|
+
export interface ImageHyperlink {
|
|
74
|
+
readonly target: string;
|
|
75
|
+
/** The text shown when the pointer rests on the picture. */
|
|
76
|
+
readonly tooltip?: string;
|
|
77
|
+
}
|
|
78
|
+
/** What a picture says about itself beyond which image it shows and where. */
|
|
79
|
+
export interface PictureProperties {
|
|
80
|
+
/** Alternative text: what a screen reader says in place of the picture. */
|
|
81
|
+
readonly description?: string;
|
|
82
|
+
/** The picture's title, shown with its alternative text. */
|
|
83
|
+
readonly title?: string;
|
|
84
|
+
readonly crop?: ImageCrop;
|
|
85
|
+
readonly hyperlink?: ImageHyperlink;
|
|
86
|
+
}
|
|
87
|
+
/** An image pinned to a worksheet: which workbook media it shows (`imageId`), where, and the picture's
|
|
88
|
+
* own properties. */
|
|
89
|
+
export interface AnchoredImage extends PictureProperties {
|
|
62
90
|
/** Index into the workbook's media registry (the id {@link Workbook.addImage} returned). */
|
|
63
91
|
readonly imageId: number;
|
|
64
92
|
readonly anchor: ImageAnchor;
|
|
65
93
|
}
|
|
94
|
+
/** The {@link PictureProperties} a value carries, and nothing else, so an image can be re-pinned or carried
|
|
95
|
+
* to another workbook without its alternative text, crop or link being left behind. */
|
|
96
|
+
export declare function pictureProperties(picture: PictureProperties): PictureProperties;
|
|
66
97
|
/** A picture's bytes and its file kind, as held in the workbook's media registry. */
|
|
67
98
|
export interface WorkbookImage {
|
|
68
99
|
/** Lower-case file extension without a dot: `"png"`, `"jpeg"`, `"gif"`. Drives the media part's
|
|
@@ -85,7 +116,7 @@ export declare function normalizeImageExtension(extension: string | undefined, d
|
|
|
85
116
|
* itself is what lets an anchor cross that boundary, which is why the transfer form carries bytes
|
|
86
117
|
* where the stored form carries an id.
|
|
87
118
|
*/
|
|
88
|
-
export interface PortableImage {
|
|
119
|
+
export interface PortableImage extends PictureProperties {
|
|
89
120
|
readonly image: WorkbookImage;
|
|
90
121
|
readonly anchor: ImageAnchor;
|
|
91
122
|
}
|
|
@@ -99,15 +130,19 @@ export interface WorksheetImages {
|
|
|
99
130
|
readonly background: WorkbookImage | undefined;
|
|
100
131
|
}
|
|
101
132
|
/**
|
|
102
|
-
*
|
|
133
|
+
* A picture's content identity as a map key: its kind, its length, and a digest of its bytes.
|
|
134
|
+
*
|
|
135
|
+
* **Content-addressed, not reference-addressed.** Two byte-identical pictures are one picture,
|
|
136
|
+
* however they reached the registry. That is what keeps repeated imports from growing the media list
|
|
137
|
+
* without bound, so the same logo carried onto twenty sheets registers once, and it is why identity
|
|
138
|
+
* cannot be object identity: a picture arriving from another workbook would never satisfy that.
|
|
103
139
|
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* workbook would never satisfy.
|
|
140
|
+
* **A key rather than a scan**, which is the part that changed. The comparison used to walk the whole
|
|
141
|
+
* media list byte by byte per candidate, and importing a sheet's pictures asks it once per anchored
|
|
142
|
+
* image, so merging a workbook of fifty distinct megabyte images compared bytes fifty times over
|
|
143
|
+
* fifty candidates. The workbook indexes each picture as it is registered instead.
|
|
109
144
|
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
145
|
+
* SHA-512 rather than a cheap checksum because a collision here silently substitutes one picture for
|
|
146
|
+
* another; the length is in the key as well, so a collision would have to match that too.
|
|
112
147
|
*/
|
|
113
|
-
export declare function
|
|
148
|
+
export declare function imageContentKey(image: WorkbookImage): string;
|
package/dist/core/image.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { hex } from '../hex.js';
|
|
2
|
+
import { sha512 } from '../sha512.js';
|
|
1
3
|
import { tokenSet } from '../token-set.js';
|
|
2
4
|
export const PX_TO_EMU = 9525;
|
|
3
5
|
export const isImageEditAs = tokenSet({ oneCell: true, twoCell: true, absolute: true });
|
|
@@ -17,6 +19,15 @@ export function resolveAnchorPoint(point, columnWidth, rowHeight) {
|
|
|
17
19
|
const rowOff = (point.rowOff ?? 0) + Math.round((point.row - row) * rowHeightEmu);
|
|
18
20
|
return { col, row, colOff, rowOff };
|
|
19
21
|
}
|
|
22
|
+
export function pictureProperties(picture) {
|
|
23
|
+
const { description, title, crop, hyperlink } = picture;
|
|
24
|
+
return {
|
|
25
|
+
...(description === undefined ? {} : { description }),
|
|
26
|
+
...(title === undefined ? {} : { title }),
|
|
27
|
+
...(crop === undefined ? {} : { crop: { ...crop } }),
|
|
28
|
+
...(hyperlink === undefined ? {} : { hyperlink: { ...hyperlink } }),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
20
31
|
const IMAGE_MAGIC = [
|
|
21
32
|
{ ext: 'png', sig: [0x89, 0x50, 0x4e, 0x47] },
|
|
22
33
|
{ ext: 'jpeg', sig: [0xff, 0xd8, 0xff] },
|
|
@@ -40,9 +51,9 @@ export function normalizeImageExtension(extension, data) {
|
|
|
40
51
|
}
|
|
41
52
|
return sniffImageExtension(data);
|
|
42
53
|
}
|
|
43
|
-
export function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return
|
|
54
|
+
export function imageContentKey(image) {
|
|
55
|
+
let digest = '';
|
|
56
|
+
for (const byte of sha512(image.data))
|
|
57
|
+
digest += hex(byte, 2);
|
|
58
|
+
return `${image.extension}:${image.data.length}:${digest}`;
|
|
48
59
|
}
|
package/dist/core/internal.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Keys the
|
|
3
|
-
* `WorksheetInternals`, declared beside their classes).
|
|
2
|
+
* Keys the operations the library's own machinery may perform on a published class and a caller may
|
|
3
|
+
* not (see `WorkbookInternals` / `WorksheetInternals`, declared beside their classes).
|
|
4
|
+
*
|
|
5
|
+
* Not only the model: `WorksheetStreamWriter` hangs its construction and its row-flush plumbing off
|
|
6
|
+
* the same key, on the static side and the instance side respectively, because that class has the
|
|
7
|
+
* identical problem one layer up. Its constructor took the writer's style registry and its
|
|
8
|
+
* `flushedSheet()` returned the writer's flushed-row record, so seven internal types were named by a
|
|
9
|
+
* published signature and none of them was a type a consumer could write down. `StreamedRow` is
|
|
10
|
+
* constructed through the same static key, because a row built outside its writer could commit, and
|
|
11
|
+
* so evict, a row number that writer never handed out.
|
|
4
12
|
*/
|
|
5
13
|
export declare const INTERNAL: unique symbol;
|
|
6
14
|
/**
|
package/dist/core/limits.d.ts
CHANGED
|
@@ -28,3 +28,28 @@ export declare const MAX_ROW_HEIGHT = 409.5;
|
|
|
28
28
|
* value for it is a bug rather than a shortcut.
|
|
29
29
|
*/
|
|
30
30
|
export declare const MAX_COLUMN_WIDTH = 255;
|
|
31
|
+
/**
|
|
32
|
+
* The longest sheet name Excel accepts, in UTF-16 code units. A longer one is refused outright rather
|
|
33
|
+
* than truncated: a truncated name silently collides with its neighbours.
|
|
34
|
+
*/
|
|
35
|
+
export declare const MAX_SHEET_NAME_LENGTH = 31;
|
|
36
|
+
/**
|
|
37
|
+
* The characters Excel forbids anywhere in a sheet name. A name may also not begin or end with an
|
|
38
|
+
* apostrophe, which this pattern does not express because the position is what makes it illegal: a
|
|
39
|
+
* sheet-qualified reference quotes the name with apostrophes, so one at either edge cannot be told
|
|
40
|
+
* from the quoting.
|
|
41
|
+
*/
|
|
42
|
+
export declare const INVALID_SHEET_NAME_CHARS: RegExp;
|
|
43
|
+
/** The longest table name Excel accepts, in UTF-16 code units. */
|
|
44
|
+
export declare const MAX_TABLE_NAME_LENGTH = 255;
|
|
45
|
+
/**
|
|
46
|
+
* Excel's table-name grammar: start with a letter, underscore, or backslash; every later character a
|
|
47
|
+
* letter, digit, period, or underscore. Unicode letters and digits are allowed.
|
|
48
|
+
*
|
|
49
|
+
* The pattern is the grammar only. Excel also refuses a name that reads as a reference: an A1 cell on
|
|
50
|
+
* the grid (`T1`), an R1C1 reference (`R`, `C`, `RC`, `R1C1`, `R1X`), or `TRUE`/`FALSE`, in any case.
|
|
51
|
+
* No regular expression states that honestly, because "on the grid" is a bound on the column letters
|
|
52
|
+
* and the row number, so `Worksheet.addTable` checks it separately and a name passing this pattern
|
|
53
|
+
* can still be refused.
|
|
54
|
+
*/
|
|
55
|
+
export declare const TABLE_NAME_PATTERN: RegExp;
|
package/dist/core/limits.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export const MAX_ROW_HEIGHT = 409.5;
|
|
2
2
|
export const MAX_COLUMN_WIDTH = 255;
|
|
3
|
+
export const MAX_SHEET_NAME_LENGTH = 31;
|
|
4
|
+
export const INVALID_SHEET_NAME_CHARS = /[*?:\\/[\]]/;
|
|
5
|
+
export const MAX_TABLE_NAME_LENGTH = 255;
|
|
6
|
+
export const TABLE_NAME_PATTERN = /^[\p{L}\\_][\p{L}\p{N}._]*$/u;
|
package/dist/core/merge.d.ts
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import { type GridRect } from './address.ts';
|
|
2
2
|
import type { Cell } from './cell.ts';
|
|
3
|
+
import { type AxisSplice } from './grid-shift.ts';
|
|
3
4
|
/** A merged region, as the {@link GridRect} every range-shaped thing in the library is. */
|
|
4
5
|
export type MergeRect = GridRect;
|
|
6
|
+
/**
|
|
7
|
+
* Each merged range that overlaps a table, paired with the first table it overlaps. Excel forbids a
|
|
8
|
+
* merge inside a table: the writer refuses that geometry and the reader drops the merge, the repair
|
|
9
|
+
* Excel makes on load. Both used to spell the overlap test out by hand. The answer is a list of its
|
|
10
|
+
* own, so the reader can unmerge while it walks it rather than the live `sheet.merges`. An unbounded
|
|
11
|
+
* whole-row/column merge carries no rectangle and overlaps nothing.
|
|
12
|
+
*/
|
|
13
|
+
export declare function mergesOverlappingTables<T extends {
|
|
14
|
+
readonly region: GridRect;
|
|
15
|
+
}>(merges: readonly string[], tables: readonly T[]): {
|
|
16
|
+
readonly merge: string;
|
|
17
|
+
readonly table: T;
|
|
18
|
+
}[];
|
|
5
19
|
/**
|
|
6
20
|
* Drop any value already sitting in a merge's covered non-anchor cells, keeping only the top-left
|
|
7
21
|
* anchor, the collapse Excel performs on merge. A leftover covered value would serialise as a
|
|
@@ -15,12 +29,12 @@ export declare function clearCoveredValues(rows: Map<number, Map<number, Cell>>,
|
|
|
15
29
|
* that can exist contributes no rectangle, the reader's rule for every other foreign attribute. */
|
|
16
30
|
export declare function decodeSqrefRects(sqref: string): MergeRect[];
|
|
17
31
|
/**
|
|
18
|
-
* Re-anchor an OOXML `sqref` through a splice
|
|
19
|
-
*
|
|
20
|
-
*
|
|
32
|
+
* Re-anchor an OOXML `sqref` through a splice, the inverse of {@link decodeSqrefRects}. Returns
|
|
33
|
+
* `undefined` when the splice deleted every area the `sqref` named: an empty `sqref` is not
|
|
34
|
+
* writable, so the entry holding it goes too.
|
|
21
35
|
*
|
|
22
36
|
* Each space-separated area shifts on its own, and one the splice does not move is returned as the
|
|
23
37
|
* *original text*. That matters for a file the library did not author: `B:B` and `B1:B1048576` decode
|
|
24
38
|
* identically, so a re-encode would rewrite a foreign spelling and cost the byte-clean round trip.
|
|
25
39
|
*/
|
|
26
|
-
export declare function shiftSqref(sqref: string,
|
|
40
|
+
export declare function shiftSqref(sqref: string, splice: AxisSplice): string | undefined;
|
package/dist/core/merge.js
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
|
-
import { encodeCornerRef, tryDecodeRange } from './address.js';
|
|
2
|
-
import {
|
|
1
|
+
import { boundedRect, decodeRange, encodeCornerRef, rectsOverlap, tryDecodeRange, } from './address.js';
|
|
2
|
+
import { shiftSpan } from './grid-shift.js';
|
|
3
|
+
export function mergesOverlappingTables(merges, tables) {
|
|
4
|
+
const overlapping = [];
|
|
5
|
+
if (tables.length === 0)
|
|
6
|
+
return overlapping;
|
|
7
|
+
for (const merge of merges) {
|
|
8
|
+
const rect = boundedRect(decodeRange(merge));
|
|
9
|
+
if (rect === undefined)
|
|
10
|
+
continue;
|
|
11
|
+
const table = tables.find((candidate) => rectsOverlap(rect, candidate.region));
|
|
12
|
+
if (table !== undefined)
|
|
13
|
+
overlapping.push({ merge, table });
|
|
14
|
+
}
|
|
15
|
+
return overlapping;
|
|
16
|
+
}
|
|
3
17
|
export function clearCoveredValues(rows, rect) {
|
|
4
|
-
for (
|
|
5
|
-
|
|
6
|
-
if (cols === undefined)
|
|
18
|
+
for (const [row, cols] of rows) {
|
|
19
|
+
if (row < rect.top || row > rect.bottom)
|
|
7
20
|
continue;
|
|
8
|
-
for (
|
|
21
|
+
for (const [col, covered] of cols) {
|
|
22
|
+
if (col < rect.left || col > rect.right)
|
|
23
|
+
continue;
|
|
9
24
|
if (row === rect.top && col === rect.left)
|
|
10
25
|
continue;
|
|
11
|
-
|
|
12
|
-
if (covered !== undefined)
|
|
13
|
-
covered.value = null;
|
|
26
|
+
covered.value = null;
|
|
14
27
|
}
|
|
15
28
|
}
|
|
16
29
|
}
|
|
@@ -32,33 +45,33 @@ export function decodeSqrefRects(sqref) {
|
|
|
32
45
|
}
|
|
33
46
|
return rects;
|
|
34
47
|
}
|
|
35
|
-
export function shiftSqref(sqref,
|
|
48
|
+
export function shiftSqref(sqref, splice) {
|
|
36
49
|
const areas = [];
|
|
37
50
|
for (const area of sqref.split(/\s+/)) {
|
|
38
51
|
if (area === '')
|
|
39
52
|
continue;
|
|
40
|
-
const shifted = shiftSqrefArea(area,
|
|
53
|
+
const shifted = shiftSqrefArea(area, splice);
|
|
41
54
|
if (shifted !== undefined)
|
|
42
55
|
areas.push(shifted);
|
|
43
56
|
}
|
|
44
57
|
return areas.length > 0 ? areas.join(' ') : undefined;
|
|
45
58
|
}
|
|
46
|
-
function shiftSqrefArea(area,
|
|
59
|
+
function shiftSqrefArea(area, splice) {
|
|
47
60
|
const decoded = tryDecodeRange(area);
|
|
48
61
|
if (decoded === undefined)
|
|
49
62
|
return area;
|
|
50
63
|
const { top, left, bottom, right } = decoded;
|
|
51
|
-
const
|
|
64
|
+
const rowAxis = splice.axis === 'row';
|
|
65
|
+
const [lo, hi] = rowAxis ? [top, bottom] : [left, right];
|
|
52
66
|
if (lo === undefined || hi === undefined)
|
|
53
67
|
return area;
|
|
54
|
-
|
|
68
|
+
const moved = shiftSpan(lo, hi, splice);
|
|
69
|
+
if (moved === undefined)
|
|
55
70
|
return undefined;
|
|
56
|
-
|
|
57
|
-
const movedHi = shiftIndex(hi, start, count, delta, axis);
|
|
58
|
-
if (movedLo === lo && movedHi === hi)
|
|
71
|
+
if (moved.lo === lo && moved.hi === hi)
|
|
59
72
|
return area;
|
|
60
|
-
const [tl, br] =
|
|
61
|
-
? [encodeCornerRef(left,
|
|
62
|
-
: [encodeCornerRef(
|
|
73
|
+
const [tl, br] = rowAxis
|
|
74
|
+
? [encodeCornerRef(left, moved.lo), encodeCornerRef(right, moved.hi)]
|
|
75
|
+
: [encodeCornerRef(moved.lo, top), encodeCornerRef(moved.hi, bottom)];
|
|
63
76
|
return area.includes(':') ? `${tl}:${br}` : tl;
|
|
64
77
|
}
|
|
@@ -60,13 +60,18 @@ export type PageSetupFacet = {
|
|
|
60
60
|
readonly key: 'paperSize' | 'scale' | 'fitToWidth' | 'fitToHeight';
|
|
61
61
|
/** A non-negative integer: a page count, a percentage, or a paper-size id. */
|
|
62
62
|
readonly kind: 'count';
|
|
63
|
-
} |
|
|
64
|
-
|
|
63
|
+
} | PageSetupTokenFacet<'pageOrder', PageOrder> | PageSetupTokenFacet<'orientation', PageOrientation>;
|
|
64
|
+
/**
|
|
65
|
+
* An enumerated `<pageSetup>` attribute. One entry per key, each with a guard that narrows to that
|
|
66
|
+
* key's own union, so a reader holding the entry can assign what the guard accepted without a cast.
|
|
67
|
+
*/
|
|
68
|
+
interface PageSetupTokenFacet<K extends keyof PageSetup, T extends string> {
|
|
69
|
+
readonly key: K;
|
|
65
70
|
readonly kind: 'token';
|
|
66
71
|
/** The enumeration guard, and what to call it in the error when a value fails it. */
|
|
67
|
-
readonly isValid: (value: string) =>
|
|
72
|
+
readonly isValid: (value: string) => value is T;
|
|
68
73
|
readonly label: string;
|
|
69
|
-
}
|
|
74
|
+
}
|
|
70
75
|
/**
|
|
71
76
|
* The six `<pageSetup>` attributes, declared once, in CT_PageSetup order. Both directions key off
|
|
72
77
|
* this list, so an attribute written but not read (it survives a re-write and vanishes on load) or
|
|
@@ -127,17 +132,26 @@ export declare const PRINT_OPTION_FLAGS: readonly ["horizontalCentered", "vertic
|
|
|
127
132
|
/** Compile-time proof that {@link PRINT_OPTION_FLAGS} covers every {@link PrintOptions} flag. */
|
|
128
133
|
export type EveryPrintOptionFlagIsDeclared = AssertNever<Exclude<keyof PrintOptions, (typeof PRINT_OPTION_FLAGS)[number]>>;
|
|
129
134
|
/**
|
|
130
|
-
* A
|
|
131
|
-
* column break
|
|
132
|
-
*
|
|
133
|
-
*
|
|
135
|
+
* A page break (`<brk>`). It falls after line `id` and before line `id + 1`, rows for a row break and
|
|
136
|
+
* columns for a column break, which is how Excel counts it: a break Excel shows above row 20 is saved
|
|
137
|
+
* as `id="19"`. `min` and `max` bound its extent across the other axis, zero-based, and Excel writes
|
|
138
|
+
* only the whole axis (`max` 16383 for a row break). `man` marks an author-set break rather than one
|
|
139
|
+
* a producer recorded as automatic. The model keeps whatever the source carried.
|
|
140
|
+
*
|
|
141
|
+
* A row or column splice moves a break with the line after it and drops the break when that line is
|
|
142
|
+
* deleted, which is what Excel Desktop does: driven over COM, a manual break above row 10 moved above
|
|
143
|
+
* row 11 when a row was inserted at row 1, and went away when row 11 was then deleted, and a column
|
|
144
|
+
* break moved the same way. The extent is not moved, because the only one Excel writes is the whole
|
|
145
|
+
* axis, and a splice should leave that whole rather than shorten it by the lines it removed.
|
|
134
146
|
*/
|
|
135
147
|
export interface PageBreak {
|
|
136
|
-
/** The row (or column) the break
|
|
148
|
+
/** The last row (or column) before the break. */
|
|
137
149
|
readonly id: number;
|
|
138
|
-
/** The break's
|
|
150
|
+
/** The break's near extent across the other axis, zero-based, if the source declared one. */
|
|
151
|
+
readonly min?: number;
|
|
152
|
+
/** The break's far extent across the other axis, zero-based, if the source declared one. */
|
|
139
153
|
readonly max?: number;
|
|
140
|
-
/**
|
|
154
|
+
/** Whether the break is manual. A break without it is written as a manual one: Excel stores no other kind. */
|
|
141
155
|
readonly man?: boolean;
|
|
142
156
|
}
|
|
143
157
|
/**
|
|
@@ -176,3 +190,4 @@ export interface HeaderFooter {
|
|
|
176
190
|
export declare const HEADER_FOOTER_ELEMENTS: readonly ["oddHeader", "oddFooter", "evenHeader", "evenFooter", "firstHeader", "firstFooter"];
|
|
177
191
|
/** Compile-time proof that {@link HEADER_FOOTER_ELEMENTS} covers every {@link HeaderFooter} slot. */
|
|
178
192
|
export type EveryHeaderFooterElementIsDeclared = AssertNever<Exclude<keyof HeaderFooter, (typeof HEADER_FOOTER_ELEMENTS)[number]>>;
|
|
193
|
+
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type SheetSplice } from './formula-references.ts';
|
|
2
|
+
import { INTERNAL } from './internal.ts';
|
|
1
3
|
import type { Worksheet } from './worksheet.ts';
|
|
2
4
|
/** The aggregation a pivot's value field applies. These are OOXML's `ST_DataConsolidateFunction`
|
|
3
5
|
* names verbatim, so a metric doubles as its `<dataField subtotal="…">` value. Excel performs the
|
|
@@ -27,13 +29,20 @@ export interface ParsedPivotSource {
|
|
|
27
29
|
readonly kind: PivotSourceKind;
|
|
28
30
|
readonly sheet: string;
|
|
29
31
|
readonly ref: string;
|
|
32
|
+
/**
|
|
33
|
+
* Whether {@link sheet} and {@link ref} name a range in another workbook, which the cache reaches
|
|
34
|
+
* through a relationship. A row or column splice of this workbook moves the source of a pivot drawing
|
|
35
|
+
* from one of its own sheets, as Excel does, and never one of these.
|
|
36
|
+
*/
|
|
37
|
+
readonly inAnotherWorkbook: boolean;
|
|
30
38
|
}
|
|
31
39
|
/** The semantic model reconstructed from a loaded pivot's `pivotTableDefinition` and its
|
|
32
40
|
* `pivotCacheDefinition` (see `io/xlsx/read-pivot.ts`). Field roles are indices into {@link fields};
|
|
33
41
|
* {@link metric} is the aggregation the value field applies. This mirrors the authoring model's shape
|
|
34
42
|
* without requiring the source sheet it was built from, so a pivot loaded from a package is
|
|
35
43
|
* inspectable data rather than an opaque preserved blob. It is a read-only view: the writer emits a
|
|
36
|
-
* loaded pivot from its preserved parts, not from this model, so exposing it never double-emits.
|
|
44
|
+
* loaded pivot from its preserved parts, not from this model, so exposing it never double-emits. A
|
|
45
|
+
* splice of the source sheet moves the source range in both, by {@link splicePivotSource}. */
|
|
37
46
|
export interface ParsedPivotTable {
|
|
38
47
|
readonly name: string;
|
|
39
48
|
readonly cacheId: string;
|
|
@@ -49,7 +58,8 @@ export interface ParsedPivotTable {
|
|
|
49
58
|
readonly metric: PivotMetric;
|
|
50
59
|
}
|
|
51
60
|
/** How a pivot table is authored: a source sheet and the header names that drive each axis.
|
|
52
|
-
* `rows`/`columns`/`values` name columns by their header text in the source's first row
|
|
61
|
+
* `rows`/`columns`/`values` name columns by their header text in the source's first row, ignoring
|
|
62
|
+
* case, as the headers themselves must be unique ignoring case. */
|
|
53
63
|
export interface PivotTableOptions {
|
|
54
64
|
readonly source: Worksheet;
|
|
55
65
|
readonly rows: readonly string[];
|
|
@@ -68,20 +78,25 @@ export type PivotItem = {
|
|
|
68
78
|
} | {
|
|
69
79
|
readonly kind: 'blank';
|
|
70
80
|
};
|
|
71
|
-
/** The
|
|
81
|
+
/** The range and integrality of the numbers a cache field holds, which Excel records beside them. */
|
|
72
82
|
export interface PivotNumericSummary {
|
|
73
83
|
readonly allInteger: boolean;
|
|
74
84
|
readonly min: number;
|
|
75
85
|
readonly max: number;
|
|
76
86
|
}
|
|
77
87
|
/** One field of the pivot cache. An axis field (row or column) carries a `sharedItems` catalogue its
|
|
78
|
-
* records reference by index; any other field stores its values inline in the records
|
|
79
|
-
*
|
|
88
|
+
* records reference by index; any other field stores its values inline in the records. Either way the
|
|
89
|
+
* cache describes which kinds of value the field holds, because Excel reads the catalogue against that
|
|
90
|
+
* description: a catalogue of numbers that does not say it holds numbers opens with the repair prompt. */
|
|
80
91
|
export interface PivotCacheField {
|
|
81
92
|
readonly name: string;
|
|
82
93
|
readonly sharedItems: readonly PivotItem[] | null;
|
|
83
|
-
|
|
94
|
+
/** Whether any value is a string. */
|
|
95
|
+
readonly containsString: boolean;
|
|
96
|
+
/** Whether any value is missing. */
|
|
84
97
|
readonly containsBlank: boolean;
|
|
98
|
+
/** The field's numbers, summarised, or `null` when it holds none. */
|
|
99
|
+
readonly numeric: PivotNumericSummary | null;
|
|
85
100
|
}
|
|
86
101
|
/** One cell of a cache record: an index into a shared-items catalogue, or an inline value. */
|
|
87
102
|
export type PivotRecordCell = {
|
|
@@ -93,14 +108,15 @@ export type PivotRecordCell = {
|
|
|
93
108
|
* the full cache (fields + records) and the axis-field wiring the renderer needs; nothing here
|
|
94
109
|
* touches XML.
|
|
95
110
|
*
|
|
96
|
-
* Supported shape:
|
|
97
|
-
*
|
|
111
|
+
* Supported shape: at least one row field and one column field, each source field on at most one
|
|
112
|
+
* axis and at most once, over a header row whose names are unique ignoring case; and exactly one value
|
|
113
|
+
* field, aggregated by any {@link PivotMetric} (`sum` by default), which may also be an axis field. An
|
|
114
|
+
* unsupported request throws at authoring time rather than emitting a corrupt file.
|
|
98
115
|
*/
|
|
99
116
|
export declare class PivotTable {
|
|
117
|
+
#private;
|
|
100
118
|
readonly metric: PivotMetric;
|
|
101
119
|
readonly sourceSheetName: string;
|
|
102
|
-
/** The `A1:C4` source range: the header row through the last data row, across the field columns. */
|
|
103
|
-
readonly sourceRef: string;
|
|
104
120
|
readonly cacheFields: readonly PivotCacheField[];
|
|
105
121
|
readonly records: readonly (readonly PivotRecordCell[])[];
|
|
106
122
|
/** Indices into {@link cacheFields} of the row-axis, column-axis, and value fields. */
|
|
@@ -108,6 +124,29 @@ export declare class PivotTable {
|
|
|
108
124
|
readonly columnFields: readonly number[];
|
|
109
125
|
readonly valueField: number;
|
|
110
126
|
constructor(options: PivotTableOptions);
|
|
127
|
+
/**
|
|
128
|
+
* The `A1:C4` source range: the header row through the last data row, across the field columns.
|
|
129
|
+
*
|
|
130
|
+
* It moves with a row or column splice of the source sheet, as Excel moves a pivot's source: an
|
|
131
|
+
* insert inside it grows it and a delete shrinks it, while a delete that takes the whole range leaves
|
|
132
|
+
* it as it was. The cache captured at construction does not change; Excel rebuilds it from this range
|
|
133
|
+
* when it opens the file.
|
|
134
|
+
*/
|
|
135
|
+
get sourceRef(): string;
|
|
136
|
+
/** What a splice does to the pivot's source; see `core/internal.ts`. */
|
|
137
|
+
readonly [INTERNAL]: PivotTableInternals;
|
|
111
138
|
/** The value field's header name, used to label the aggregated data column ("Sum of Amount"). */
|
|
112
139
|
get valueFieldName(): string;
|
|
113
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* A pivot's worksheet source range on `sheet`, moved through a splice as Excel moves it: grown by an
|
|
143
|
+
* insert inside it, shrunk by a delete, and left as it was by a delete that takes every row or every
|
|
144
|
+
* column of it, which Excel does not turn into `#REF!`. A splice of another sheet leaves it too. The one
|
|
145
|
+
* rule for an authored pivot, a loaded pivot's view, and the preserved cache the writer edits.
|
|
146
|
+
*/
|
|
147
|
+
export declare function splicePivotSource(sheet: string, ref: string, edit: SheetSplice): string;
|
|
148
|
+
/** What the library's own machinery may do to a {@link PivotTable}; reached as `pivot[INTERNAL]`. */
|
|
149
|
+
export interface PivotTableInternals {
|
|
150
|
+
/** Move the source range through a row or column splice, when the splice is of the source sheet. */
|
|
151
|
+
spliceSource(edit: SheetSplice): void;
|
|
152
|
+
}
|