@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
package/dist/core/style.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ClonePlan } from './clone.ts';
|
|
2
|
+
import { type AssertNever, NAMED_STYLE_ID } from './internal.ts';
|
|
2
3
|
/** Underline can be a plain flag or one of Excel's named underline styles. */
|
|
3
4
|
export type UnderlineStyle = boolean | 'none' | 'single' | 'double' | 'singleAccounting' | 'doubleAccounting';
|
|
4
5
|
/** Narrow a raw `<u val>` token to a named {@link UnderlineStyle} (the non-boolean members). */
|
|
@@ -36,11 +37,35 @@ export interface Color {
|
|
|
36
37
|
*/
|
|
37
38
|
export declare function parseArgb(value: string): string | undefined;
|
|
38
39
|
/**
|
|
39
|
-
* Fill pattern kinds,
|
|
40
|
+
* Fill pattern kinds, in the order OOXML's `ST_PatternType` enumerates them. `none` is the
|
|
40
41
|
* absence of a fill; `solid` paints the whole cell with the foreground colour (the
|
|
41
42
|
* common case). The remaining hatch patterns are carried for fidelity on read.
|
|
43
|
+
*
|
|
44
|
+
* The order is load-bearing rather than cosmetic, which is why it is stated twice over -- here, and
|
|
45
|
+
* in {@link FILL_PATTERNS_IN_SCHEMA_ORDER}, tied together by a proof. BIFF12 stores a pattern as its
|
|
46
|
+
* *index* into this enumeration, so the binary codec needs the sequence as a value; the doc above
|
|
47
|
+
* this type used to claim schema order while the union put `gray125` and `gray0625` at positions 2
|
|
48
|
+
* and 6, where the schema puts them last, and the binary codec carried a third copy that was right.
|
|
49
|
+
*/
|
|
50
|
+
export type FillPatternType = 'none' | 'solid' | 'mediumGray' | 'darkGray' | 'lightGray' | 'darkHorizontal' | 'darkVertical' | 'darkDown' | 'darkUp' | 'darkGrid' | 'darkTrellis' | 'lightHorizontal' | 'lightVertical' | 'lightDown' | 'lightUp' | 'lightGrid' | 'lightTrellis' | 'gray125' | 'gray0625';
|
|
51
|
+
/**
|
|
52
|
+
* Every {@link FillPatternType}, in `ST_PatternType` order, which is also the order BIFF12's `fls`
|
|
53
|
+
* field indexes: `fls` 1 is `solid`, 2 is `mediumGray`, and so on. Index 0 is `none`, which the
|
|
54
|
+
* model spells as no fill at all rather than as a pattern.
|
|
55
|
+
*
|
|
56
|
+
* One list, consulted by the guard below and by `io/xlsb/read-styles.ts`. It replaced three
|
|
57
|
+
* hand-maintained copies of one enumeration -- the union, the guard's own table, and the binary
|
|
58
|
+
* codec's index array -- of which only the first two were checked against each other, so adding a
|
|
59
|
+
* pattern forced the guard to be updated and let the binary codec silently drop it.
|
|
42
60
|
*/
|
|
43
|
-
export
|
|
61
|
+
export declare const FILL_PATTERNS_IN_SCHEMA_ORDER: readonly ["none", "solid", "mediumGray", "darkGray", "lightGray", "darkHorizontal", "darkVertical", "darkDown", "darkUp", "darkGrid", "darkTrellis", "lightHorizontal", "lightVertical", "lightDown", "lightUp", "lightGrid", "lightTrellis", "gray125", "gray0625"];
|
|
62
|
+
/**
|
|
63
|
+
* The two halves of the proof {@link FILL_PATTERNS_IN_SCHEMA_ORDER} owes, since a list -- unlike the
|
|
64
|
+
* `Record` shape every other token guard here is built from -- can name fewer members than its union
|
|
65
|
+
* without the compiler minding. `satisfies` above covers "no invented name"; this covers "no
|
|
66
|
+
* omission".
|
|
67
|
+
*/
|
|
68
|
+
export type EveryFillPatternIsOrdered = AssertNever<Exclude<FillPatternType, (typeof FILL_PATTERNS_IN_SCHEMA_ORDER)[number]>>;
|
|
44
69
|
/** Narrow a raw `<patternFill patternType>` token to a known {@link FillPatternType}. */
|
|
45
70
|
export declare const isFillPatternType: (value: string) => value is FillPatternType;
|
|
46
71
|
/**
|
|
@@ -79,6 +104,18 @@ export interface GradientFill {
|
|
|
79
104
|
}
|
|
80
105
|
/** A cell/row background fill: a flat pattern or a colour gradient. */
|
|
81
106
|
export type Fill = PatternFill | GradientFill;
|
|
107
|
+
declare const GRADIENT_STOP_CLONE: ClonePlan<GradientStop>;
|
|
108
|
+
/** The proof that {@link GRADIENT_STOP_CLONE} names every field of a gradient stop. */
|
|
109
|
+
export type EveryGradientStopFieldIsCloned = AssertNever<Exclude<keyof Required<GradientStop>, keyof typeof GRADIENT_STOP_CLONE>>;
|
|
110
|
+
declare const PATTERN_FILL_CLONE: ClonePlan<PatternFill>;
|
|
111
|
+
/** The proof that {@link PATTERN_FILL_CLONE} names every field of a pattern fill. */
|
|
112
|
+
export type EveryPatternFillFieldIsCloned = AssertNever<Exclude<keyof Required<PatternFill>, keyof typeof PATTERN_FILL_CLONE>>;
|
|
113
|
+
declare const GRADIENT_FILL_CLONE: ClonePlan<GradientFill>;
|
|
114
|
+
/** The proof that {@link GRADIENT_FILL_CLONE} names every field of a gradient fill. */
|
|
115
|
+
export type EveryGradientFillFieldIsCloned = AssertNever<Exclude<keyof Required<GradientFill>, keyof typeof GRADIENT_FILL_CLONE>>;
|
|
116
|
+
/** A defensive deep copy of a fill, whichever of the two shapes it is. The union is dispatched on
|
|
117
|
+
* `type` because the two halves share no field beyond it, so one plan could not describe both. */
|
|
118
|
+
export declare function cloneFill(fill: Fill): Fill;
|
|
82
119
|
/**
|
|
83
120
|
* Line styles a cell border edge can take, as OOXML's `ST_BorderStyle` enumerates them.
|
|
84
121
|
* `none` is the absence of an edge and is expressed by omitting the edge, not by this value.
|
|
@@ -106,6 +143,14 @@ export interface Border {
|
|
|
106
143
|
readonly diagonalUp?: boolean;
|
|
107
144
|
readonly diagonalDown?: boolean;
|
|
108
145
|
}
|
|
146
|
+
declare const BORDER_EDGE_CLONE: ClonePlan<BorderEdge>;
|
|
147
|
+
/** The proof that {@link BORDER_EDGE_CLONE} names every field of a border edge. */
|
|
148
|
+
export type EveryBorderEdgeFieldIsCloned = AssertNever<Exclude<keyof Required<BorderEdge>, keyof typeof BORDER_EDGE_CLONE>>;
|
|
149
|
+
declare const BORDER_CLONE: ClonePlan<Border>;
|
|
150
|
+
/** The proof that {@link BORDER_CLONE} names every side of a border. */
|
|
151
|
+
export type EveryBorderFieldIsCloned = AssertNever<Exclude<keyof Required<Border>, keyof typeof BORDER_CLONE>>;
|
|
152
|
+
/** A defensive deep copy of a border, each present edge and its colour included. */
|
|
153
|
+
export declare function cloneBorder(border: Border): Border;
|
|
109
154
|
/** Vertical alignment of a font relative to the baseline (super/subscript). */
|
|
110
155
|
export type FontVerticalAlignment = 'superscript' | 'subscript';
|
|
111
156
|
/** Narrow a raw `<vertAlign val>` token to a known {@link FontVerticalAlignment}. */
|
|
@@ -133,6 +178,11 @@ export interface Font {
|
|
|
133
178
|
readonly outline?: boolean;
|
|
134
179
|
readonly vertAlign?: FontVerticalAlignment;
|
|
135
180
|
}
|
|
181
|
+
declare const FONT_CLONE: ClonePlan<Font>;
|
|
182
|
+
/** The proof that {@link FONT_CLONE} names every facet of a font. */
|
|
183
|
+
export type EveryFontFieldIsCloned = AssertNever<Exclude<keyof Required<Font>, keyof typeof FONT_CLONE>>;
|
|
184
|
+
/** A defensive deep copy of a font, its nested colour included. */
|
|
185
|
+
export declare function cloneFont(font: Font): Font;
|
|
136
186
|
/** How a cell's content sits horizontally within its bounds, as OOXML's `ST_HorizontalAlignment`
|
|
137
187
|
* enumerates it. `general` is the type-dependent default (text left, numbers right) and reads
|
|
138
188
|
* back as no explicit horizontal alignment. */
|
|
@@ -166,7 +216,11 @@ export interface Alignment {
|
|
|
166
216
|
* Format-blind on purpose. `Alignment` is a core type and the layering gate forbids core importing a
|
|
167
217
|
* serialisation, so the table states what a facet *is* and each codec supplies the reading and the
|
|
168
218
|
* writing off the `kind`. That is where {@link SHEET_PROTECTION_FLAGS} sits and how it is consumed,
|
|
169
|
-
* and it is the shape the BIFF12 codec
|
|
219
|
+
* and it is the shape the BIFF12 codec drives off too: `io/xlsb/read-styles.ts` walks this list and
|
|
220
|
+
* looks each facet up in a `Record` keyed by {@link Alignment}, so the bit layout stays a BIFF12 fact
|
|
221
|
+
* in the BIFF12 codec while the *set* of facets is decided here, once, for both. (That sentence used
|
|
222
|
+
* to read "if alignment ever reaches it". Alignment had reached it; the comment had not noticed, and
|
|
223
|
+
* the binary reader was restating all seven facets and their default-omission rules by hand.)
|
|
170
224
|
*
|
|
171
225
|
* The OOXML attribute name is the model key for all seven facets, so it is not restated here: a
|
|
172
226
|
* second list that is always identical is a second list to keep in step. A future facet whose
|
|
@@ -234,6 +288,32 @@ export interface CellStyle {
|
|
|
234
288
|
}
|
|
235
289
|
/** The names of the {@link CellStyle} facets, for helpers that copy the tuple facet-by-facet. */
|
|
236
290
|
export declare const CELL_STYLE_FACETS: (keyof CellStyle)[];
|
|
291
|
+
/**
|
|
292
|
+
* Everything a cell's *formatting* is, which is the six {@link CellStyle} facets plus two that only a
|
|
293
|
+
* cell can carry: the quote-prefix flag and the link to a named cell style.
|
|
294
|
+
*
|
|
295
|
+
* The two extras are on the cell's `xf` record exactly as the six are, and are written and read back
|
|
296
|
+
* exactly as the six are, but they sat outside the tuple, so every copy path driven by the tuple
|
|
297
|
+
* dropped them: a splice, a `duplicateRow`, or a `dst.model = src.model` turned a leading-apostrophe
|
|
298
|
+
* text cell back into an unprefixed one. That is the merge-loss the tuple exists to make impossible,
|
|
299
|
+
* so they join it. Callers that mean "the six shared facets" (a column default, a named style, a
|
|
300
|
+
* `<dxf>`) still say {@link CellStyle}; callers copying a *cell* say this.
|
|
301
|
+
*/
|
|
302
|
+
export type CellContent = CellStyle & {
|
|
303
|
+
quotePrefix?: boolean | undefined;
|
|
304
|
+
[NAMED_STYLE_ID]?: number | undefined;
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* The names of every {@link CellContent} facet, the six shared ones first. Helpers that copy a cell's
|
|
308
|
+
* whole formatting drive off this, so a facet added to either half reaches all of them at once.
|
|
309
|
+
*/
|
|
310
|
+
export declare const CELL_CONTENT_FACETS: (keyof CellContent)[];
|
|
311
|
+
/**
|
|
312
|
+
* Copy every present facet of a cell's formatting from `source` onto `target`, leaving facets
|
|
313
|
+
* `source` omits untouched: {@link assignStyleFacets} widened to the two cell-only facets. This is
|
|
314
|
+
* what a copy of a *cell* uses, so no structural edit can drop one.
|
|
315
|
+
*/
|
|
316
|
+
export declare function assignContentFacets(target: CellContent, source: Readonly<CellContent>): void;
|
|
237
317
|
/**
|
|
238
318
|
* Copy each present facet of `source` onto `target`, leaving facets `source` omits untouched: the
|
|
239
319
|
* plain-record counterpart to a cell's `applyCellStyle`, for the {@link CellStyle}-shaped targets a
|
|
@@ -249,69 +329,4 @@ export declare function assignStyleFacets(target: CellStyle, source: Readonly<Ce
|
|
|
249
329
|
* the tuple reaches a `<col>` style without anyone remembering to widen a literal.
|
|
250
330
|
*/
|
|
251
331
|
export declare function pickStyleFacets(source: Readonly<CellStyle>): CellStyle;
|
|
252
|
-
|
|
253
|
-
* A named cell style: the OOXML `cellStyleXfs`/`cellStyles` layer. A spreadsheet applies a built-in
|
|
254
|
-
* or custom style (e.g. "Normal", "Accent1") whose visual facets live in this shared, named layer
|
|
255
|
-
* rather than on each cell's direct format; a cell links to it and inherits any facet the direct
|
|
256
|
-
* format leaves unset. The facets are a cell's own (see {@link CellStyle}); `name` is the style's
|
|
257
|
-
* display name and `builtinId` its Excel gallery index when it is a built-in style.
|
|
258
|
-
*/
|
|
259
|
-
export type NamedCellStyle = Readonly<CellStyle> & {
|
|
260
|
-
readonly name?: string;
|
|
261
|
-
readonly builtinId?: number;
|
|
262
|
-
};
|
|
263
|
-
/**
|
|
264
|
-
* A differential style (OOXML CT_Dxf): formatting laid *over* whatever a cell already carries. Only
|
|
265
|
-
* the facets present override; the rest of the cell's own style shows through. It carries the subset
|
|
266
|
-
* of the cell-style facets (see {@link CellStyle}) a `<dxf>` can express: font, number format, fill,
|
|
267
|
-
* and border.
|
|
268
|
-
*
|
|
269
|
-
* Differential styles live in one workbook-level table (`<dxfs>`) that several features index into:
|
|
270
|
-
* a conditional-formatting rule's highlight format, and a table style's per-element formatting
|
|
271
|
-
* (`<tableStyleElement dxfId="…">`). They are interned and shared, so two features asking for the
|
|
272
|
-
* same formatting land on one entry.
|
|
273
|
-
*
|
|
274
|
-
* Not every facet reaches every consumer. As a **table style element**, Excel applies only the font,
|
|
275
|
-
* fill, and border: its own object model exposes `Font`, `Interior`, and `Borders` on a table style
|
|
276
|
-
* element and nothing for a number format, so a `numFmt` set here is carried faithfully through a
|
|
277
|
-
* round-trip but has no visible effect. The type is left whole rather than split, because the same
|
|
278
|
-
* value is legitimately reused across both consumers and narrowing it would only move the surprise.
|
|
279
|
-
*/
|
|
280
|
-
export type DifferentialStyle = Pick<CellStyle, 'font' | 'numFmt' | 'fill' | 'border'>;
|
|
281
|
-
/**
|
|
282
|
-
* The `<tableStyles>` block of a styles part: the custom table/pivot style definitions a file
|
|
283
|
-
* declares, and the two gallery names it nominates as the default for a new table and a new pivot.
|
|
284
|
-
*
|
|
285
|
-
* Each entry of {@link styles} is one `<tableStyle>…</tableStyle>` fragment kept verbatim, for the
|
|
286
|
-
* same reason a `<dxf>` is: a `tableStyleElement`'s `dxfId` indexes the differential-style table,
|
|
287
|
-
* which the writer re-emits **at its original indices**, so the references stay valid without
|
|
288
|
-
* reparsing anything. That index-stability is load-bearing: renumbering the dxf table would
|
|
289
|
-
* silently re-point every preserved table style at a different format.
|
|
290
|
-
*
|
|
291
|
-
* The two default names are ordinary strings, not fragments: they are re-escaped on write, so they
|
|
292
|
-
* are held decoded.
|
|
293
|
-
*/
|
|
294
|
-
export interface TableStyleTable {
|
|
295
|
-
readonly styles: readonly string[];
|
|
296
|
-
readonly defaultTableStyle?: string | undefined;
|
|
297
|
-
readonly defaultPivotStyle?: string | undefined;
|
|
298
|
-
/**
|
|
299
|
-
* The namespace prefixes the verbatim {@link styles} fragments use, mapped to their URI and to
|
|
300
|
-
* whether the source marked the prefix ignorable (`mc:Ignorable`).
|
|
301
|
-
*
|
|
302
|
-
* Carrying a fragment verbatim carries its *prefixes* too. Excel stamps a revision id
|
|
303
|
-
* (`xr9:uid="{…}"`) on every `<tableStyle>` it writes, so a fragment re-emitted under a
|
|
304
|
-
* `<styleSheet>` that declares only the default namespace is not namespace-well-formed, and no
|
|
305
|
-
* consumer can parse the part at all, which is a far louder failure than the dropped table style
|
|
306
|
-
* this preservation exists to prevent. The writer re-declares each prefix on `<styleSheet>` and
|
|
307
|
-
* re-states the ignorable ones, exactly as the source did.
|
|
308
|
-
*/
|
|
309
|
-
readonly namespaces?: readonly TableStyleNamespace[];
|
|
310
|
-
}
|
|
311
|
-
/** One namespace declaration a preserved `<tableStyle>` fragment depends on. */
|
|
312
|
-
export interface TableStyleNamespace {
|
|
313
|
-
readonly prefix: string;
|
|
314
|
-
readonly uri: string;
|
|
315
|
-
/** Whether the source listed this prefix in the stylesheet's `mc:Ignorable`. */
|
|
316
|
-
readonly ignorable: boolean;
|
|
317
|
-
}
|
|
332
|
+
export {};
|
package/dist/core/style.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { tokenSet } from '../token-set.js';
|
|
1
|
+
import { tokenSet, tokenSetOf } from '../token-set.js';
|
|
2
|
+
import { cloneWith } from './clone.js';
|
|
3
|
+
import { copyKeyIfPresent } from './containers.js';
|
|
4
|
+
import { NAMED_STYLE_ID } from './internal.js';
|
|
2
5
|
export const isNamedUnderlineStyle = tokenSet({
|
|
3
6
|
none: true,
|
|
4
7
|
single: true,
|
|
@@ -11,27 +14,50 @@ export function parseArgb(value) {
|
|
|
11
14
|
const argb = hex.length === 6 ? `FF${hex}` : hex;
|
|
12
15
|
return /^[0-9a-fA-F]{8}$/.test(argb) ? argb : undefined;
|
|
13
16
|
}
|
|
14
|
-
export const
|
|
15
|
-
none
|
|
16
|
-
solid
|
|
17
|
-
|
|
18
|
-
darkGray
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
17
|
+
export const FILL_PATTERNS_IN_SCHEMA_ORDER = [
|
|
18
|
+
'none',
|
|
19
|
+
'solid',
|
|
20
|
+
'mediumGray',
|
|
21
|
+
'darkGray',
|
|
22
|
+
'lightGray',
|
|
23
|
+
'darkHorizontal',
|
|
24
|
+
'darkVertical',
|
|
25
|
+
'darkDown',
|
|
26
|
+
'darkUp',
|
|
27
|
+
'darkGrid',
|
|
28
|
+
'darkTrellis',
|
|
29
|
+
'lightHorizontal',
|
|
30
|
+
'lightVertical',
|
|
31
|
+
'lightDown',
|
|
32
|
+
'lightUp',
|
|
33
|
+
'lightGrid',
|
|
34
|
+
'lightTrellis',
|
|
35
|
+
'gray125',
|
|
36
|
+
'gray0625',
|
|
37
|
+
];
|
|
38
|
+
export const isFillPatternType = tokenSetOf(FILL_PATTERNS_IN_SCHEMA_ORDER);
|
|
39
|
+
const GRADIENT_STOP_CLONE = { position: 'value', color: 'record' };
|
|
40
|
+
const PATTERN_FILL_CLONE = {
|
|
41
|
+
type: 'value',
|
|
42
|
+
pattern: 'value',
|
|
43
|
+
fgColor: 'record',
|
|
44
|
+
bgColor: 'record',
|
|
45
|
+
};
|
|
46
|
+
const GRADIENT_FILL_CLONE = {
|
|
47
|
+
type: 'value',
|
|
48
|
+
gradient: 'value',
|
|
49
|
+
degree: 'value',
|
|
50
|
+
left: 'value',
|
|
51
|
+
right: 'value',
|
|
52
|
+
top: 'value',
|
|
53
|
+
bottom: 'value',
|
|
54
|
+
stops: (stops) => stops.map((stop) => cloneWith(stop, GRADIENT_STOP_CLONE)),
|
|
55
|
+
};
|
|
56
|
+
export function cloneFill(fill) {
|
|
57
|
+
return fill.type === 'gradient'
|
|
58
|
+
? cloneWith(fill, GRADIENT_FILL_CLONE)
|
|
59
|
+
: cloneWith(fill, PATTERN_FILL_CLONE);
|
|
60
|
+
}
|
|
35
61
|
export const isBorderStyle = tokenSet({
|
|
36
62
|
thin: true,
|
|
37
63
|
medium: true,
|
|
@@ -47,11 +73,42 @@ export const isBorderStyle = tokenSet({
|
|
|
47
73
|
mediumDashDotDot: true,
|
|
48
74
|
slantDashDot: true,
|
|
49
75
|
});
|
|
76
|
+
const BORDER_EDGE_CLONE = { style: 'value', color: 'record' };
|
|
77
|
+
const cloneBorderEdge = (edge) => cloneWith(edge, BORDER_EDGE_CLONE);
|
|
78
|
+
const BORDER_CLONE = {
|
|
79
|
+
left: cloneBorderEdge,
|
|
80
|
+
right: cloneBorderEdge,
|
|
81
|
+
top: cloneBorderEdge,
|
|
82
|
+
bottom: cloneBorderEdge,
|
|
83
|
+
diagonal: cloneBorderEdge,
|
|
84
|
+
diagonalUp: 'value',
|
|
85
|
+
diagonalDown: 'value',
|
|
86
|
+
};
|
|
87
|
+
export function cloneBorder(border) {
|
|
88
|
+
return cloneWith(border, BORDER_CLONE);
|
|
89
|
+
}
|
|
50
90
|
export const isFontVerticalAlignment = tokenSet({
|
|
51
91
|
superscript: true,
|
|
52
92
|
subscript: true,
|
|
53
93
|
});
|
|
54
94
|
export const isFontScheme = tokenSet({ minor: true, major: true, none: true });
|
|
95
|
+
const FONT_CLONE = {
|
|
96
|
+
name: 'value',
|
|
97
|
+
size: 'value',
|
|
98
|
+
family: 'value',
|
|
99
|
+
scheme: 'value',
|
|
100
|
+
charset: 'value',
|
|
101
|
+
color: 'record',
|
|
102
|
+
bold: 'value',
|
|
103
|
+
italic: 'value',
|
|
104
|
+
underline: 'value',
|
|
105
|
+
strike: 'value',
|
|
106
|
+
outline: 'value',
|
|
107
|
+
vertAlign: 'value',
|
|
108
|
+
};
|
|
109
|
+
export function cloneFont(font) {
|
|
110
|
+
return cloneWith(font, FONT_CLONE);
|
|
111
|
+
}
|
|
55
112
|
export const isHorizontalAlignment = tokenSet({
|
|
56
113
|
general: true,
|
|
57
114
|
left: true,
|
|
@@ -93,17 +150,24 @@ const CELL_STYLE_FACET_KEYS = {
|
|
|
93
150
|
protection: true,
|
|
94
151
|
};
|
|
95
152
|
export const CELL_STYLE_FACETS = Object.keys(CELL_STYLE_FACET_KEYS);
|
|
153
|
+
const CELL_CONTENT_ONLY_KEYS = {
|
|
154
|
+
quotePrefix: true,
|
|
155
|
+
[NAMED_STYLE_ID]: true,
|
|
156
|
+
};
|
|
157
|
+
export const CELL_CONTENT_FACETS = [
|
|
158
|
+
...CELL_STYLE_FACETS,
|
|
159
|
+
...Reflect.ownKeys(CELL_CONTENT_ONLY_KEYS),
|
|
160
|
+
];
|
|
161
|
+
export function assignContentFacets(target, source) {
|
|
162
|
+
for (const facet of CELL_CONTENT_FACETS)
|
|
163
|
+
copyKeyIfPresent(target, source, facet);
|
|
164
|
+
}
|
|
96
165
|
export function assignStyleFacets(target, source) {
|
|
97
166
|
for (const facet of CELL_STYLE_FACETS)
|
|
98
|
-
|
|
167
|
+
copyKeyIfPresent(target, source, facet);
|
|
99
168
|
}
|
|
100
169
|
export function pickStyleFacets(source) {
|
|
101
170
|
const facets = {};
|
|
102
171
|
assignStyleFacets(facets, source);
|
|
103
172
|
return facets;
|
|
104
173
|
}
|
|
105
|
-
function copyFacet(target, source, key) {
|
|
106
|
-
const value = source[key];
|
|
107
|
-
if (value !== undefined)
|
|
108
|
-
target[key] = value;
|
|
109
|
-
}
|
package/dist/core/table-style.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthoringError } from '../errors.js';
|
|
1
|
+
import { AuthoringError, invalidToken, quoted } from '../errors.js';
|
|
2
2
|
export const TABLE_STYLE_ELEMENT_TYPES = [
|
|
3
3
|
'wholeTable',
|
|
4
4
|
'headerRow',
|
|
@@ -46,17 +46,17 @@ export function checkTableStyle(style) {
|
|
|
46
46
|
if (element === undefined)
|
|
47
47
|
continue;
|
|
48
48
|
if (!isTableStyleElementType(type)) {
|
|
49
|
-
throw
|
|
49
|
+
throw invalidToken('table style element', type);
|
|
50
50
|
}
|
|
51
51
|
const { size } = element;
|
|
52
52
|
if (size === undefined)
|
|
53
53
|
continue;
|
|
54
54
|
if (!STRIPE_ELEMENT_TYPES.has(type)) {
|
|
55
|
-
throw new AuthoringError(`table style element
|
|
55
|
+
throw new AuthoringError(`table style element ${quoted(type)} cannot carry a size: band width applies only to ` +
|
|
56
56
|
`${[...STRIPE_ELEMENT_TYPES].join(', ')}`);
|
|
57
57
|
}
|
|
58
58
|
if (!Number.isInteger(size) || size < 1) {
|
|
59
|
-
throw new RangeError(`
|
|
59
|
+
throw new RangeError(`invalid table style band size ${size}: expected a positive integer`);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|
package/dist/core/table.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { type GridRect } from './address.ts';
|
|
2
|
+
import { type ClonePlan } from './clone.ts';
|
|
3
|
+
import { type AxisSplice } from './grid-shift.ts';
|
|
4
|
+
import { type AssertNever, INTERNAL } from './internal.ts';
|
|
2
5
|
import type { CellStyle } from './style.ts';
|
|
3
6
|
import type { CellValue } from './value.ts';
|
|
4
7
|
/** A per-column cell format applied to a table's body cells: the facets Excel's table-column style
|
|
@@ -57,6 +60,22 @@ export interface TableStyleInfo {
|
|
|
57
60
|
/** Band the columns (alternating fill). */
|
|
58
61
|
readonly showColumnStripes?: boolean;
|
|
59
62
|
}
|
|
63
|
+
/** Copy a style, keeping only its defined fields off the literal so `exactOptionalPropertyTypes`
|
|
64
|
+
* never sees a fabricated `key: undefined`: an absent attribute must stay absent across a copy.
|
|
65
|
+
*
|
|
66
|
+
* The sentinel name `"None"` (Excel's table-style gallery entry for *no* style) is normalised to an
|
|
67
|
+
* absent name: OOXML expresses "unstyled" as a `<tableStyleInfo>` with no `name` attribute, so a
|
|
68
|
+
* literal `name="None"` would reference a style that does not exist and make the file suspect. The
|
|
69
|
+
* banding flags set alongside it are untouched. */
|
|
70
|
+
declare const STYLE_INFO_CLONE: ClonePlan<TableStyleInfo>;
|
|
71
|
+
/** The proof that {@link STYLE_INFO_CLONE} names every field of the style. */
|
|
72
|
+
export type EveryTableStyleInfoFieldIsCloned = AssertNever<Exclude<keyof Required<TableStyleInfo>, keyof typeof STYLE_INFO_CLONE>>;
|
|
73
|
+
/** The `<tableStyleInfo>` banding flags, in CT_TableStyleInfo attribute order. Each is an optional
|
|
74
|
+
* OOXML boolean, so the list is the whole of what the reader and the writer need to know about them. */
|
|
75
|
+
export declare const TABLE_STYLE_FLAGS: readonly ["showFirstColumn", "showLastColumn", "showRowStripes", "showColumnStripes"];
|
|
76
|
+
/** Compile-time proof that `name` and {@link TABLE_STYLE_FLAGS} cover every {@link TableStyleInfo}
|
|
77
|
+
* field, so a flag added to the type cannot be read or written by one direction only. */
|
|
78
|
+
export type EveryTableStyleFlagIsDeclared = AssertNever<Exclude<keyof TableStyleInfo, 'name' | (typeof TABLE_STYLE_FLAGS)[number]>>;
|
|
60
79
|
/**
|
|
61
80
|
* OOXML's totals-row function names (`ST_TotalsRowFunction`) to the `SUBTOTAL` first-argument code
|
|
62
81
|
* Excel writes into a materialised totals cell. The `10x` band ignores manually hidden rows, the
|
|
@@ -92,18 +111,31 @@ export interface TableColumn {
|
|
|
92
111
|
* `<totalsRowFormula>` child. Round-tripped verbatim and written into the totals cell as the
|
|
93
112
|
* cell's formula. Meaningful only alongside `totalsRowFunction: "custom"`; ignored otherwise. */
|
|
94
113
|
readonly totalsRowFormula?: string;
|
|
114
|
+
/**
|
|
115
|
+
* The formula (no leading `=`) that makes this a calculated column: OOXML's
|
|
116
|
+
* `<calculatedColumnFormula>`, spelled as it stands in the column's first data row, with a structured
|
|
117
|
+
* reference to the row written `Table[[#This Row],[Column]]`. Excel fills it into each row added to
|
|
118
|
+
* the table.
|
|
119
|
+
*
|
|
120
|
+
* It describes the column and writes no cell: the body cells hold their own formulas.
|
|
121
|
+
*/
|
|
122
|
+
readonly calculatedColumnFormula?: string;
|
|
95
123
|
/** A format applied to this column's body cells as they are written (see {@link TableColumnStyle}).
|
|
96
124
|
* Excel bakes a table-column style into the cells rather than storing it as table metadata, so this
|
|
97
125
|
* is an authoring convenience: it round-trips as the affected cells' own styles, not as the table. */
|
|
98
126
|
readonly style?: TableColumnStyle;
|
|
99
127
|
}
|
|
100
128
|
export interface TableOptions {
|
|
101
|
-
/**
|
|
102
|
-
*
|
|
129
|
+
/**
|
|
130
|
+
* Table name: a valid Excel identifier, unique across the workbook. It is the one name a table has:
|
|
131
|
+
* the name structured references use (`Table1[Column]`) and the one Excel shows, written as both the
|
|
132
|
+
* table part's `name` and its `displayName`.
|
|
133
|
+
*
|
|
134
|
+
* There is no separate display label. OOXML's `displayName` is the identifier Excel resolves a
|
|
135
|
+
* structured reference against and shows in the UI, and a package whose `displayName` carries a space
|
|
136
|
+
* opens with Excel's repair prompt.
|
|
137
|
+
*/
|
|
103
138
|
name: string;
|
|
104
|
-
/** Human-facing display name shown in the UI. A free-form label (spaces allowed) that need not
|
|
105
|
-
* be a valid identifier. Defaults to {@link name} when omitted. */
|
|
106
|
-
displayName?: string;
|
|
107
139
|
/** A1 reference of the table's top-left cell (an anchor, e.g. `"A1"`, not the full range). */
|
|
108
140
|
ref: string;
|
|
109
141
|
/** The table's columns, left to right. At least one is required. */
|
|
@@ -134,14 +166,16 @@ export type TableRegion = GridRect;
|
|
|
134
166
|
export declare class Table {
|
|
135
167
|
#private;
|
|
136
168
|
readonly name: string;
|
|
137
|
-
readonly displayName: string;
|
|
138
|
-
readonly columns: readonly TableColumn[];
|
|
139
169
|
readonly headerRow: boolean;
|
|
140
170
|
readonly totalsRow: boolean;
|
|
141
171
|
readonly totalsRowShown: boolean | undefined;
|
|
142
172
|
readonly autoFilter: boolean;
|
|
143
173
|
readonly style: TableStyleInfo | undefined;
|
|
174
|
+
/** What a splice does to the table's formulas; see `core/internal.ts`. */
|
|
175
|
+
readonly [INTERNAL]: TableInternals;
|
|
144
176
|
constructor(options: TableOptions, grid?: TableGrid);
|
|
177
|
+
/** The table's columns, left to right. */
|
|
178
|
+
get columns(): readonly TableColumn[];
|
|
145
179
|
get columnCount(): number;
|
|
146
180
|
/** The number of data rows (excludes the header and totals rows). Always defined: a table loaded
|
|
147
181
|
* from a file derives it from the stored range, so reading the height never throws. */
|
|
@@ -158,20 +192,24 @@ export declare class Table {
|
|
|
158
192
|
*/
|
|
159
193
|
addRow(values?: readonly CellValue[]): void;
|
|
160
194
|
/**
|
|
161
|
-
* Re-pin the table through a row splice
|
|
162
|
-
*
|
|
163
|
-
* whole range by `delta`; one landing inside grows or shrinks the data rows to absorb the change;
|
|
195
|
+
* Re-pin the table through a row splice. A splice entirely above the table moves its whole range
|
|
196
|
+
* by the splice's `delta`; one landing inside grows or shrinks the data rows to absorb the change;
|
|
164
197
|
* one that deletes the table's every row removes it. Returns `false` when the table no longer has
|
|
165
198
|
* a row to occupy (the caller drops it), `true` when it survives.
|
|
166
199
|
*/
|
|
167
|
-
shiftRows(
|
|
200
|
+
shiftRows(splice: AxisSplice): boolean;
|
|
168
201
|
/**
|
|
169
|
-
* Re-pin the table through a column splice. A splice entirely to
|
|
170
|
-
* by `delta`; one to its right leaves it untouched
|
|
171
|
-
*
|
|
172
|
-
*
|
|
202
|
+
* Re-pin the table through a column splice, the mirror of {@link shiftRows}. A splice entirely to
|
|
203
|
+
* the table's left moves its anchor by the splice's `delta`; one to its right leaves it untouched;
|
|
204
|
+
* one that deletes the table's every column removes it. Returns `false` when the table no longer
|
|
205
|
+
* has a column to occupy (the caller drops it), `true` when it survives.
|
|
206
|
+
*
|
|
207
|
+
* A splice landing *inside* the table's columns is structural surgery on named columns with no
|
|
208
|
+
* unambiguous answer, so those columns are left as-is rather than fabricated or dropped. Whole-table
|
|
209
|
+
* deletion is not that case: a table left declared over whatever slid into its place, carrying the
|
|
210
|
+
* names of columns that no longer exist, is content the writer then emits.
|
|
173
211
|
*/
|
|
174
|
-
shiftColumns(
|
|
212
|
+
shiftColumns(splice: AxisSplice): boolean;
|
|
175
213
|
/**
|
|
176
214
|
* The options that reconstruct this table: the anchor as a single-cell ref (not the derived
|
|
177
215
|
* full range), the columns, and the data-row count with the header/totals flags. Feeding this
|
|
@@ -194,3 +232,13 @@ export declare class Table {
|
|
|
194
232
|
/** The occupied rectangle, for conflict checks such as overlapping merges. */
|
|
195
233
|
get region(): TableRegion;
|
|
196
234
|
}
|
|
235
|
+
/** What the library's own machinery may do to a {@link Table}; reached as `table[INTERNAL]`. */
|
|
236
|
+
export interface TableInternals {
|
|
237
|
+
/**
|
|
238
|
+
* Replace each column's calculated column formula and totals row formula with what `rewrite` makes
|
|
239
|
+
* of it, which is how a row or column splice moves the references they make. A column whose formulas
|
|
240
|
+
* come back unchanged stays the same object.
|
|
241
|
+
*/
|
|
242
|
+
rewriteFormulas(rewrite: (formula: string) => string): void;
|
|
243
|
+
}
|
|
244
|
+
export {};
|