@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.
Files changed (223) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +230 -0
  3. package/dist/core/address.d.ts +49 -0
  4. package/dist/core/address.js +125 -0
  5. package/dist/core/autofilter.d.ts +55 -0
  6. package/dist/core/autofilter.js +48 -0
  7. package/dist/core/cell.d.ts +132 -0
  8. package/dist/core/cell.js +249 -0
  9. package/dist/core/color-resolution.d.ts +58 -0
  10. package/dist/core/color-resolution.js +170 -0
  11. package/dist/core/column.d.ts +87 -0
  12. package/dist/core/column.js +167 -0
  13. package/dist/core/comment-thread.d.ts +116 -0
  14. package/dist/core/comment-thread.js +62 -0
  15. package/dist/core/conditional-formatting-overlay.d.ts +15 -0
  16. package/dist/core/conditional-formatting-overlay.js +24 -0
  17. package/dist/core/conditional-formatting.d.ts +70 -0
  18. package/dist/core/conditional-formatting.js +35 -0
  19. package/dist/core/containers.d.ts +2 -0
  20. package/dist/core/containers.js +25 -0
  21. package/dist/core/data-validation-overlay.d.ts +28 -0
  22. package/dist/core/data-validation-overlay.js +56 -0
  23. package/dist/core/data-validation.d.ts +38 -0
  24. package/dist/core/data-validation.js +13 -0
  25. package/dist/core/date.d.ts +25 -0
  26. package/dist/core/date.js +58 -0
  27. package/dist/core/formula.d.ts +49 -0
  28. package/dist/core/formula.js +319 -0
  29. package/dist/core/grid-edits.d.ts +22 -0
  30. package/dist/core/grid-edits.js +206 -0
  31. package/dist/core/image.d.ts +76 -0
  32. package/dist/core/image.js +65 -0
  33. package/dist/core/internal.d.ts +11 -0
  34. package/dist/core/internal.js +29 -0
  35. package/dist/core/merge.d.ts +13 -0
  36. package/dist/core/merge.js +26 -0
  37. package/dist/core/modern-functions.d.ts +1 -0
  38. package/dist/core/modern-functions.js +165 -0
  39. package/dist/core/page-setup.d.ts +94 -0
  40. package/dist/core/page-setup.js +6 -0
  41. package/dist/core/pivot-table.d.ts +113 -0
  42. package/dist/core/pivot-table.js +249 -0
  43. package/dist/core/preserved.d.ts +58 -0
  44. package/dist/core/preserved.js +5 -0
  45. package/dist/core/protection.d.ts +67 -0
  46. package/dist/core/protection.js +68 -0
  47. package/dist/core/range.d.ts +112 -0
  48. package/dist/core/range.js +283 -0
  49. package/dist/core/row.d.ts +73 -0
  50. package/dist/core/row.js +135 -0
  51. package/dist/core/style.d.ts +246 -0
  52. package/dist/core/style.js +125 -0
  53. package/dist/core/table-style.d.ts +67 -0
  54. package/dist/core/table-style.js +90 -0
  55. package/dist/core/table.d.ts +194 -0
  56. package/dist/core/table.js +291 -0
  57. package/dist/core/theme.d.ts +90 -0
  58. package/dist/core/theme.js +272 -0
  59. package/dist/core/value.d.ts +115 -0
  60. package/dist/core/value.js +144 -0
  61. package/dist/core/workbook-protection.d.ts +27 -0
  62. package/dist/core/workbook-protection.js +25 -0
  63. package/dist/core/workbook.d.ts +528 -0
  64. package/dist/core/workbook.js +732 -0
  65. package/dist/core/worksheet-model.d.ts +34 -0
  66. package/dist/core/worksheet-model.js +100 -0
  67. package/dist/core/worksheet.d.ts +647 -0
  68. package/dist/core/worksheet.js +1025 -0
  69. package/dist/customui/errors.d.ts +15 -0
  70. package/dist/customui/errors.js +15 -0
  71. package/dist/customui/index.d.ts +2 -0
  72. package/dist/customui/index.js +7 -0
  73. package/dist/customui/ribbon.d.ts +86 -0
  74. package/dist/customui/ribbon.js +180 -0
  75. package/dist/entries/core.d.ts +23 -0
  76. package/dist/entries/core.js +20 -0
  77. package/dist/entries/csv.d.ts +2 -0
  78. package/dist/entries/csv.js +6 -0
  79. package/dist/entries/customui.d.ts +1 -0
  80. package/dist/entries/customui.js +3 -0
  81. package/dist/entries/errors.d.ts +7 -0
  82. package/dist/entries/errors.js +20 -0
  83. package/dist/entries/vba.d.ts +2 -0
  84. package/dist/entries/vba.js +7 -0
  85. package/dist/entries/xlsb.d.ts +1 -0
  86. package/dist/entries/xlsb.js +7 -0
  87. package/dist/entries/xlsx.d.ts +5 -0
  88. package/dist/entries/xlsx.js +18 -0
  89. package/dist/errors.d.ts +65 -0
  90. package/dist/errors.js +66 -0
  91. package/dist/index.d.ts +7 -0
  92. package/dist/index.js +19 -0
  93. package/dist/io/csv/read.d.ts +15 -0
  94. package/dist/io/csv/read.js +113 -0
  95. package/dist/io/csv/write.d.ts +28 -0
  96. package/dist/io/csv/write.js +124 -0
  97. package/dist/io/opc/errors.d.ts +46 -0
  98. package/dist/io/opc/errors.js +49 -0
  99. package/dist/io/opc/inflate.d.ts +15 -0
  100. package/dist/io/opc/inflate.js +91 -0
  101. package/dist/io/opc/namespaces.d.ts +18 -0
  102. package/dist/io/opc/namespaces.js +18 -0
  103. package/dist/io/opc/part-paths.d.ts +4 -0
  104. package/dist/io/opc/part-paths.js +35 -0
  105. package/dist/io/opc/read-opc.d.ts +24 -0
  106. package/dist/io/opc/read-opc.js +153 -0
  107. package/dist/io/opc/read-options.d.ts +10 -0
  108. package/dist/io/opc/read-options.js +7 -0
  109. package/dist/io/opc/rels.d.ts +15 -0
  110. package/dist/io/opc/rels.js +28 -0
  111. package/dist/io/opc/sniff-format.d.ts +27 -0
  112. package/dist/io/opc/sniff-format.js +92 -0
  113. package/dist/io/style/xf-style.d.ts +47 -0
  114. package/dist/io/style/xf-style.js +95 -0
  115. package/dist/io/xlsb/errors.d.ts +15 -0
  116. package/dist/io/xlsb/errors.js +15 -0
  117. package/dist/io/xlsb/formula.d.ts +48 -0
  118. package/dist/io/xlsb/formula.js +398 -0
  119. package/dist/io/xlsb/primitives.d.ts +86 -0
  120. package/dist/io/xlsb/primitives.js +230 -0
  121. package/dist/io/xlsb/ptg-functions.d.ts +16 -0
  122. package/dist/io/xlsb/ptg-functions.js +659 -0
  123. package/dist/io/xlsb/read-shared-strings.d.ts +2 -0
  124. package/dist/io/xlsb/read-shared-strings.js +22 -0
  125. package/dist/io/xlsb/read-styles.d.ts +4 -0
  126. package/dist/io/xlsb/read-styles.js +386 -0
  127. package/dist/io/xlsb/read-worksheet.d.ts +9 -0
  128. package/dist/io/xlsb/read-worksheet.js +301 -0
  129. package/dist/io/xlsb/read.d.ts +20 -0
  130. package/dist/io/xlsb/read.js +199 -0
  131. package/dist/io/xlsb/record-stream.d.ts +14 -0
  132. package/dist/io/xlsb/record-stream.js +56 -0
  133. package/dist/io/xlsb/record-types.d.ts +55 -0
  134. package/dist/io/xlsb/record-types.js +73 -0
  135. package/dist/io/xlsx/cell-accumulator.d.ts +25 -0
  136. package/dist/io/xlsx/cell-accumulator.js +172 -0
  137. package/dist/io/xlsx/cell-value.d.ts +32 -0
  138. package/dist/io/xlsx/cell-value.js +85 -0
  139. package/dist/io/xlsx/comments.d.ts +74 -0
  140. package/dist/io/xlsx/comments.js +243 -0
  141. package/dist/io/xlsx/conditional-formatting.d.ts +32 -0
  142. package/dist/io/xlsx/conditional-formatting.js +464 -0
  143. package/dist/io/xlsx/data-validation.d.ts +20 -0
  144. package/dist/io/xlsx/data-validation.js +258 -0
  145. package/dist/io/xlsx/edit-vba.d.ts +23 -0
  146. package/dist/io/xlsx/edit-vba.js +139 -0
  147. package/dist/io/xlsx/errors.d.ts +17 -0
  148. package/dist/io/xlsx/errors.js +17 -0
  149. package/dist/io/xlsx/hyperlinks.d.ts +42 -0
  150. package/dist/io/xlsx/hyperlinks.js +139 -0
  151. package/dist/io/xlsx/images.d.ts +34 -0
  152. package/dist/io/xlsx/images.js +218 -0
  153. package/dist/io/xlsx/namespaces.d.ts +55 -0
  154. package/dist/io/xlsx/namespaces.js +55 -0
  155. package/dist/io/xlsx/package-plan.d.ts +103 -0
  156. package/dist/io/xlsx/package-plan.js +168 -0
  157. package/dist/io/xlsx/pivot-read.d.ts +5 -0
  158. package/dist/io/xlsx/pivot-read.js +134 -0
  159. package/dist/io/xlsx/pivot.d.ts +12 -0
  160. package/dist/io/xlsx/pivot.js +141 -0
  161. package/dist/io/xlsx/read-rows.d.ts +85 -0
  162. package/dist/io/xlsx/read-rows.js +286 -0
  163. package/dist/io/xlsx/read-styles.d.ts +8 -0
  164. package/dist/io/xlsx/read-styles.js +551 -0
  165. package/dist/io/xlsx/read-worksheet.d.ts +4 -0
  166. package/dist/io/xlsx/read-worksheet.js +528 -0
  167. package/dist/io/xlsx/read.d.ts +32 -0
  168. package/dist/io/xlsx/read.js +680 -0
  169. package/dist/io/xlsx/relationships.d.ts +33 -0
  170. package/dist/io/xlsx/relationships.js +47 -0
  171. package/dist/io/xlsx/rich-runs.d.ts +13 -0
  172. package/dist/io/xlsx/rich-runs.js +59 -0
  173. package/dist/io/xlsx/rich-text.d.ts +7 -0
  174. package/dist/io/xlsx/rich-text.js +23 -0
  175. package/dist/io/xlsx/shared-formulas.d.ts +6 -0
  176. package/dist/io/xlsx/shared-formulas.js +52 -0
  177. package/dist/io/xlsx/shared-strings-read.d.ts +2 -0
  178. package/dist/io/xlsx/shared-strings-read.js +70 -0
  179. package/dist/io/xlsx/shared-strings.d.ts +17 -0
  180. package/dist/io/xlsx/shared-strings.js +50 -0
  181. package/dist/io/xlsx/sheet-properties.d.ts +13 -0
  182. package/dist/io/xlsx/sheet-properties.js +211 -0
  183. package/dist/io/xlsx/styles.d.ts +138 -0
  184. package/dist/io/xlsx/styles.js +821 -0
  185. package/dist/io/xlsx/tables.d.ts +9 -0
  186. package/dist/io/xlsx/tables.js +208 -0
  187. package/dist/io/xlsx/threaded-comments.d.ts +102 -0
  188. package/dist/io/xlsx/threaded-comments.js +308 -0
  189. package/dist/io/xlsx/workbook-xml.d.ts +12 -0
  190. package/dist/io/xlsx/workbook-xml.js +353 -0
  191. package/dist/io/xlsx/worksheet-xml.d.ts +86 -0
  192. package/dist/io/xlsx/worksheet-xml.js +643 -0
  193. package/dist/io/xlsx/write-stream.d.ts +171 -0
  194. package/dist/io/xlsx/write-stream.js +399 -0
  195. package/dist/io/xlsx/write.d.ts +81 -0
  196. package/dist/io/xlsx/write.js +396 -0
  197. package/dist/io/xlsx/x14-ext.d.ts +9 -0
  198. package/dist/io/xlsx/x14-ext.js +12 -0
  199. package/dist/vba/cfb-writer.d.ts +19 -0
  200. package/dist/vba/cfb-writer.js +277 -0
  201. package/dist/vba/cfb.d.ts +16 -0
  202. package/dist/vba/cfb.js +324 -0
  203. package/dist/vba/codepage.d.ts +18 -0
  204. package/dist/vba/codepage.js +87 -0
  205. package/dist/vba/errors.d.ts +24 -0
  206. package/dist/vba/errors.js +24 -0
  207. package/dist/vba/index.d.ts +5 -0
  208. package/dist/vba/index.js +15 -0
  209. package/dist/vba/ms-ovba.d.ts +12 -0
  210. package/dist/vba/ms-ovba.js +176 -0
  211. package/dist/vba/project-editor.d.ts +62 -0
  212. package/dist/vba/project-editor.js +377 -0
  213. package/dist/vba/project.d.ts +45 -0
  214. package/dist/vba/project.js +160 -0
  215. package/dist/vba/vba-encoding.d.ts +14 -0
  216. package/dist/vba/vba-encoding.js +39 -0
  217. package/dist/xml/errors.d.ts +15 -0
  218. package/dist/xml/errors.js +15 -0
  219. package/dist/xml/xml-read.d.ts +107 -0
  220. package/dist/xml/xml-read.js +283 -0
  221. package/dist/xml/xml.d.ts +41 -0
  222. package/dist/xml/xml.js +86 -0
  223. 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;