@shbernal/ts-xlsx 1.0.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/LICENSE +23 -0
- package/README.md +230 -0
- package/dist/core/address.d.ts +49 -0
- package/dist/core/address.js +125 -0
- package/dist/core/autofilter.d.ts +55 -0
- package/dist/core/autofilter.js +48 -0
- package/dist/core/cell.d.ts +132 -0
- package/dist/core/cell.js +249 -0
- package/dist/core/color-resolution.d.ts +58 -0
- package/dist/core/color-resolution.js +170 -0
- package/dist/core/column.d.ts +87 -0
- package/dist/core/column.js +167 -0
- package/dist/core/comment-thread.d.ts +116 -0
- package/dist/core/comment-thread.js +62 -0
- package/dist/core/conditional-formatting-overlay.d.ts +15 -0
- package/dist/core/conditional-formatting-overlay.js +24 -0
- package/dist/core/conditional-formatting.d.ts +70 -0
- package/dist/core/conditional-formatting.js +35 -0
- package/dist/core/containers.d.ts +2 -0
- package/dist/core/containers.js +25 -0
- package/dist/core/data-validation-overlay.d.ts +28 -0
- package/dist/core/data-validation-overlay.js +56 -0
- package/dist/core/data-validation.d.ts +38 -0
- package/dist/core/data-validation.js +13 -0
- package/dist/core/date.d.ts +25 -0
- package/dist/core/date.js +58 -0
- package/dist/core/formula.d.ts +49 -0
- package/dist/core/formula.js +319 -0
- package/dist/core/grid-edits.d.ts +22 -0
- package/dist/core/grid-edits.js +206 -0
- package/dist/core/image.d.ts +76 -0
- package/dist/core/image.js +65 -0
- package/dist/core/internal.d.ts +11 -0
- package/dist/core/internal.js +29 -0
- package/dist/core/merge.d.ts +13 -0
- package/dist/core/merge.js +26 -0
- package/dist/core/modern-functions.d.ts +1 -0
- package/dist/core/modern-functions.js +165 -0
- package/dist/core/page-setup.d.ts +94 -0
- package/dist/core/page-setup.js +6 -0
- package/dist/core/pivot-table.d.ts +113 -0
- package/dist/core/pivot-table.js +249 -0
- package/dist/core/preserved.d.ts +58 -0
- package/dist/core/preserved.js +5 -0
- package/dist/core/protection.d.ts +67 -0
- package/dist/core/protection.js +68 -0
- package/dist/core/range.d.ts +112 -0
- package/dist/core/range.js +283 -0
- package/dist/core/row.d.ts +73 -0
- package/dist/core/row.js +135 -0
- package/dist/core/style.d.ts +246 -0
- package/dist/core/style.js +125 -0
- package/dist/core/table-style.d.ts +67 -0
- package/dist/core/table-style.js +90 -0
- package/dist/core/table.d.ts +194 -0
- package/dist/core/table.js +291 -0
- package/dist/core/theme.d.ts +90 -0
- package/dist/core/theme.js +272 -0
- package/dist/core/value.d.ts +115 -0
- package/dist/core/value.js +144 -0
- package/dist/core/workbook-protection.d.ts +27 -0
- package/dist/core/workbook-protection.js +25 -0
- package/dist/core/workbook.d.ts +528 -0
- package/dist/core/workbook.js +732 -0
- package/dist/core/worksheet-model.d.ts +34 -0
- package/dist/core/worksheet-model.js +100 -0
- package/dist/core/worksheet.d.ts +647 -0
- package/dist/core/worksheet.js +1025 -0
- package/dist/customui/errors.d.ts +15 -0
- package/dist/customui/errors.js +15 -0
- package/dist/customui/index.d.ts +2 -0
- package/dist/customui/index.js +7 -0
- package/dist/customui/ribbon.d.ts +86 -0
- package/dist/customui/ribbon.js +180 -0
- package/dist/entries/core.d.ts +23 -0
- package/dist/entries/core.js +20 -0
- package/dist/entries/csv.d.ts +2 -0
- package/dist/entries/csv.js +6 -0
- package/dist/entries/customui.d.ts +1 -0
- package/dist/entries/customui.js +3 -0
- package/dist/entries/errors.d.ts +7 -0
- package/dist/entries/errors.js +20 -0
- package/dist/entries/vba.d.ts +2 -0
- package/dist/entries/vba.js +7 -0
- package/dist/entries/xlsb.d.ts +1 -0
- package/dist/entries/xlsb.js +7 -0
- package/dist/entries/xlsx.d.ts +5 -0
- package/dist/entries/xlsx.js +18 -0
- package/dist/errors.d.ts +65 -0
- package/dist/errors.js +66 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +19 -0
- package/dist/io/csv/read.d.ts +15 -0
- package/dist/io/csv/read.js +113 -0
- package/dist/io/csv/write.d.ts +28 -0
- package/dist/io/csv/write.js +124 -0
- package/dist/io/opc/errors.d.ts +46 -0
- package/dist/io/opc/errors.js +49 -0
- package/dist/io/opc/inflate.d.ts +15 -0
- package/dist/io/opc/inflate.js +91 -0
- package/dist/io/opc/namespaces.d.ts +18 -0
- package/dist/io/opc/namespaces.js +18 -0
- package/dist/io/opc/part-paths.d.ts +4 -0
- package/dist/io/opc/part-paths.js +35 -0
- package/dist/io/opc/read-opc.d.ts +24 -0
- package/dist/io/opc/read-opc.js +153 -0
- package/dist/io/opc/read-options.d.ts +10 -0
- package/dist/io/opc/read-options.js +7 -0
- package/dist/io/opc/rels.d.ts +15 -0
- package/dist/io/opc/rels.js +28 -0
- package/dist/io/opc/sniff-format.d.ts +27 -0
- package/dist/io/opc/sniff-format.js +92 -0
- package/dist/io/style/xf-style.d.ts +47 -0
- package/dist/io/style/xf-style.js +95 -0
- package/dist/io/xlsb/errors.d.ts +15 -0
- package/dist/io/xlsb/errors.js +15 -0
- package/dist/io/xlsb/formula.d.ts +48 -0
- package/dist/io/xlsb/formula.js +398 -0
- package/dist/io/xlsb/primitives.d.ts +86 -0
- package/dist/io/xlsb/primitives.js +230 -0
- package/dist/io/xlsb/ptg-functions.d.ts +16 -0
- package/dist/io/xlsb/ptg-functions.js +659 -0
- package/dist/io/xlsb/read-shared-strings.d.ts +2 -0
- package/dist/io/xlsb/read-shared-strings.js +22 -0
- package/dist/io/xlsb/read-styles.d.ts +4 -0
- package/dist/io/xlsb/read-styles.js +386 -0
- package/dist/io/xlsb/read-worksheet.d.ts +9 -0
- package/dist/io/xlsb/read-worksheet.js +301 -0
- package/dist/io/xlsb/read.d.ts +20 -0
- package/dist/io/xlsb/read.js +199 -0
- package/dist/io/xlsb/record-stream.d.ts +14 -0
- package/dist/io/xlsb/record-stream.js +56 -0
- package/dist/io/xlsb/record-types.d.ts +55 -0
- package/dist/io/xlsb/record-types.js +73 -0
- package/dist/io/xlsx/cell-accumulator.d.ts +25 -0
- package/dist/io/xlsx/cell-accumulator.js +172 -0
- package/dist/io/xlsx/cell-value.d.ts +32 -0
- package/dist/io/xlsx/cell-value.js +85 -0
- package/dist/io/xlsx/comments.d.ts +74 -0
- package/dist/io/xlsx/comments.js +243 -0
- package/dist/io/xlsx/conditional-formatting.d.ts +32 -0
- package/dist/io/xlsx/conditional-formatting.js +464 -0
- package/dist/io/xlsx/data-validation.d.ts +20 -0
- package/dist/io/xlsx/data-validation.js +258 -0
- package/dist/io/xlsx/edit-vba.d.ts +23 -0
- package/dist/io/xlsx/edit-vba.js +139 -0
- package/dist/io/xlsx/errors.d.ts +17 -0
- package/dist/io/xlsx/errors.js +17 -0
- package/dist/io/xlsx/hyperlinks.d.ts +42 -0
- package/dist/io/xlsx/hyperlinks.js +139 -0
- package/dist/io/xlsx/images.d.ts +34 -0
- package/dist/io/xlsx/images.js +218 -0
- package/dist/io/xlsx/namespaces.d.ts +55 -0
- package/dist/io/xlsx/namespaces.js +55 -0
- package/dist/io/xlsx/package-plan.d.ts +103 -0
- package/dist/io/xlsx/package-plan.js +168 -0
- package/dist/io/xlsx/pivot-read.d.ts +5 -0
- package/dist/io/xlsx/pivot-read.js +134 -0
- package/dist/io/xlsx/pivot.d.ts +12 -0
- package/dist/io/xlsx/pivot.js +141 -0
- package/dist/io/xlsx/read-rows.d.ts +85 -0
- package/dist/io/xlsx/read-rows.js +286 -0
- package/dist/io/xlsx/read-styles.d.ts +8 -0
- package/dist/io/xlsx/read-styles.js +551 -0
- package/dist/io/xlsx/read-worksheet.d.ts +4 -0
- package/dist/io/xlsx/read-worksheet.js +528 -0
- package/dist/io/xlsx/read.d.ts +32 -0
- package/dist/io/xlsx/read.js +680 -0
- package/dist/io/xlsx/relationships.d.ts +33 -0
- package/dist/io/xlsx/relationships.js +47 -0
- package/dist/io/xlsx/rich-runs.d.ts +13 -0
- package/dist/io/xlsx/rich-runs.js +59 -0
- package/dist/io/xlsx/rich-text.d.ts +7 -0
- package/dist/io/xlsx/rich-text.js +23 -0
- package/dist/io/xlsx/shared-formulas.d.ts +6 -0
- package/dist/io/xlsx/shared-formulas.js +52 -0
- package/dist/io/xlsx/shared-strings-read.d.ts +2 -0
- package/dist/io/xlsx/shared-strings-read.js +70 -0
- package/dist/io/xlsx/shared-strings.d.ts +17 -0
- package/dist/io/xlsx/shared-strings.js +50 -0
- package/dist/io/xlsx/sheet-properties.d.ts +13 -0
- package/dist/io/xlsx/sheet-properties.js +211 -0
- package/dist/io/xlsx/styles.d.ts +138 -0
- package/dist/io/xlsx/styles.js +821 -0
- package/dist/io/xlsx/tables.d.ts +9 -0
- package/dist/io/xlsx/tables.js +208 -0
- package/dist/io/xlsx/threaded-comments.d.ts +102 -0
- package/dist/io/xlsx/threaded-comments.js +308 -0
- package/dist/io/xlsx/workbook-xml.d.ts +12 -0
- package/dist/io/xlsx/workbook-xml.js +353 -0
- package/dist/io/xlsx/worksheet-xml.d.ts +86 -0
- package/dist/io/xlsx/worksheet-xml.js +643 -0
- package/dist/io/xlsx/write-stream.d.ts +171 -0
- package/dist/io/xlsx/write-stream.js +399 -0
- package/dist/io/xlsx/write.d.ts +81 -0
- package/dist/io/xlsx/write.js +396 -0
- package/dist/io/xlsx/x14-ext.d.ts +9 -0
- package/dist/io/xlsx/x14-ext.js +12 -0
- package/dist/vba/cfb-writer.d.ts +19 -0
- package/dist/vba/cfb-writer.js +277 -0
- package/dist/vba/cfb.d.ts +16 -0
- package/dist/vba/cfb.js +324 -0
- package/dist/vba/codepage.d.ts +18 -0
- package/dist/vba/codepage.js +87 -0
- package/dist/vba/errors.d.ts +24 -0
- package/dist/vba/errors.js +24 -0
- package/dist/vba/index.d.ts +5 -0
- package/dist/vba/index.js +15 -0
- package/dist/vba/ms-ovba.d.ts +12 -0
- package/dist/vba/ms-ovba.js +176 -0
- package/dist/vba/project-editor.d.ts +62 -0
- package/dist/vba/project-editor.js +377 -0
- package/dist/vba/project.d.ts +45 -0
- package/dist/vba/project.js +160 -0
- package/dist/vba/vba-encoding.d.ts +14 -0
- package/dist/vba/vba-encoding.js +39 -0
- package/dist/xml/errors.d.ts +15 -0
- package/dist/xml/errors.js +15 -0
- package/dist/xml/xml-read.d.ts +107 -0
- package/dist/xml/xml-read.js +283 -0
- package/dist/xml/xml.d.ts +41 -0
- package/dist/xml/xml.js +86 -0
- package/package.json +117 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { type Alignment, type Border, type Color, type DifferentialStyle, type Fill, type Font, type NamedCellStyle, type Protection, type TableStyleTable } from '../../core/style.ts';
|
|
2
|
+
import { type TableStyle } from '../../core/table-style.ts';
|
|
3
|
+
/** A cell's style facets as the writer composes them: cell overrides atop row/column defaults. */
|
|
4
|
+
export interface CellStyle {
|
|
5
|
+
readonly fill?: Fill | undefined;
|
|
6
|
+
readonly numFmt?: string | undefined;
|
|
7
|
+
readonly font?: Font | undefined;
|
|
8
|
+
readonly border?: Border | undefined;
|
|
9
|
+
readonly alignment?: Alignment | undefined;
|
|
10
|
+
readonly protection?: Protection | undefined;
|
|
11
|
+
/** The quote-prefix flag — an attribute on the xf, not a shared sub-table entry. */
|
|
12
|
+
readonly quotePrefix?: boolean | undefined;
|
|
13
|
+
/** The `xfId` link into `cellStyleXfs` — the named cell style this format inherits from (0 = Normal). */
|
|
14
|
+
readonly xfId?: number | undefined;
|
|
15
|
+
}
|
|
16
|
+
/** What a {@link StyleRegistry} needs from its workbook before any style is interned. */
|
|
17
|
+
export interface StyleRegistryOptions {
|
|
18
|
+
/**
|
|
19
|
+
* The font every cell naming none of its own renders in — emitted as id 0. Take it from
|
|
20
|
+
* {@link Workbook.defaultFont}, which resolves the authored/declared/theme chain and guarantees a
|
|
21
|
+
* complete entry. Omitted, the registry falls back to the Office default.
|
|
22
|
+
*/
|
|
23
|
+
readonly defaultFont?: Font;
|
|
24
|
+
/**
|
|
25
|
+
* The default font the *source package* declared, when a workbook was read
|
|
26
|
+
* ({@link Workbook.declaredDefaultFont}). It also interns to id 0, which is what lets an authored
|
|
27
|
+
* default font reach cells the reader had already resolved.
|
|
28
|
+
*
|
|
29
|
+
* The reader flattens font 0 onto every xf that names it, so a cell that merely inherited the
|
|
30
|
+
* file's default arrives carrying it as a concrete face. That face is an artefact of reading, not
|
|
31
|
+
* an authored intent — in the source file the cell said nothing about its font — so it must
|
|
32
|
+
* collapse back to id 0 and follow the new default rather than pin itself to the old one through a
|
|
33
|
+
* custom entry.
|
|
34
|
+
*/
|
|
35
|
+
readonly declaredDefaultFont?: Font;
|
|
36
|
+
}
|
|
37
|
+
export declare class StyleRegistry {
|
|
38
|
+
#private;
|
|
39
|
+
constructor(options?: StyleRegistryOptions);
|
|
40
|
+
/**
|
|
41
|
+
* The `<cellXfs>` index for a composed cell/row/column style. A style with no facet needs
|
|
42
|
+
* no entry and resolves to the default xf 0, so its owner emits no `s` attribute at all.
|
|
43
|
+
*/
|
|
44
|
+
styleId(style: CellStyle): number;
|
|
45
|
+
/**
|
|
46
|
+
* Seed the named cell styles (`<cellStyleXfs>`/`<cellStyles>`) read from a file, in place of the
|
|
47
|
+
* lone default, interning each style's facets into the shared sub-tables so its `fillId`/`fontId`/…
|
|
48
|
+
* references stay valid against the rebuilt tables. Index 0 stays Normal. A cell's `xfId` indexes
|
|
49
|
+
* this table, so it must be seeded before any {@link styleId} that carries an `xfId`.
|
|
50
|
+
*/
|
|
51
|
+
seedNamedStyles(styles: readonly NamedCellStyle[]): void;
|
|
52
|
+
/**
|
|
53
|
+
* Seed the differential-style table with fragments read from a file, keeping each `<dxf>…</dxf>`
|
|
54
|
+
* verbatim and at its original index. Call once before any {@link differentialStyleId}; authored
|
|
55
|
+
* styles append after these.
|
|
56
|
+
*
|
|
57
|
+
* **Index stability is a contract, not an implementation detail.** A `dxfId` is an index into this
|
|
58
|
+
* one table, and more than one preserved construct resolves through it: a conditional-formatting
|
|
59
|
+
* rule's `dxfId`, and every `<tableStyleElement dxfId="…">` inside a preserved `<tableStyle>` (see
|
|
60
|
+
* {@link seedTableStyles}). Those constructs are carried as opaque XML precisely *because* the
|
|
61
|
+
* indices they name do not move. Renumbering, reordering, or de-duplicating the seeded entries
|
|
62
|
+
* would silently re-point every one of them at a different format — a change no schema check and no
|
|
63
|
+
* round-trip of our own can catch, because the file stays perfectly valid and merely renders wrong.
|
|
64
|
+
*/
|
|
65
|
+
seedDifferentialStyles(fragments: readonly string[]): void;
|
|
66
|
+
/**
|
|
67
|
+
* Seed the custom indexed-color palette (`<colors><indexedColors>`) read from a file, each entry a
|
|
68
|
+
* verbatim `<rgbColor rgb="…"/>` fragment. Re-emitting it unchanged is what keeps an `indexed="…"`
|
|
69
|
+
* colour reference resolving to the RGB the source intended. An empty list leaves the workbook on
|
|
70
|
+
* the default palette and emits no `<colors>` element.
|
|
71
|
+
*/
|
|
72
|
+
seedIndexedColors(fragments: readonly string[]): void;
|
|
73
|
+
/**
|
|
74
|
+
* Seed the most-recently-used colour swatches (`<colors><mruColors>`) read from a file, each entry a
|
|
75
|
+
* verbatim `<color rgb="…"/>` fragment. An empty list emits no `<mruColors>` element.
|
|
76
|
+
*/
|
|
77
|
+
seedMruColors(fragments: readonly string[]): void;
|
|
78
|
+
/**
|
|
79
|
+
* Seed the custom table-style definitions (`<tableStyles>`) read from a file, each `<tableStyle>`
|
|
80
|
+
* kept verbatim so a table's `tableStyleInfo/@name` still resolves and each element's `dxfId` still
|
|
81
|
+
* indexes the differential-style table {@link seedDifferentialStyles} preserves at its original
|
|
82
|
+
* indices. Replaces any block already held.
|
|
83
|
+
*/
|
|
84
|
+
seedTableStyles(table: TableStyleTable): void;
|
|
85
|
+
/**
|
|
86
|
+
* Serialise a table style authored on the workbook, interning each element's formatting into the
|
|
87
|
+
* differential-style table and emitting the `dxfId` that reaches it. Call after
|
|
88
|
+
* {@link seedTableStyles}, whose preserved definitions these append after.
|
|
89
|
+
*
|
|
90
|
+
* A definition here **replaces** a preserved one of the same name. Two `<tableStyle>` elements
|
|
91
|
+
* sharing a name is ambiguous — a table's `tableStyleInfo/@name` would reach whichever a consumer
|
|
92
|
+
* happened to index first — so authoring a name the source already used is read as overriding it,
|
|
93
|
+
* which is what asking for it means.
|
|
94
|
+
*/
|
|
95
|
+
addTableStyle(style: TableStyle): void;
|
|
96
|
+
/**
|
|
97
|
+
* Intern an authored differential style, returning the `<dxfs>` index that references it — a
|
|
98
|
+
* conditional-formatting rule's `dxfId`, or a table style element's. Identical styles collapse to
|
|
99
|
+
* one entry, whichever feature asked for them, so a highlight rule and a table style's header row
|
|
100
|
+
* painted the same way share a single `<dxf>`.
|
|
101
|
+
*
|
|
102
|
+
* Authored entries append after the seeded ones ({@link seedDifferentialStyles}), which is what
|
|
103
|
+
* keeps every preserved reference pointing where it did.
|
|
104
|
+
*/
|
|
105
|
+
differentialStyleId(style: DifferentialStyle): number;
|
|
106
|
+
/** Serialise the accumulated table into a complete, valid styles.xml part. */
|
|
107
|
+
toXml(): string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Extract the custom indexed-color palette (`<colors><indexedColors>`) from styles.xml as verbatim
|
|
111
|
+
* `<rgbColor rgb="…"/>` fragments, or an empty list when the file rides the default palette. Kept raw
|
|
112
|
+
* — rather than parsed into RGB and re-serialised — so the exact entries (count, order, casing) a
|
|
113
|
+
* source file declared survive a round-trip and every `indexed="…"` reference keeps its RGB.
|
|
114
|
+
*/
|
|
115
|
+
export declare function parseIndexedColors(stylesXml: string): string[];
|
|
116
|
+
/**
|
|
117
|
+
* Extract the most-recently-used colour swatches (`<colors><mruColors>`) from styles.xml as verbatim
|
|
118
|
+
* `<color .../>` fragments, or an empty list when the file declares none. Kept raw for the same reason
|
|
119
|
+
* the indexed palette is: the list is the author's own working set of colours and the model has no
|
|
120
|
+
* use for its contents, only for not losing them.
|
|
121
|
+
*/
|
|
122
|
+
export declare function parseMruColors(stylesXml: string): string[];
|
|
123
|
+
/**
|
|
124
|
+
* Extract the `<tableStyles>` block from styles.xml: each `<tableStyle>` definition verbatim, plus the
|
|
125
|
+
* container's nominated `defaultTableStyle`/`defaultPivotStyle`. See {@link TableStyleTable} for why
|
|
126
|
+
* the definitions stay raw while the two names are decoded.
|
|
127
|
+
*
|
|
128
|
+
* A file with no such block — or with the self-closing `count="0"` container Excel writes when it has
|
|
129
|
+
* only defaults to state — yields an empty {@link TableStyleTable.styles} and whichever names it did
|
|
130
|
+
* carry.
|
|
131
|
+
*/
|
|
132
|
+
export declare function parseTableStyles(stylesXml: string): TableStyleTable;
|
|
133
|
+
export declare function fontXml(font: Font, nameTag?: 'name' | 'rFont'): string;
|
|
134
|
+
export declare function dxfXml(style: DifferentialStyle): string;
|
|
135
|
+
export declare function colorAttrs(color: Color): string;
|
|
136
|
+
export declare function parseColor(attrs: {
|
|
137
|
+
readonly [k: string]: string;
|
|
138
|
+
}): Color;
|