@office-kit/xlsx 0.8.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 (220) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +319 -0
  3. package/THIRD_PARTY_NOTICES.md +56 -0
  4. package/dist/cell/cell.d.ts +234 -0
  5. package/dist/cell/index.d.ts +4 -0
  6. package/dist/cell/rich-text.d.ts +37 -0
  7. package/dist/cell-D9CaNKnU.mjs +320 -0
  8. package/dist/cell-D9CaNKnU.mjs.map +1 -0
  9. package/dist/cell-style-BEDjMX1y.mjs +1579 -0
  10. package/dist/cell-style-BEDjMX1y.mjs.map +1 -0
  11. package/dist/cell.mjs +2 -0
  12. package/dist/chart/chart-xml.d.ts +16 -0
  13. package/dist/chart/chart.d.ts +735 -0
  14. package/dist/chart/cx/chartex-xml.d.ts +6 -0
  15. package/dist/chart/cx/chartex.d.ts +279 -0
  16. package/dist/chart/index.d.ts +6 -0
  17. package/dist/chart/user-shapes-xml.d.ts +4 -0
  18. package/dist/chart/user-shapes.d.ts +61 -0
  19. package/dist/chart.mjs +232 -0
  20. package/dist/chart.mjs.map +1 -0
  21. package/dist/chartsheet/chartsheet-xml.d.ts +17 -0
  22. package/dist/chartsheet/chartsheet.d.ts +121 -0
  23. package/dist/chartsheet/index.d.ts +2 -0
  24. package/dist/chartsheet-C3-tqkPy.mjs +23 -0
  25. package/dist/chartsheet-C3-tqkPy.mjs.map +1 -0
  26. package/dist/chartsheet.mjs +2 -0
  27. package/dist/colors-ovWAwnZI.mjs +67 -0
  28. package/dist/colors-ovWAwnZI.mjs.map +1 -0
  29. package/dist/compat/numbers.d.ts +14 -0
  30. package/dist/coordinate-96Ecci4d.mjs +276 -0
  31. package/dist/coordinate-96Ecci4d.mjs.map +1 -0
  32. package/dist/datetime-B2ySVlXt.mjs +71 -0
  33. package/dist/datetime-B2ySVlXt.mjs.map +1 -0
  34. package/dist/defined-names-CviWmtQg.mjs +89 -0
  35. package/dist/defined-names-CviWmtQg.mjs.map +1 -0
  36. package/dist/differential-D4dg-qtZ.mjs +37 -0
  37. package/dist/differential-D4dg-qtZ.mjs.map +1 -0
  38. package/dist/drawing/anchor.d.ts +63 -0
  39. package/dist/drawing/dml/colors.d.ts +109 -0
  40. package/dist/drawing/dml/dml-xml.d.ts +35 -0
  41. package/dist/drawing/dml/effect.d.ts +92 -0
  42. package/dist/drawing/dml/fill.d.ts +115 -0
  43. package/dist/drawing/dml/geometry.d.ts +113 -0
  44. package/dist/drawing/dml/line.d.ts +41 -0
  45. package/dist/drawing/dml/shape-properties.d.ts +33 -0
  46. package/dist/drawing/dml/text.d.ts +218 -0
  47. package/dist/drawing/drawing-xml.d.ts +5 -0
  48. package/dist/drawing/drawing.d.ts +117 -0
  49. package/dist/drawing/image.d.ts +40 -0
  50. package/dist/drawing/index.d.ts +14 -0
  51. package/dist/drawing-BxzLuryn.mjs +415 -0
  52. package/dist/drawing-BxzLuryn.mjs.map +1 -0
  53. package/dist/drawing.mjs +119 -0
  54. package/dist/drawing.mjs.map +1 -0
  55. package/dist/escape-DFTE7ZJc.mjs +51 -0
  56. package/dist/escape-DFTE7ZJc.mjs.map +1 -0
  57. package/dist/exceptions-D-CFwxgm.mjs +37 -0
  58. package/dist/exceptions-D-CFwxgm.mjs.map +1 -0
  59. package/dist/formula/tokenizer.d.ts +61 -0
  60. package/dist/formula/translate.d.ts +67 -0
  61. package/dist/inference-B3ES3KEJ.mjs +42 -0
  62. package/dist/inference-B3ES3KEJ.mjs.map +1 -0
  63. package/dist/io/browser.d.ts +41 -0
  64. package/dist/io/index.d.ts +7 -0
  65. package/dist/io/load.d.ts +46 -0
  66. package/dist/io/node-fs.d.ts +62 -0
  67. package/dist/io/node-save.d.ts +3 -0
  68. package/dist/io/node.d.ts +17 -0
  69. package/dist/io/save.d.ts +14 -0
  70. package/dist/io/sink.d.ts +54 -0
  71. package/dist/io/source.d.ts +14 -0
  72. package/dist/io.mjs +212 -0
  73. package/dist/io.mjs.map +1 -0
  74. package/dist/load-D5cbhoGx.mjs +1069 -0
  75. package/dist/load-D5cbhoGx.mjs.map +1 -0
  76. package/dist/manifest-Dps1-OpP.mjs +801 -0
  77. package/dist/manifest-Dps1-OpP.mjs.map +1 -0
  78. package/dist/node.d.ts +3 -0
  79. package/dist/node.mjs +308 -0
  80. package/dist/node.mjs.map +1 -0
  81. package/dist/packaging/core.d.ts +45 -0
  82. package/dist/packaging/custom.d.ts +62 -0
  83. package/dist/packaging/extended.d.ts +45 -0
  84. package/dist/packaging/index.d.ts +10 -0
  85. package/dist/packaging/manifest.d.ts +24 -0
  86. package/dist/packaging/relationships.d.ts +30 -0
  87. package/dist/packaging.mjs +2 -0
  88. package/dist/parser-DuLejQy1.mjs +156 -0
  89. package/dist/parser-DuLejQy1.mjs.map +1 -0
  90. package/dist/reader-D1fNW9k1.mjs +534 -0
  91. package/dist/reader-D1fNW9k1.mjs.map +1 -0
  92. package/dist/save-RohQtgEZ.mjs +745 -0
  93. package/dist/save-RohQtgEZ.mjs.map +1 -0
  94. package/dist/schema/core.d.ts +133 -0
  95. package/dist/schema/index.d.ts +3 -0
  96. package/dist/schema/serialize.d.ts +6 -0
  97. package/dist/schema.mjs +2 -0
  98. package/dist/serialize-55EnT30e.mjs +254 -0
  99. package/dist/serialize-55EnT30e.mjs.map +1 -0
  100. package/dist/serializer-BwbgHYJV.mjs +116 -0
  101. package/dist/serializer-BwbgHYJV.mjs.map +1 -0
  102. package/dist/streaming/index.d.ts +2 -0
  103. package/dist/streaming/read-only.d.ts +38 -0
  104. package/dist/streaming/write-only.d.ts +47 -0
  105. package/dist/streaming.mjs +612 -0
  106. package/dist/streaming.mjs.map +1 -0
  107. package/dist/styles/alignment.d.ts +33 -0
  108. package/dist/styles/alignment.schema.d.ts +3 -0
  109. package/dist/styles/borders.d.ts +40 -0
  110. package/dist/styles/borders.schema.d.ts +4 -0
  111. package/dist/styles/cell-style.d.ts +270 -0
  112. package/dist/styles/colors.d.ts +128 -0
  113. package/dist/styles/colors.schema.d.ts +3 -0
  114. package/dist/styles/differential.d.ts +41 -0
  115. package/dist/styles/fills.d.ts +54 -0
  116. package/dist/styles/fills.schema.d.ts +6 -0
  117. package/dist/styles/fonts.d.ts +44 -0
  118. package/dist/styles/fonts.schema.d.ts +3 -0
  119. package/dist/styles/index.d.ts +21 -0
  120. package/dist/styles/named-styles.d.ts +52 -0
  121. package/dist/styles/numbers.d.ts +39 -0
  122. package/dist/styles/numbers.schema.d.ts +3 -0
  123. package/dist/styles/protection.d.ts +9 -0
  124. package/dist/styles/protection.schema.d.ts +3 -0
  125. package/dist/styles/stylesheet-reader.d.ts +7 -0
  126. package/dist/styles/stylesheet-writer.d.ts +3 -0
  127. package/dist/styles/stylesheet.d.ts +95 -0
  128. package/dist/styles.mjs +4 -0
  129. package/dist/stylesheet-writer-C2eRmn22.mjs +8624 -0
  130. package/dist/stylesheet-writer-C2eRmn22.mjs.map +1 -0
  131. package/dist/table-DkX6UniA.mjs +113 -0
  132. package/dist/table-DkX6UniA.mjs.map +1 -0
  133. package/dist/tree-Bbs1C8Rc.mjs +192 -0
  134. package/dist/tree-Bbs1C8Rc.mjs.map +1 -0
  135. package/dist/units-rOMQqXh2.mjs +41 -0
  136. package/dist/units-rOMQqXh2.mjs.map +1 -0
  137. package/dist/user-shapes-DfmCGKB0.mjs +252 -0
  138. package/dist/user-shapes-DfmCGKB0.mjs.map +1 -0
  139. package/dist/utf8-D91g1XTG.mjs +143 -0
  140. package/dist/utf8-D91g1XTG.mjs.map +1 -0
  141. package/dist/utils/coordinate.d.ts +103 -0
  142. package/dist/utils/css.d.ts +18 -0
  143. package/dist/utils/datetime.d.ts +38 -0
  144. package/dist/utils/escape.d.ts +34 -0
  145. package/dist/utils/exceptions.d.ts +34 -0
  146. package/dist/utils/index.d.ts +11 -0
  147. package/dist/utils/inference.d.ts +24 -0
  148. package/dist/utils/stable-stringify.d.ts +7 -0
  149. package/dist/utils/units.d.ts +14 -0
  150. package/dist/utils/utf8.d.ts +1 -0
  151. package/dist/utils.mjs +39 -0
  152. package/dist/utils.mjs.map +1 -0
  153. package/dist/workbook/calc-properties.d.ts +47 -0
  154. package/dist/workbook/defined-names.d.ts +121 -0
  155. package/dist/workbook/file-recovery.d.ts +11 -0
  156. package/dist/workbook/file-sharing.d.ts +14 -0
  157. package/dist/workbook/file-version.d.ts +13 -0
  158. package/dist/workbook/function-groups.d.ts +10 -0
  159. package/dist/workbook/index.d.ts +24 -0
  160. package/dist/workbook/protection.d.ts +35 -0
  161. package/dist/workbook/shared-strings.d.ts +57 -0
  162. package/dist/workbook/smart-tags.d.ts +13 -0
  163. package/dist/workbook/views.d.ts +89 -0
  164. package/dist/workbook/workbook-properties.d.ts +57 -0
  165. package/dist/workbook/workbook.d.ts +643 -0
  166. package/dist/workbook-HGYNRBlV.mjs +636 -0
  167. package/dist/workbook-HGYNRBlV.mjs.map +1 -0
  168. package/dist/workbook.mjs +58 -0
  169. package/dist/workbook.mjs.map +1 -0
  170. package/dist/worksheet/auto-filter.d.ts +34 -0
  171. package/dist/worksheet/cell-range.d.ts +121 -0
  172. package/dist/worksheet/comments-xml.d.ts +24 -0
  173. package/dist/worksheet/comments.d.ts +13 -0
  174. package/dist/worksheet/conditional-formatting.d.ts +150 -0
  175. package/dist/worksheet/custom-sheet-views.d.ts +43 -0
  176. package/dist/worksheet/data-consolidate.d.ts +29 -0
  177. package/dist/worksheet/data-validations.d.ts +72 -0
  178. package/dist/worksheet/dimensions.d.ts +40 -0
  179. package/dist/worksheet/errors.d.ts +40 -0
  180. package/dist/worksheet/hyperlinks.d.ts +42 -0
  181. package/dist/worksheet/index.d.ts +46 -0
  182. package/dist/worksheet/ole-objects.d.ts +37 -0
  183. package/dist/worksheet/page-setup.d.ts +173 -0
  184. package/dist/worksheet/phonetic.d.ts +11 -0
  185. package/dist/worksheet/properties.d.ts +34 -0
  186. package/dist/worksheet/protected-ranges.d.ts +19 -0
  187. package/dist/worksheet/protection.d.ts +44 -0
  188. package/dist/worksheet/reader.d.ts +38 -0
  189. package/dist/worksheet/scenarios.d.ts +36 -0
  190. package/dist/worksheet/smart-tags.d.ts +23 -0
  191. package/dist/worksheet/sort-state.d.ts +28 -0
  192. package/dist/worksheet/table-xml.d.ts +5 -0
  193. package/dist/worksheet/table.d.ts +80 -0
  194. package/dist/worksheet/views.d.ts +47 -0
  195. package/dist/worksheet/web-publish.d.ts +21 -0
  196. package/dist/worksheet/worksheet.d.ts +935 -0
  197. package/dist/worksheet/writer.d.ts +72 -0
  198. package/dist/worksheet-CmCNoIgD.mjs +1726 -0
  199. package/dist/worksheet-CmCNoIgD.mjs.map +1 -0
  200. package/dist/worksheet.mjs +247 -0
  201. package/dist/worksheet.mjs.map +1 -0
  202. package/dist/writer-DspzfkNA.mjs +221 -0
  203. package/dist/writer-DspzfkNA.mjs.map +1 -0
  204. package/dist/xml/index.d.ts +10 -0
  205. package/dist/xml/iterparse.d.ts +22 -0
  206. package/dist/xml/namespaces.d.ts +91 -0
  207. package/dist/xml/parser.d.ts +7 -0
  208. package/dist/xml/serializer.d.ts +14 -0
  209. package/dist/xml/stream-writer.d.ts +39 -0
  210. package/dist/xml/tree.d.ts +37 -0
  211. package/dist/xml.mjs +140 -0
  212. package/dist/xml.mjs.map +1 -0
  213. package/dist/zip/decompression-guard.d.ts +70 -0
  214. package/dist/zip/index.d.ts +6 -0
  215. package/dist/zip/random-access-reader.d.ts +16 -0
  216. package/dist/zip/reader.d.ts +45 -0
  217. package/dist/zip/writer.d.ts +65 -0
  218. package/dist/zip/zip64-patch.d.ts +12 -0
  219. package/dist/zip.mjs +3 -0
  220. package/package.json +147 -0
