@shbernal/ts-xlsx 1.1.0 → 1.3.1
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 +26 -0
- package/dist/core/address.js +0 -33
- package/dist/core/autofilter.js +0 -9
- package/dist/core/cell.js +0 -131
- package/dist/core/color-resolution.js +0 -60
- package/dist/core/column.js +0 -60
- package/dist/core/comment-thread.js +0 -45
- package/dist/core/conditional-formatting-overlay.js +0 -11
- package/dist/core/conditional-formatting.js +0 -10
- package/dist/core/containers.js +0 -15
- package/dist/core/data-validation-overlay.js +0 -25
- package/dist/core/data-validation.js +0 -7
- package/dist/core/date.js +0 -39
- package/dist/core/formula.js +0 -117
- package/dist/core/grid-edits.js +0 -38
- package/dist/core/image.js +0 -25
- package/dist/core/internal.js +0 -27
- package/dist/core/limits.js +0 -45
- package/dist/core/merge.d.ts +18 -0
- package/dist/core/merge.js +22 -7
- package/dist/core/modern-functions.js +0 -17
- package/dist/core/page-setup.js +0 -5
- package/dist/core/pivot-table.d.ts +1 -1
- package/dist/core/pivot-table.js +0 -48
- package/dist/core/preserved.js +0 -4
- package/dist/core/protection.js +0 -26
- package/dist/core/range.js +0 -112
- package/dist/core/row-input.d.ts +24 -0
- package/dist/core/row-input.js +29 -0
- package/dist/core/row.js +0 -66
- package/dist/core/style.js +0 -26
- package/dist/core/table-style.js +0 -28
- package/dist/core/table.js +0 -97
- package/dist/core/text-metrics.js +0 -40
- package/dist/core/theme.js +0 -85
- package/dist/core/value.js +0 -94
- package/dist/core/workbook-protection.js +0 -13
- package/dist/core/workbook.d.ts +13 -1
- package/dist/core/workbook.js +0 -380
- package/dist/core/worksheet-model.js +2 -23
- package/dist/core/worksheet.d.ts +9 -0
- package/dist/core/worksheet.js +7 -506
- package/dist/customui/errors.js +0 -10
- package/dist/customui/index.js +0 -5
- package/dist/customui/ribbon.js +0 -43
- package/dist/entries/core.js +0 -6
- package/dist/entries/csv.js +0 -4
- package/dist/entries/customui.js +0 -2
- package/dist/entries/errors.js +0 -13
- package/dist/entries/vba.js +0 -5
- package/dist/entries/xlsb.js +0 -6
- package/dist/entries/xlsx.js +0 -13
- package/dist/errors.d.ts +14 -0
- package/dist/errors.js +5 -56
- package/dist/index.js +0 -12
- package/dist/io/csv/read.js +0 -18
- package/dist/io/csv/write.js +0 -18
- package/dist/io/opc/errors.js +0 -30
- package/dist/io/opc/inflate.js +0 -35
- package/dist/io/opc/namespaces.js +0 -15
- package/dist/io/opc/part-paths.js +0 -11
- package/dist/io/opc/read-opc.js +0 -31
- package/dist/io/opc/read-options.js +0 -6
- package/dist/io/opc/rels.js +0 -13
- package/dist/io/opc/sniff-format.js +0 -50
- package/dist/io/opc/zip-mtime.d.ts +5 -0
- package/dist/io/opc/zip-mtime.js +1 -0
- package/dist/io/style/xf-style.js +0 -31
- package/dist/io/xlsb/errors.js +0 -10
- package/dist/io/xlsb/formula.js +1 -99
- package/dist/io/xlsb/primitives.js +1 -83
- package/dist/io/xlsb/ptg-functions.js +0 -34
- package/dist/io/xlsb/read-shared-strings.js +0 -7
- package/dist/io/xlsb/read-styles.js +3 -66
- package/dist/io/xlsb/read-worksheet.js +4 -87
- package/dist/io/xlsb/read.js +2 -60
- package/dist/io/xlsb/record-stream.js +0 -28
- package/dist/io/xlsb/record-types.js +0 -19
- package/dist/io/xlsx/cell-accumulator.js +0 -32
- package/dist/io/xlsx/cell-value.js +0 -29
- package/dist/io/xlsx/color-xml.d.ts +6 -0
- package/dist/io/xlsx/color-xml.js +42 -0
- package/dist/io/xlsx/comments.js +0 -84
- package/dist/io/xlsx/conditional-formatting.d.ts +1 -1
- package/dist/io/xlsx/conditional-formatting.js +1 -97
- package/dist/io/xlsx/data-validation.js +0 -56
- package/dist/io/xlsx/edit-vba.js +2 -55
- package/dist/io/xlsx/errors.js +0 -12
- package/dist/io/xlsx/hyperlinks.js +0 -40
- package/dist/io/xlsx/images.js +0 -32
- package/dist/io/xlsx/namespaces.js +0 -42
- package/dist/io/xlsx/package-plan.js +0 -47
- package/dist/io/xlsx/pivot.js +0 -22
- package/dist/io/xlsx/{pivot-read.js → read-pivot.js} +0 -30
- package/dist/io/xlsx/read-rows.js +1 -83
- package/dist/io/xlsx/{shared-strings-read.js → read-shared-strings.js} +0 -11
- package/dist/io/xlsx/read-styles.d.ts +25 -1
- package/dist/io/xlsx/read-styles.js +61 -108
- package/dist/io/xlsx/read-worksheet.js +7 -88
- package/dist/io/xlsx/read.js +36 -213
- package/dist/io/xlsx/relationships.js +0 -11
- package/dist/io/xlsx/rich-runs.js +0 -16
- package/dist/io/xlsx/rich-text.js +0 -12
- package/dist/io/xlsx/shared-formulas.js +0 -7
- package/dist/io/xlsx/shared-strings.js +0 -21
- package/dist/io/xlsx/sheet-properties.js +4 -66
- package/dist/io/xlsx/styles.d.ts +1 -29
- package/dist/io/xlsx/styles.js +2 -366
- package/dist/io/xlsx/tables.js +5 -52
- package/dist/io/xlsx/threaded-comments.js +0 -103
- package/dist/io/xlsx/workbook-xml.d.ts +1 -1
- package/dist/io/xlsx/workbook-xml.js +6 -96
- package/dist/io/xlsx/worksheet-xml.js +0 -174
- package/dist/io/xlsx/write-stream.js +2 -137
- package/dist/io/xlsx/write.d.ts +5 -1
- package/dist/io/xlsx/write.js +5 -137
- package/dist/io/xlsx/x14-ext.js +0 -8
- package/dist/vba/cfb-writer.js +12 -59
- package/dist/vba/cfb.js +2 -32
- package/dist/vba/codepage.js +1 -23
- package/dist/vba/errors.js +0 -15
- package/dist/vba/index.js +0 -10
- package/dist/vba/ms-ovba.js +3 -46
- package/dist/vba/project-editor.js +4 -89
- package/dist/vba/project.js +2 -34
- package/dist/vba/vba-encoding.js +1 -17
- package/dist/xml/errors.js +0 -10
- package/dist/xml/xml-read.js +3 -82
- package/dist/xml/xml.js +0 -39
- package/package.json +8 -9
- package/skills/ts-xlsx-upstream/SKILL.md +178 -0
- /package/dist/io/xlsx/{pivot-read.d.ts → read-pivot.d.ts} +0 -0
- /package/dist/io/xlsx/{shared-strings-read.d.ts → read-shared-strings.d.ts} +0 -0
|
@@ -1,29 +1,10 @@
|
|
|
1
|
-
// The shared-strings table: `xl/sharedStrings.xml`, the workbook-wide pool a `t="s"` cell indexes.
|
|
2
|
-
//
|
|
3
|
-
// When the writer runs with `useSharedStrings`, a plain string cell value is interned here — an
|
|
4
|
-
// identical string is stored once and every cell holding it references the single `<si>` entry by
|
|
5
|
-
// index — rather than repeating the text inline in each cell. This trades a second part and an
|
|
6
|
-
// indirection for a smaller package when strings repeat, the storage Excel itself prefers.
|
|
7
|
-
//
|
|
8
|
-
// Both plain strings and rich text are pooled: a plain value becomes a `<si><t>…</t></si>` entry, a
|
|
9
|
-
// rich value a `<si><r>…</r>…</si>` entry carrying its per-run formatting — the rich `<si>` runs Excel
|
|
10
|
-
// itself writes. A `t="s"` cell then indexes either, and the reader reconstructs the runs, so pooled
|
|
11
|
-
// rich text round-trips its formatting rather than flattening to text.
|
|
12
1
|
import { textElement, XML_DECLARATION } from '../../xml/xml.js';
|
|
13
2
|
import { SPREADSHEETML_NS } from './namespaces.js';
|
|
14
3
|
import { richTextRunsXml } from './rich-text.js';
|
|
15
|
-
/**
|
|
16
|
-
* Interns cell string values into the shared-strings pool. {@link intern} returns the index a
|
|
17
|
-
* `t="s"` cell writes as its `<v>`; identical entries collapse to one, so `count` (total references)
|
|
18
|
-
* and `uniqueCount` (distinct entries) diverge exactly as Excel records them. Each entry is stored as
|
|
19
|
-
* its rendered `<si>` inner XML, which is also its dedup key — a plain string (`<t>…`) and rich runs
|
|
20
|
-
* (`<r>…`) render to distinct markup, so the two kinds never collide in the pool.
|
|
21
|
-
*/
|
|
22
4
|
export class SharedStringTable {
|
|
23
5
|
#indexByEntry = new Map();
|
|
24
6
|
#entries = [];
|
|
25
7
|
#references = 0;
|
|
26
|
-
/** Intern a plain or rich string and return its `<si>` index, reusing the entry when it repeats. */
|
|
27
8
|
intern(value) {
|
|
28
9
|
this.#references += 1;
|
|
29
10
|
const inner = typeof value === 'string' ? textElement(value) : richTextRunsXml(value.richText);
|
|
@@ -35,11 +16,9 @@ export class SharedStringTable {
|
|
|
35
16
|
this.#entries.push(inner);
|
|
36
17
|
return index;
|
|
37
18
|
}
|
|
38
|
-
/** Whether no string has been interned — the writer omits the part entirely when so. */
|
|
39
19
|
get isEmpty() {
|
|
40
20
|
return this.#entries.length === 0;
|
|
41
21
|
}
|
|
42
|
-
/** Serialise the pool as the `xl/sharedStrings.xml` part. */
|
|
43
22
|
toXml() {
|
|
44
23
|
const items = this.#entries.map((inner) => `<si>${inner}</si>`).join('');
|
|
45
24
|
return (XML_DECLARATION +
|
|
@@ -1,27 +1,14 @@
|
|
|
1
|
-
// The worksheet's non-cell property blocks: `<sheetPr>`, `<sheetViews>`, `<sheetProtection>`,
|
|
2
|
-
// `<autoFilter>`, and the print settings (`<printOptions>`, `<pageMargins>`, `<pageSetup>`,
|
|
3
|
-
// `<headerFooter>`, `<rowBreaks>`/`<colBreaks>`). Each renders one CT_Worksheet child (or child
|
|
4
|
-
// group) independently of the row/cell body `worksheet-xml.ts` orchestrates them alongside.
|
|
5
1
|
import { encodeAddress } from '../../core/address.js';
|
|
6
2
|
import { SHEET_PROTECTION_FLAGS } from '../../core/protection.js';
|
|
7
3
|
import { attr, boolAttr, escapeAttr, escapeText, numberText } from '../../xml/xml.js';
|
|
8
|
-
import { colorAttrs } from './
|
|
9
|
-
// `<sheetViews>` holds the sheet's single view. A frozen view adds a `<pane>` recording the split
|
|
10
|
-
// and a `<selection>` naming the pane the split activates, exactly as Excel writes it — a normal
|
|
11
|
-
// view carries neither, so unfreezing leaves no leftover `<pane>` that would trip a repair prompt.
|
|
12
|
-
// The active pane is whichever scrolling region the freeze creates: bottom-right when both axes are
|
|
13
|
-
// frozen, else top-right (columns only) or bottom-left (rows only).
|
|
14
|
-
//
|
|
15
|
-
// `active` marks this sheet as the one selected on open (`tabSelected`). Exactly one sheet in a
|
|
16
|
-
// workbook carries it — with none, the consumer opens with no sheet view initialised; with several,
|
|
17
|
-
// the sheets form a *group selection*, where an edit to one is applied to all of them. The caller
|
|
18
|
-
// (`worksheetXml`, fed from `Workbook.activeTabIndex`) is what guarantees the "exactly one".
|
|
4
|
+
import { colorAttrs } from './color-xml.js';
|
|
19
5
|
export function sheetViewsXml(view, active) {
|
|
20
6
|
const selected = active ? ' tabSelected="1"' : '';
|
|
7
|
+
const gridLines = view.showGridLines === false ? ' showGridLines="0"' : '';
|
|
21
8
|
const xSplit = view.xSplit ?? 0;
|
|
22
9
|
const ySplit = view.ySplit ?? 0;
|
|
23
10
|
if (view.state !== 'frozen' || (xSplit === 0 && ySplit === 0)) {
|
|
24
|
-
return `<sheetViews><sheetView${selected} workbookViewId="0"/></sheetViews>`;
|
|
11
|
+
return `<sheetViews><sheetView${gridLines}${selected} workbookViewId="0"/></sheetViews>`;
|
|
25
12
|
}
|
|
26
13
|
const topLeftCell = view.topLeftCell ?? encodeAddress(xSplit + 1, ySplit + 1);
|
|
27
14
|
const activePane = xSplit > 0 && ySplit > 0 ? 'bottomRight' : xSplit > 0 ? 'topRight' : 'bottomLeft';
|
|
@@ -30,41 +17,21 @@ export function sheetViewsXml(view, active) {
|
|
|
30
17
|
(ySplit > 0 ? ` ySplit="${ySplit}"` : '') +
|
|
31
18
|
` topLeftCell="${escapeAttr(topLeftCell)}" activePane="${activePane}" state="frozen"/>`;
|
|
32
19
|
const selection = `<selection pane="${activePane}" activeCell="${escapeAttr(topLeftCell)}" sqref="${escapeAttr(topLeftCell)}"/>`;
|
|
33
|
-
return `<sheetViews><sheetView${selected} workbookViewId="0">${pane}${selection}</sheetView></sheetViews>`;
|
|
20
|
+
return `<sheetViews><sheetView${gridLines}${selected} workbookViewId="0">${pane}${selection}</sheetView></sheetViews>`;
|
|
34
21
|
}
|
|
35
|
-
// `<sheetPr>` carries the sheet's appearance properties: the tab colour, the outline
|
|
36
|
-
// summary-position flags, and the fit-to-page flag. It is the first child of `<worksheet>` in
|
|
37
|
-
// CT_Worksheet order; its own children follow CT_SheetPr order — `<tabColor>`, `<outlinePr>`, then
|
|
38
|
-
// `<pageSetUpPr>`. Omitted entirely when the sheet carries none, so an unadorned sheet stays
|
|
39
|
-
// byte-clean.
|
|
40
22
|
export function sheetPrXml(sheet) {
|
|
41
23
|
const children = (sheet.tabColor !== undefined ? `<tabColor ${colorAttrs(sheet.tabColor)}/>` : '') +
|
|
42
24
|
outlinePrXml(sheet.outline) +
|
|
43
25
|
pageSetUpPrXml(sheet.pageSetup);
|
|
44
26
|
return children === '' ? '' : `<sheetPr>${children}</sheetPr>`;
|
|
45
27
|
}
|
|
46
|
-
// `<pageSetUpPr>` holds the fit-to-page toggle, which lives on the sheet properties rather than on
|
|
47
|
-
// `<pageSetup>` — Excel reads it from here to decide whether the `fitToWidth`/`fitToHeight` counts
|
|
48
|
-
// or the fixed `scale` govern printing. Emitted only when the author set the flag.
|
|
49
28
|
function pageSetUpPrXml(pageSetup) {
|
|
50
29
|
return pageSetup.fitToPage ? '<pageSetUpPr fitToPage="1"/>' : '';
|
|
51
30
|
}
|
|
52
|
-
// `<outlinePr>` carries only the summary-position flags today. Each is emitted solely when the
|
|
53
|
-
// caller set it, so an inverted placement (`summaryBelow="0"`) is honoured while an untouched sheet
|
|
54
|
-
// keeps the element out of the file entirely.
|
|
55
31
|
function outlinePrXml(outline) {
|
|
56
32
|
const attrs = boolAttr('summaryBelow', outline.summaryBelow) + boolAttr('summaryRight', outline.summaryRight);
|
|
57
33
|
return attrs === '' ? '' : `<outlinePr${attrs}/>`;
|
|
58
34
|
}
|
|
59
|
-
// Each sheet-protection flag maps to a `<sheetProtection>` attribute whose value is INVERTED
|
|
60
|
-
// from the author-facing allow-flag: the attribute records that an operation is *forbidden*
|
|
61
|
-
// ("1"), so `allow: true` serialises as "0". Only a value that differs from OOXML's per-
|
|
62
|
-
// attribute default (see SHEET_PROTECTION_FLAGS) is written — most editing operations default
|
|
63
|
-
// to forbidden under protection, while selecting cells defaults to permitted.
|
|
64
|
-
//
|
|
65
|
-
// <sheetProtection> is what makes the per-cell locked/hidden flags bite. `sheet="1"` marks the
|
|
66
|
-
// sheet protected; the password credential (when present) guards lifting it; the flag attributes
|
|
67
|
-
// carve out the operations that stay available. base64 salt/hash use only XML-safe characters.
|
|
68
35
|
export function sheetProtectionXml(protection) {
|
|
69
36
|
if (protection === undefined)
|
|
70
37
|
return '';
|
|
@@ -89,10 +56,6 @@ export function sheetProtectionXml(protection) {
|
|
|
89
56
|
}
|
|
90
57
|
return `<sheetProtection${attrs}/>`;
|
|
91
58
|
}
|
|
92
|
-
// The sheet's autofilter: `<autoFilter ref="A1:C10"/>` when it only draws dropdowns, or with nested
|
|
93
|
-
// `<filterColumn>` children when columns carry criteria. Its companion `_FilterDatabase` defined name
|
|
94
|
-
// (the range Excel derives filtering from) is written in the workbook part, so a sheet with no filter
|
|
95
|
-
// emits nothing here and nothing there.
|
|
96
59
|
export function autoFilterXml(filter) {
|
|
97
60
|
if (filter === undefined)
|
|
98
61
|
return '';
|
|
@@ -104,9 +67,6 @@ export function autoFilterXml(filter) {
|
|
|
104
67
|
function filterColumnXml(column) {
|
|
105
68
|
return `<filterColumn colId="${column.colId}">${filterCriteriaXml(column.criteria)}</filterColumn>`;
|
|
106
69
|
}
|
|
107
|
-
// A values filter is `<filters>` with a `<filter val>` per allowed value (and `blank="1"` to admit
|
|
108
|
-
// empty cells); a custom filter is `<customFilters>` with one or two `<customFilter operator val>`
|
|
109
|
-
// predicates, `and="1"` when they are AND-combined rather than OR.
|
|
110
70
|
function filterCriteriaXml(criteria) {
|
|
111
71
|
if (criteria.kind === 'values') {
|
|
112
72
|
const blankAttr = criteria.blank ? ' blank="1"' : '';
|
|
@@ -119,9 +79,6 @@ function filterCriteriaXml(criteria) {
|
|
|
119
79
|
.join('');
|
|
120
80
|
return `<customFilters${andAttr}>${predicates}</customFilters>`;
|
|
121
81
|
}
|
|
122
|
-
// CT_HeaderFooter child order, paired with the flag their presence gates: the even- and
|
|
123
|
-
// first-page variants are silently ignored by Excel unless differentOddEven / differentFirst
|
|
124
|
-
// are set, so the writer derives each flag from whether any variant in its class was provided.
|
|
125
82
|
const HF_CHILDREN = [
|
|
126
83
|
{ tag: 'oddHeader', key: 'oddHeader' },
|
|
127
84
|
{ tag: 'oddFooter', key: 'oddFooter' },
|
|
@@ -146,7 +103,6 @@ export function headerFooterXml(hf) {
|
|
|
146
103
|
.join('');
|
|
147
104
|
return `<headerFooter${attrs}>${body}</headerFooter>`;
|
|
148
105
|
}
|
|
149
|
-
// Excel's "Normal" margins, in inches — the defaults Excel writes for an untouched sheet.
|
|
150
106
|
const DEFAULT_MARGINS = {
|
|
151
107
|
left: 0.7,
|
|
152
108
|
right: 0.7,
|
|
@@ -156,10 +112,6 @@ const DEFAULT_MARGINS = {
|
|
|
156
112
|
footer: 0.3,
|
|
157
113
|
};
|
|
158
114
|
const MARGIN_SIDES = ['left', 'right', 'top', 'bottom', 'header', 'footer'];
|
|
159
|
-
// `<printOptions>` carries the print-toggle flags and sits just before `<pageMargins>` in
|
|
160
|
-
// CT_Worksheet order. Each attribute is emitted only when the model carries it — as an explicit
|
|
161
|
-
// `="1"`/`="0"` so a caller can force a flag off against Excel's default — and an untouched sheet
|
|
162
|
-
// keeps the element out of the file entirely.
|
|
163
115
|
export function printOptionsXml(printOptions) {
|
|
164
116
|
const attrs = boolAttr('horizontalCentered', printOptions.horizontalCentered) +
|
|
165
117
|
boolAttr('verticalCentered', printOptions.verticalCentered) +
|
|
@@ -168,21 +120,12 @@ export function printOptionsXml(printOptions) {
|
|
|
168
120
|
boolAttr('gridLinesSet', printOptions.gridLinesSet);
|
|
169
121
|
return attrs === '' ? '' : `<printOptions${attrs}/>`;
|
|
170
122
|
}
|
|
171
|
-
// OOXML's <pageMargins> is all-or-nothing: setting any one margin requires all six, or Excel
|
|
172
|
-
// repairs the file. So the element is emitted only when the caller set at least one, and the
|
|
173
|
-
// untouched sides fall back to the Normal-preset defaults.
|
|
174
123
|
export function pageMarginsXml(margins) {
|
|
175
124
|
if (MARGIN_SIDES.every((side) => margins[side] === undefined))
|
|
176
125
|
return '';
|
|
177
126
|
const attrs = MARGIN_SIDES.map((side) => `${side}="${numberText(margins[side] ?? DEFAULT_MARGINS[side])}"`).join(' ');
|
|
178
127
|
return `<pageMargins ${attrs}/>`;
|
|
179
128
|
}
|
|
180
|
-
// `<pageSetup>` carries the print-scaling attributes (all but `fitToPage`, which is a `<sheetPr>`
|
|
181
|
-
// flag). It sits between `<pageMargins>` and `<headerFooter>` in CT_Worksheet order. Each attribute
|
|
182
|
-
// is emitted only when the author set it, so an untouched sheet keeps the element out of the file
|
|
183
|
-
// and a partially-set one never fabricates the counts Excel would otherwise default. A non-null
|
|
184
|
-
// `printerSettingsRelId` links the sheet's opaque printer-settings blob and forces the element out
|
|
185
|
-
// even when no scaling attribute is set — the reference is the only thing the model has to carry.
|
|
186
129
|
export function pageSetupXml(pageSetup, printerSettingsRelId) {
|
|
187
130
|
const attrs = attr('paperSize', pageSetup.paperSize) +
|
|
188
131
|
attr('scale', pageSetup.scale) +
|
|
@@ -193,11 +136,6 @@ export function pageSetupXml(pageSetup, printerSettingsRelId) {
|
|
|
193
136
|
(printerSettingsRelId !== null ? ` r:id="${printerSettingsRelId}"` : '');
|
|
194
137
|
return attrs === '' ? '' : `<pageSetup${attrs}/>`;
|
|
195
138
|
}
|
|
196
|
-
// Manual page breaks (`<rowBreaks>`/`<colBreaks>`): one `<brk>` per row/column the layout splits
|
|
197
|
-
// before. Excel records both the running total (`count`) and the manual subset (`manualBreakCount`);
|
|
198
|
-
// every break the model carries is a manual, author-set one, so the two counts coincide. `max` bounds
|
|
199
|
-
// the break across the other axis (Excel writes the last row/column index); a break without one is
|
|
200
|
-
// emitted bare. Row and column breaks share this shape, differing only in the wrapping element.
|
|
201
139
|
export function pageBreaksXml(breaks, element) {
|
|
202
140
|
if (breaks.length === 0)
|
|
203
141
|
return '';
|
package/dist/io/xlsx/styles.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Alignment, type Border, type
|
|
1
|
+
import { type Alignment, type Border, type DifferentialStyle, type Fill, type Font, type NamedCellStyle, type Protection, type TableStyleTable } from '../../core/style.ts';
|
|
2
2
|
import { type TableStyle } from '../../core/table-style.ts';
|
|
3
3
|
/** A cell's style facets as the writer composes them: cell overrides atop row/column defaults. */
|
|
4
4
|
export interface CellStyle {
|
|
@@ -106,33 +106,5 @@ export declare class StyleRegistry {
|
|
|
106
106
|
/** Serialise the accumulated table into a complete, valid styles.xml part. */
|
|
107
107
|
toXml(): string;
|
|
108
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
109
|
export declare function fontXml(font: Font, nameTag?: 'name' | 'rFont'): string;
|
|
134
110
|
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;
|