@@ -0,0 +1,54 @@
1
+ import { type Color } from './colors';
2
+ /** Predefined Excel pattern types. `'none'` lives here too as an explicit value. */
3
+ export type PatternType = 'none' | 'solid' | 'darkDown' | 'darkGray' | 'darkGrid' | 'darkHorizontal' | 'darkTrellis' | 'darkUp' | 'darkVertical' | 'gray0625' | 'gray125' | 'lightDown' | 'lightGray' | 'lightGrid' | 'lightHorizontal' | 'lightTrellis' | 'lightUp' | 'lightVertical' | 'mediumGray';
4
+ export declare const PATTERN_TYPES: ReadonlyArray<PatternType>;
5
+ export interface PatternFill {
6
+ readonly kind: 'pattern';
7
+ readonly patternType?: PatternType;
8
+ readonly fgColor?: Color;
9
+ readonly bgColor?: Color;
10
+ }
11
+ export declare function makePatternFill(opts?: Partial<Omit<PatternFill, 'kind'>>): PatternFill;
12
+ export interface GradientStop {
13
+ /** 0..1 ratio along the gradient. */
14
+ readonly position: number;
15
+ readonly color: Color;
16
+ }
17
+ export type GradientFillType = 'linear' | 'path';
18
+ export interface GradientFill {
19
+ readonly kind: 'gradient';
20
+ readonly type: GradientFillType;
21
+ /** Rotation angle (degrees). Ignored when `type === 'path'`. */
22
+ readonly degree?: number;
23
+ /** path-mode insets (0..1 from each edge). */
24
+ readonly left?: number;
25
+ readonly right?: number;
26
+ readonly top?: number;
27
+ readonly bottom?: number;
28
+ /** Colour stops along the gradient. */
29
+ readonly stops: ReadonlyArray<GradientStop>;
30
+ }
31
+ export declare function makeGradientStop(position: number, color: Color | Partial<Color>): GradientStop;
32
+ export declare function makeGradientFill(opts?: Partial<Omit<GradientFill, 'kind'>>): GradientFill;
33
+ export type Fill = PatternFill | GradientFill;
34
+ /**
35
+ * Single-arg constructor that defers to the variant-specific maker based on
36
+ * `kind`. Useful when the caller has a plain object in hand and wants the
37
+ * freeze invariant applied uniformly.
38
+ */
39
+ export declare function makeFill(opts: Partial<PatternFill> | Partial<GradientFill>): Fill;
40
+ /** The empty PatternFill — Excel's default cellXf[0] points here. */
41
+ export declare const DEFAULT_EMPTY_FILL: Fill;
42
+ /** The 'gray125' PatternFill — Excel's default cellXf[1]. */
43
+ export declare const DEFAULT_GRAY_FILL: Fill;
44
+ /**
45
+ * Translate a {@link Fill} to a CSS-property record suitable for HTML preview.
46
+ * `'solid'` PatternFill renders as `background-color`, other pattern types
47
+ * collapse to bgColor (CSS has no built-in equivalent of Excel hatch patterns).
48
+ * GradientFill emits a CSS `background-image` with `linear-gradient(<angle>,
49
+ * …)` for `type='linear'` or `radial-gradient(circle, …)` for `type='path'`.
50
+ *
51
+ * theme/auto colours and unresolvable inputs are skipped (returns `{}`) so
52
+ * callers can spread without overwriting upstream defaults.
53
+ */
54
+ export declare function fillToCss(fill: Fill | undefined): Record<string, string>;
@@ -0,0 +1,6 @@
1
+ import { type XmlNode } from '../xml/tree';
2
+ import { type Fill } from './fills';
3
+ /** Build the `<fill>…</fill>` envelope around either variant. */
4
+ export declare function fillToTree(fill: Fill): XmlNode;
5
+ /** Inverse of {@link fillToTree}. Reads `<fill>` and dispatches on the child tag. */
6
+ export declare function fillFromTree(node: XmlNode): Fill;
@@ -0,0 +1,44 @@
1
+ import { type Color } from './colors';
2
+ /** Underline styles per openpyxl's NestedNoneSet. */
3
+ export type UnderlineStyle = 'single' | 'double' | 'singleAccounting' | 'doubleAccounting';
4
+ export declare const UNDERLINE_STYLES: ReadonlyArray<UnderlineStyle>;
5
+ export type VertAlign = 'baseline' | 'superscript' | 'subscript';
6
+ export declare const VERT_ALIGNS: ReadonlyArray<VertAlign>;
7
+ export type FontScheme = 'major' | 'minor';
8
+ export declare const FONT_SCHEMES: ReadonlyArray<FontScheme>;
9
+ export interface Font {
10
+ readonly name?: string;
11
+ readonly charset?: number;
12
+ /** Font family code (0..14). */
13
+ readonly family?: number;
14
+ /** Point size; openpyxl name = `sz`. */
15
+ readonly size?: number;
16
+ readonly color?: Color;
17
+ readonly bold?: boolean;
18
+ readonly italic?: boolean;
19
+ readonly strike?: boolean;
20
+ readonly outline?: boolean;
21
+ readonly shadow?: boolean;
22
+ readonly condense?: boolean;
23
+ readonly extend?: boolean;
24
+ readonly underline?: UnderlineStyle;
25
+ readonly vertAlign?: VertAlign;
26
+ readonly scheme?: FontScheme;
27
+ }
28
+ export declare function makeFont(opts?: Partial<Font>): Font;
29
+ /** Excel's default cell font: Calibri 11, minor scheme, theme=1 colour. */
30
+ export declare const DEFAULT_FONT: Font;
31
+ /**
32
+ * Translate a {@link Font} to a CSS-property record suitable for HTML
33
+ * rendering / preview. Boolean toggles map to weight/style/decoration,
34
+ * `size` becomes `font-size: <n>pt`, and an explicit rgb/indexed
35
+ * `color` is rendered as `#RRGGBB` (alpha dropped). theme/auto colours
36
+ * are skipped — callers without a theme can't resolve them.
37
+ *
38
+ * `vertAlign='superscript'|'subscript'` lowers `font-size` to 0.83em
39
+ * (W3C convention) and sets `vertical-align`.
40
+ *
41
+ * Returns `{}` for an empty Font so callers can spread it without
42
+ * overwriting upstream defaults.
43
+ */
44
+ export declare function fontToCss(font: Font | undefined): Record<string, string>;
@@ -0,0 +1,3 @@
1
+ import { type Schema } from '../schema/core';
2
+ import type { Font } from './fonts';
3
+ export declare const FontSchema: Schema<Font>;
@@ -0,0 +1,21 @@
1
+ export type { Alignment, HorizontalAlignment, VerticalAlignment } from './alignment';
2
+ export { alignmentToCss, makeAlignment } from './alignment';
3
+ export type { Border, Side, SideStyle } from './borders';
4
+ export { borderToCss, makeBorder, makeSide } from './borders';
5
+ export { alignCellHorizontal, alignCellVertical, applyBuiltinStyle, applyNamedStyle, cellStyleToCss, centerCell, clearCellBackground, clearCellStyle, clearRangeStyle, cloneCellStyle, copyCellStyle, formatAsHeader, indentCell, rotateCellText, setBold, setCellBackgroundColor, setFontColor, setFontName, setFontSize, setItalic, setStrikethrough, setUnderline, wrapCellText, getCellAlignment, getCellBorder, getCellFill, getCellFont, getCellNumberFormat, getCellProtection, setCellAlignment, setCellAsCurrency, setCellAsDate, setCellAsNumber, setCellAsPercent, setCellBorder, setCellBorderAll, setCellFill, setCellFont, setCellNumberFormat, setCellProtection, setCellStyle, setRangeBackgroundColor, setRangeBorderBox, setRangeFont, setRangeNumberFormat, setRangeAlignment, setRangeProtection, setRangeStyle, setRangeWrapText, } from './cell-style';
6
+ export type { DifferentialStyle } from './differential';
7
+ export { addDxf, makeDifferentialStyle } from './differential';
8
+ export type { NamedStyle, StylesheetNamedStyle } from './named-styles';
9
+ export { addNamedStyle, BUILTIN_NAMED_STYLES, ensureBuiltinStyle } from './named-styles';
10
+ export type { Color } from './colors';
11
+ export { adjustLightness, adjustSaturation, colorToHex, contrastRatio, darken, hexToHsl, hslToHex, lighten, luminance, makeColor, mixColors, normaliseRgb, pickReadableTextColor, resolveIndexedColor, rgbColor, rotateHue, } from './colors';
12
+ export type { Fill, GradientFill, GradientFillType, GradientStop, PatternFill, PatternType } from './fills';
13
+ export { fillToCss, makeFill, makeGradientFill, makeGradientStop, makePatternFill } from './fills';
14
+ export type { Font, FontScheme, UnderlineStyle, VertAlign } from './fonts';
15
+ export { DEFAULT_FONT, fontToCss, makeFont } from './fonts';
16
+ export type { Protection } from './protection';
17
+ export { makeProtection } from './protection';
18
+ export type { CellXf, Stylesheet } from './stylesheet';
19
+ export { addBorder, addCellStyleXf, addCellXf, addFill, addFont, addNumFmt, defaultCellXf, listBorders, listCellStyleXfs, listCellXfs, listFills, listFonts, makeStylesheet, } from './stylesheet';
20
+ export type { NumberFormat } from './numbers';
21
+ export { BUILTIN_FORMATS, BUILTIN_FORMATS_MAX_SIZE, builtinFormatCode, builtinFormatId, classifyDateFormat, FORMAT_DATE_DATETIME, FORMAT_DATE_TIMEDELTA, FORMAT_DATE_YYYYMMDD2, FORMAT_GENERAL, FORMAT_NUMBER, FORMAT_NUMBER_00, FORMAT_PERCENTAGE, FORMAT_PERCENTAGE_00, FORMAT_TEXT, isBuiltinFormat, isDateFormat, isTimedeltaFormat, makeNumberFormat, } from './numbers';
@@ -0,0 +1,52 @@
1
+ import type { Alignment } from './alignment';
2
+ import type { Border } from './borders';
3
+ import type { Fill } from './fills';
4
+ import type { Font } from './fonts';
5
+ import { type Stylesheet } from './stylesheet';
6
+ export interface NamedStyle {
7
+ readonly name: string;
8
+ /** OOXML built-in id (0..N); absent for user-defined styles. */
9
+ readonly builtinId?: number;
10
+ readonly customBuiltin?: boolean;
11
+ readonly hidden?: boolean;
12
+ readonly iLevel?: number;
13
+ readonly font?: Font;
14
+ readonly fill?: Fill;
15
+ readonly border?: Border;
16
+ readonly alignment?: Alignment;
17
+ readonly protection?: Protection;
18
+ readonly numberFormat?: string;
19
+ }
20
+ import type { Protection } from './protection';
21
+ /**
22
+ * NamedStyle as it sits inside the Stylesheet (an `<cellStyles>` entry).
23
+ * Captures the resolved cellStyleXfs index so the writer can emit the
24
+ * `<cellStyle xfId="…" name="…" builtinId="…"/>` element directly.
25
+ */
26
+ export interface StylesheetNamedStyle {
27
+ readonly name: string;
28
+ readonly xfId: number;
29
+ readonly builtinId?: number;
30
+ readonly customBuiltin?: boolean;
31
+ readonly hidden?: boolean;
32
+ readonly iLevel?: number;
33
+ }
34
+ /**
35
+ * Register a NamedStyle on the Stylesheet:
36
+ * 1. add Font / Fill / Border / NumberFormat to their pools
37
+ * 2. push a CellXf with apply* flags into cellStyleXfs
38
+ * 3. append a {name, xfId, builtinId} entry into the workbook's
39
+ * namedStyles list (caller-managed; this function returns the
40
+ * xfId so callers can connect the dots)
41
+ * Idempotent on (name): re-registering by the same name returns the
42
+ * cached xfId.
43
+ */
44
+ export declare function addNamedStyle(ss: Stylesheet, style: NamedStyle): number;
45
+ /** Curated subset of openpyxl's `styles` dict. Keys match the user-visible names. */
46
+ export declare const BUILTIN_NAMED_STYLES: Readonly<Record<string, NamedStyle>>;
47
+ /**
48
+ * Register a built-in style with the supplied Stylesheet (idempotent).
49
+ * Returns the cellStyleXfs index. Throws OpenXmlSchemaError when the
50
+ * name is unknown.
51
+ */
52
+ export declare function ensureBuiltinStyle(ss: Stylesheet, name: keyof typeof BUILTIN_NAMED_STYLES | string): number;
@@ -0,0 +1,39 @@
1
+ /** Canonical OOXML built-in number formats — verbatim from openpyxl. */
2
+ export declare const BUILTIN_FORMATS: Readonly<Record<number, string>>;
3
+ /** First numFmtId Excel reserves for user-defined formats. */
4
+ export declare const BUILTIN_FORMATS_MAX_SIZE = 164;
5
+ export declare const FORMAT_GENERAL = "General";
6
+ export declare const FORMAT_TEXT = "@";
7
+ export declare const FORMAT_NUMBER = "0";
8
+ export declare const FORMAT_NUMBER_00 = "0.00";
9
+ export declare const FORMAT_PERCENTAGE = "0%";
10
+ export declare const FORMAT_PERCENTAGE_00 = "0.00%";
11
+ export declare const FORMAT_DATE_DATETIME = "yyyy-mm-dd h:mm:ss";
12
+ export declare const FORMAT_DATE_TIMEDELTA = "[hh]:mm:ss";
13
+ export declare const FORMAT_DATE_YYYYMMDD2 = "yyyy-mm-dd";
14
+ /** Look up the format code for a given numFmtId, or `undefined` if unknown. */
15
+ export declare function builtinFormatCode(id: number): string | undefined;
16
+ /** Look up the numFmtId for a given format code, or `undefined` if not built-in. */
17
+ export declare function builtinFormatId(code: string): number | undefined;
18
+ /** True iff `code` is one of the OOXML built-in format strings. */
19
+ export declare function isBuiltinFormat(code: string): boolean;
20
+ /**
21
+ * Heuristic: does the format string imply a date / time interpretation?
22
+ * Looks at only the first format section (positive-value branch); strips
23
+ * literals, colour codes and locale modifiers before scanning for date
24
+ * tokens (d/m/h/y/s, case-insensitive) that aren't escaped.
25
+ */
26
+ export declare function isDateFormat(code: string | undefined | null): boolean;
27
+ /** Heuristic: does the format string indicate a duration ([h]:mm:ss etc.)? */
28
+ export declare function isTimedeltaFormat(code: string | undefined | null): boolean;
29
+ /** Categorise a date format as 'date', 'time', 'datetime' or undefined. */
30
+ export declare function classifyDateFormat(code: string | undefined | null): 'date' | 'time' | 'datetime' | undefined;
31
+ export interface NumberFormat {
32
+ /** Stylesheet-relative numFmtId. */
33
+ readonly numFmtId: number;
34
+ readonly formatCode: string;
35
+ }
36
+ export declare function makeNumberFormat(opts: {
37
+ numFmtId: number;
38
+ formatCode: string;
39
+ }): NumberFormat;
@@ -0,0 +1,3 @@
1
+ import { type Schema } from '../schema/core';
2
+ import type { NumberFormat } from './numbers';
3
+ export declare const NumberFormatSchema: Schema<NumberFormat>;
@@ -0,0 +1,9 @@
1
+ export interface Protection {
2
+ /** When true (the default), the cell can't be edited if the sheet is locked. */
3
+ readonly locked?: boolean;
4
+ /** When true, the formula bar hides this cell's contents on a protected sheet. */
5
+ readonly hidden?: boolean;
6
+ }
7
+ export declare function makeProtection(opts?: Partial<Protection>): Protection;
8
+ /** Excel's Stylesheet always contains an entry equal to {locked:true, hidden:false}. */
9
+ export declare const DEFAULT_PROTECTION: Protection;
@@ -0,0 +1,3 @@
1
+ import { type Schema } from '../schema/core';
2
+ import type { Protection } from './protection';
3
+ export declare const ProtectionSchema: Schema<Protection>;
@@ -0,0 +1,7 @@
1
+ import { type Stylesheet } from './stylesheet';
2
+ /**
3
+ * Parse `xl/styles.xml` and return a fully-populated {@link Stylesheet}. Slot
4
+ * ordering is preserved verbatim; the dedup index Maps are rebuilt after the
5
+ * fact so future `addFont` / `addCellXf` calls keep working.
6
+ */
7
+ export declare function parseStylesheetXml(bytes: Uint8Array | string): Stylesheet;
@@ -0,0 +1,3 @@
1
+ import type { Stylesheet } from './stylesheet';
2
+ /** Serialise a Stylesheet to its `xl/styles.xml` payload. */
3
+ export declare function stylesheetToBytes(ss: Stylesheet): Uint8Array;
@@ -0,0 +1,95 @@
1
+ import type { Alignment } from './alignment';
2
+ import type { Border } from './borders';
3
+ import type { Fill } from './fills';
4
+ import type { Font } from './fonts';
5
+ import type { Protection } from './protection';
6
+ /**
7
+ * One entry in the cellXfs / cellStyleXfs pool. Represents the union of
8
+ * indexes-into-other-pools that a cell or named style points at.
9
+ *
10
+ * Mirrors openpyxl's CellStyle (styles/cell_style.py). The TS port keeps it as
11
+ * a plain readonly object — no class, no methods. The Stylesheet `addCellXf`
12
+ * allocates the index; cells store only that.
13
+ */
14
+ export interface CellXf {
15
+ readonly fontId: number;
16
+ readonly fillId: number;
17
+ readonly borderId: number;
18
+ readonly numFmtId: number;
19
+ /** Index into cellStyleXfs — only set for direct-cell xfs that point at a NamedStyle. */
20
+ readonly xfId?: number;
21
+ readonly alignment?: Alignment;
22
+ readonly protection?: Protection;
23
+ readonly applyFont?: boolean;
24
+ readonly applyFill?: boolean;
25
+ readonly applyBorder?: boolean;
26
+ readonly applyNumberFormat?: boolean;
27
+ readonly applyAlignment?: boolean;
28
+ readonly applyProtection?: boolean;
29
+ readonly pivotButton?: boolean;
30
+ readonly quotePrefix?: boolean;
31
+ }
32
+ export interface Stylesheet {
33
+ fonts: Font[];
34
+ fills: Fill[];
35
+ borders: Border[];
36
+ /** numFmtId → format code (custom IDs only; built-ins implicit). */
37
+ numFmts: Map<number, string>;
38
+ cellXfs: CellXf[];
39
+ cellStyleXfs: CellXf[];
40
+ /** Named styles (Excel's "Cell Styles" gallery; populated by addNamedStyle). */
41
+ namedStyles?: Array<import('./named-styles').StylesheetNamedStyle>;
42
+ _fontIdByKey: Map<string, number>;
43
+ _fillIdByKey: Map<string, number>;
44
+ _borderIdByKey: Map<string, number>;
45
+ _xfIdByKey: Map<string, number>;
46
+ _styleXfIdByKey: Map<string, number>;
47
+ _numFmtIdByCode: Map<string, number>;
48
+ _namedStyleByName?: Map<string, import('./named-styles').StylesheetNamedStyle>;
49
+ }
50
+ /**
51
+ * Build a fresh Stylesheet pre-populated with Excel's required default entries.
52
+ * Mirrors openpyxl's empty Stylesheet: fonts: [DEFAULT_FONT] (index 0) fills:
53
+ * [DEFAULT_EMPTY_FILL,
54
+ * DEFAULT_GRAY_FILL] (indices 0, 1 — required)
55
+ * borders: [DEFAULT_BORDER] (index 0) cellXfs: empty (indices allocated on
56
+ * demand)
57
+ */
58
+ export declare function makeStylesheet(): Stylesheet;
59
+ /** Add a Font to the pool, returning its 0-based index. Idempotent. */
60
+ export declare function addFont(ss: Stylesheet, font: Font): number;
61
+ /** Add a Fill to the pool, returning its 0-based index. Idempotent. */
62
+ export declare function addFill(ss: Stylesheet, fill: Fill): number;
63
+ /** Add a Border to the pool, returning its 0-based index. Idempotent. */
64
+ export declare function addBorder(ss: Stylesheet, border: Border): number;
65
+ /**
66
+ * Resolve a number-format string to its numFmtId.
67
+ * - Built-in codes return their canonical OOXML ID.
68
+ * - Otherwise the custom code is registered (and allocated an ID
69
+ * ≥ {@link BUILTIN_FORMATS_MAX_SIZE}). Idempotent.
70
+ */
71
+ export declare function addNumFmt(ss: Stylesheet, formatCode: string): number;
72
+ /** Add a CellXf to the cellXfs pool, returning its 0-based index. Idempotent. */
73
+ export declare function addCellXf(ss: Stylesheet, xf: CellXf): number;
74
+ /** Add a CellXf to the cellStyleXfs pool. Idempotent. */
75
+ export declare function addCellStyleXf(ss: Stylesheet, xf: CellXf): number;
76
+ /** Returns the currently registered numFmt entries (built-ins are implicit and not included). */
77
+ export declare function getCustomNumFmts(ss: Stylesheet): ReadonlyArray<{
78
+ id: number;
79
+ code: string;
80
+ }>;
81
+ /** Read-only snapshot of every Font entry in the pool, indexed by id. */
82
+ export declare function listFonts(ss: Stylesheet): ReadonlyArray<Font>;
83
+ /** Read-only snapshot of every Fill entry in the pool, indexed by id. */
84
+ export declare function listFills(ss: Stylesheet): ReadonlyArray<Fill>;
85
+ /** Read-only snapshot of every Border entry in the pool, indexed by id. */
86
+ export declare function listBorders(ss: Stylesheet): ReadonlyArray<Border>;
87
+ /** Read-only snapshot of every CellXf entry in the cellXfs pool. */
88
+ export declare function listCellXfs(ss: Stylesheet): ReadonlyArray<CellXf>;
89
+ /** Read-only snapshot of every CellStyleXf entry (named-style xfs). */
90
+ export declare function listCellStyleXfs(ss: Stylesheet): ReadonlyArray<CellXf>;
91
+ /**
92
+ * Convenience: build the default `cellXfs[0]` Excel emits — points at the
93
+ * workbook's font 0 / fill 0 / border 0 / numFmtId 0 (General).
94
+ */
95
+ export declare function defaultCellXf(): CellXf;
@@ -0,0 +1,4 @@
1
+ import { an as hexToHsl, cn as luminance, dn as normaliseRgb, en as adjustLightness, fn as pickReadableTextColor, hn as rotateHue, in as darken, ln as makeColor, mn as rgbColor, nn as colorToHex, on as hslToHex, pn as resolveIndexedColor, rn as contrastRatio, sn as lighten, tn as adjustSaturation, un as mixColors } from "./worksheet-CmCNoIgD.mjs";
2
+ import { $ as ensureBuiltinStyle, A as setCellFill, At as makeNumberFormat, B as setRangeBackgroundColor, Bt as makeGradientFill, C as setCellAsCurrency, Ct as FORMAT_TEXT, D as setCellBackgroundColor, Dt as isBuiltinFormat, E as setCellAsPercent, Et as classifyDateFormat, F as setFontColor, Ft as fontToCss, G as setRangeStyle, Gt as makeBorder, H as setRangeFont, Ht as makePatternFill, I as setFontName, It as makeFont, J as setUnderline, K as setRangeWrapText, Kt as makeSide, L as setFontSize, M as setCellNumberFormat, N as setCellProtection, O as setCellBorder, Ot as isDateFormat, P as setCellStyle, Q as addNamedStyle, R as setItalic, Rt as fillToCss, S as setCellAlignment, St as FORMAT_PERCENTAGE_00, T as setCellAsNumber, Tt as builtinFormatId, U as setRangeNumberFormat, V as setRangeBorderBox, Vt as makeGradientStop, W as setRangeProtection, Wt as borderToCss, X as makeProtection, Xt as makeAlignment, Y as wrapCellText, Yt as alignmentToCss, Z as BUILTIN_NAMED_STYLES, _ as getCellNumberFormat, _t as FORMAT_DATE_YYYYMMDD2, a as cellStyleToCss, at as addNumFmt, b as rotateCellText, bt as FORMAT_NUMBER_00, c as clearCellStyle, ct as listCellStyleXfs, d as copyCellStyle, dt as listFonts, et as addBorder, f as formatAsHeader, ft as makeStylesheet, g as getCellFont, gt as FORMAT_DATE_TIMEDELTA, h as getCellFill, ht as FORMAT_DATE_DATETIME, i as applyNamedStyle, it as addFont, j as setCellFont, jt as DEFAULT_FONT, k as setCellBorderAll, kt as isTimedeltaFormat, l as clearRangeStyle, lt as listCellXfs, m as getCellBorder, mt as BUILTIN_FORMATS_MAX_SIZE, n as alignCellVertical, nt as addCellXf, o as centerCell, ot as defaultCellXf, p as getCellAlignment, pt as BUILTIN_FORMATS, q as setStrikethrough, r as applyBuiltinStyle, rt as addFill, s as clearCellBackground, st as listBorders, t as alignCellHorizontal, tt as addCellStyleXf, u as cloneCellStyle, ut as listFills, v as getCellProtection, vt as FORMAT_GENERAL, w as setCellAsDate, wt as builtinFormatCode, x as setBold, xt as FORMAT_PERCENTAGE, y as indentCell, yt as FORMAT_NUMBER, z as setRangeAlignment, zt as makeFill } from "./cell-style-BEDjMX1y.mjs";
3
+ import { r as makeDifferentialStyle, t as addDxf } from "./differential-D4dg-qtZ.mjs";
4
+ export { BUILTIN_FORMATS, BUILTIN_FORMATS_MAX_SIZE, BUILTIN_NAMED_STYLES, DEFAULT_FONT, FORMAT_DATE_DATETIME, FORMAT_DATE_TIMEDELTA, FORMAT_DATE_YYYYMMDD2, FORMAT_GENERAL, FORMAT_NUMBER, FORMAT_NUMBER_00, FORMAT_PERCENTAGE, FORMAT_PERCENTAGE_00, FORMAT_TEXT, addBorder, addCellStyleXf, addCellXf, addDxf, addFill, addFont, addNamedStyle, addNumFmt, adjustLightness, adjustSaturation, alignCellHorizontal, alignCellVertical, alignmentToCss, applyBuiltinStyle, applyNamedStyle, borderToCss, builtinFormatCode, builtinFormatId, cellStyleToCss, centerCell, classifyDateFormat, clearCellBackground, clearCellStyle, clearRangeStyle, cloneCellStyle, colorToHex, contrastRatio, copyCellStyle, darken, defaultCellXf, ensureBuiltinStyle, fillToCss, fontToCss, formatAsHeader, getCellAlignment, getCellBorder, getCellFill, getCellFont, getCellNumberFormat, getCellProtection, hexToHsl, hslToHex, indentCell, isBuiltinFormat, isDateFormat, isTimedeltaFormat, lighten, listBorders, listCellStyleXfs, listCellXfs, listFills, listFonts, luminance, makeAlignment, makeBorder, makeColor, makeDifferentialStyle, makeFill, makeFont, makeGradientFill, makeGradientStop, makeNumberFormat, makePatternFill, makeProtection, makeSide, makeStylesheet, mixColors, normaliseRgb, pickReadableTextColor, resolveIndexedColor, rgbColor, rotateCellText, rotateHue, setBold, setCellAlignment, setCellAsCurrency, setCellAsDate, setCellAsNumber, setCellAsPercent, setCellBackgroundColor, setCellBorder, setCellBorderAll, setCellFill, setCellFont, setCellNumberFormat, setCellProtection, setCellStyle, setFontColor, setFontName, setFontSize, setItalic, setRangeAlignment, setRangeBackgroundColor, setRangeBorderBox, setRangeFont, setRangeNumberFormat, setRangeProtection, setRangeStyle, setRangeWrapText, setStrikethrough, setUnderline, wrapCellText };