@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,113 @@
1
+ import type { Point2D } from './shape-properties';
2
+ /**
3
+ * ECMA-376 §20.1.10.55 preset shape catalogue (`ST_PresetShapeType`, 187
4
+ * entries). Pulled from openpyxl's `PresetGeometry2D.prst` Set so the test
5
+ * corpus stays directly comparable.
6
+ */
7
+ export declare const PRESET_SHAPE_NAMES: ReadonlyArray<string>;
8
+ /** True iff `name` is one of the 187 ECMA-376 preset shapes. */
9
+ export declare const isPresetShapeName: (name: string) => boolean;
10
+ /** `<a:gd name="..." fmla="..."/>`. Shape guide / formula. */
11
+ export interface ShapeGuide {
12
+ name: string;
13
+ fmla: string;
14
+ }
15
+ /**
16
+ * Adjust point. ECMA-376 calls these out as a Coordinate (a string that may be
17
+ * a literal EMU number or a guide-name reference like `wd2`). We keep them as
18
+ * strings so guide-references survive round-trip.
19
+ */
20
+ export interface AdjPoint2D {
21
+ x: string;
22
+ y: string;
23
+ }
24
+ /** `<a:cxn ang="..."><a:pos x y/></a:cxn>`. */
25
+ export interface ConnectionSite {
26
+ /** Angle: either a number (degrees × 60_000) or a guide reference. */
27
+ ang: string;
28
+ pos: AdjPoint2D;
29
+ }
30
+ /** `<a:ahXY>`-style adjust handle. The polar variant uses the same shape with `ang` in `pos`. */
31
+ export interface AdjustHandle {
32
+ /** `xy` (cartesian) or `polar`. */
33
+ kind: 'xy' | 'polar';
34
+ pos: AdjPoint2D;
35
+ /** Range constraints (xy) or radius/angle constraints (polar). */
36
+ gdRefX?: string;
37
+ minX?: string;
38
+ maxX?: string;
39
+ gdRefY?: string;
40
+ minY?: string;
41
+ maxY?: string;
42
+ gdRefR?: string;
43
+ minR?: string;
44
+ maxR?: string;
45
+ gdRefAng?: string;
46
+ minAng?: string;
47
+ maxAng?: string;
48
+ }
49
+ /** `<a:rect l t r b/>`. Optional bounding rect for custom geometry. */
50
+ export interface GuideRect {
51
+ l: string;
52
+ t: string;
53
+ r: string;
54
+ b: string;
55
+ }
56
+ /** Path-command discriminated union. ECMA-376 §20.1.9.* */
57
+ export type PathCommand = {
58
+ kind: 'moveTo';
59
+ pt: Point2D;
60
+ } | {
61
+ kind: 'lnTo';
62
+ pt: Point2D;
63
+ } | {
64
+ kind: 'arcTo';
65
+ wR: string;
66
+ hR: string;
67
+ stAng: string;
68
+ swAng: string;
69
+ } | {
70
+ kind: 'quadBezTo';
71
+ pts: [Point2D, Point2D];
72
+ } | {
73
+ kind: 'cubicBezTo';
74
+ pts: [Point2D, Point2D, Point2D];
75
+ } | {
76
+ kind: 'close';
77
+ };
78
+ export type PathFill = 'none' | 'norm' | 'lighten' | 'lightenLess' | 'darken' | 'darkenLess';
79
+ /** A single `<a:path>` element inside `<a:pathLst>`. */
80
+ export interface GeometryPath {
81
+ w?: number;
82
+ h?: number;
83
+ fill?: PathFill;
84
+ stroke?: boolean;
85
+ extrusionOk?: boolean;
86
+ commands: PathCommand[];
87
+ }
88
+ /** `<a:prstGeom prst="..."><a:avLst/></a:prstGeom>`. */
89
+ export interface PresetGeometry {
90
+ kind: 'preset';
91
+ prst: string;
92
+ avLst?: ShapeGuide[];
93
+ }
94
+ /** `<a:custGeom>...</a:custGeom>`. */
95
+ export interface CustomGeometry {
96
+ kind: 'custom';
97
+ avLst?: ShapeGuide[];
98
+ gdLst?: ShapeGuide[];
99
+ ahLst?: AdjustHandle[];
100
+ cxnLst?: ConnectionSite[];
101
+ rect?: GuideRect;
102
+ pathLst: GeometryPath[];
103
+ }
104
+ export type Geometry = PresetGeometry | CustomGeometry;
105
+ export declare const makePresetGeometry: (prst: string, avLst?: ShapeGuide[]) => PresetGeometry;
106
+ export declare const makeCustomGeometry: (opts: {
107
+ pathLst: GeometryPath[];
108
+ avLst?: ShapeGuide[];
109
+ gdLst?: ShapeGuide[];
110
+ ahLst?: AdjustHandle[];
111
+ cxnLst?: ConnectionSite[];
112
+ rect?: GuideRect;
113
+ }) => CustomGeometry;
@@ -0,0 +1,41 @@
1
+ import type { Fill } from './fill';
2
+ export type PresetDash = 'solid' | 'dot' | 'dash' | 'lgDash' | 'dashDot' | 'lgDashDot' | 'lgDashDotDot' | 'sysDash' | 'sysDot' | 'sysDashDot' | 'sysDashDotDot';
3
+ type LineDash = {
4
+ kind: 'preset';
5
+ val: PresetDash;
6
+ } | {
7
+ kind: 'custDash';
8
+ pattern: number[];
9
+ };
10
+ export type LineCap = 'rnd' | 'sq' | 'flat';
11
+ export type LineCompound = 'sng' | 'dbl' | 'thickThin' | 'thinThick' | 'tri';
12
+ type LineAlign = 'ctr' | 'in';
13
+ type LineJoin = {
14
+ kind: 'round';
15
+ } | {
16
+ kind: 'bevel';
17
+ } | {
18
+ kind: 'miter';
19
+ lim?: number;
20
+ };
21
+ export type LineEndType = 'none' | 'triangle' | 'stealth' | 'diamond' | 'oval' | 'arrow';
22
+ export type LineEndSize = 'sm' | 'med' | 'lg';
23
+ export interface LineEnd {
24
+ type?: LineEndType;
25
+ w?: LineEndSize;
26
+ len?: LineEndSize;
27
+ }
28
+ export interface LineProperties {
29
+ /** Line width in EMU (1pt ≈ 12700 EMU). */
30
+ w?: number;
31
+ cap?: LineCap;
32
+ cmpd?: LineCompound;
33
+ algn?: LineAlign;
34
+ fill?: Fill;
35
+ dash?: LineDash;
36
+ join?: LineJoin;
37
+ headEnd?: LineEnd;
38
+ tailEnd?: LineEnd;
39
+ }
40
+ export declare const makeLine: (opts?: Partial<LineProperties>) => LineProperties;
41
+ export {};
@@ -0,0 +1,33 @@
1
+ import type { Point2D, PositiveSize2D } from '../anchor';
2
+ import type { EffectsRef } from './effect';
3
+ import type { Fill } from './fill';
4
+ import type { Geometry } from './geometry';
5
+ import type { LineProperties } from './line';
6
+ export type { Point2D, PositiveSize2D };
7
+ export type BlackWhiteMode = 'clr' | 'auto' | 'gray' | 'ltGray' | 'invGray' | 'grayWhite' | 'blackGray' | 'blackWhite' | 'black' | 'white' | 'hidden';
8
+ /** `<a:xfrm>`. Position / size / rotation transformation. */
9
+ export interface Transform2D {
10
+ off?: Point2D;
11
+ ext?: PositiveSize2D;
12
+ /** Rotation in 60_000-ths of a degree (0..21_600_000). */
13
+ rot?: number;
14
+ flipH?: boolean;
15
+ flipV?: boolean;
16
+ chOff?: Point2D;
17
+ chExt?: PositiveSize2D;
18
+ }
19
+ /**
20
+ * `<a:spPr>` wrapper. 3-D / text-body slots will be added as their primitive
21
+ * modules land — kept absent here so the type stays closed under the modules
22
+ * currently shipped.
23
+ */
24
+ export interface ShapeProperties {
25
+ bwMode?: BlackWhiteMode;
26
+ xfrm?: Transform2D;
27
+ geometry?: Geometry;
28
+ fill?: Fill;
29
+ ln?: LineProperties;
30
+ /** Either `<a:effectLst>` (kind: 'lst') or `<a:effectDag>` (kind: 'dag'). */
31
+ effects?: EffectsRef;
32
+ }
33
+ export declare const makeShapeProperties: (opts?: Partial<ShapeProperties>) => ShapeProperties;
@@ -0,0 +1,218 @@
1
+ import type { DmlColorWithMods } from './colors';
2
+ import type { EffectsRef } from './effect';
3
+ import type { Fill } from './fill';
4
+ import type { LineProperties } from './line';
5
+ export type FontAlign = 'auto' | 't' | 'ctr' | 'base' | 'b';
6
+ export type ParagraphAlign = 'l' | 'ctr' | 'r' | 'just' | 'justLow' | 'dist' | 'thaiDist';
7
+ export type TextUnderline = 'none' | 'words' | 'sng' | 'dbl' | 'heavy' | 'dotted' | 'dottedHeavy' | 'dash' | 'dashHeavy' | 'dashLong' | 'dashLongHeavy' | 'dotDash' | 'dotDashHeavy' | 'dotDotDash' | 'dotDotDashHeavy' | 'wavy' | 'wavyHeavy' | 'wavyDbl';
8
+ export type TextStrike = 'noStrike' | 'sngStrike' | 'dblStrike';
9
+ export type TextCap = 'none' | 'small' | 'all';
10
+ export type TextOverflow = 'overflow' | 'ellipsis' | 'clip';
11
+ export type TextHorzOverflow = 'overflow' | 'clip';
12
+ export type TextVertical = 'horz' | 'vert' | 'vert270' | 'wordArtVert' | 'eaVert' | 'mongolianVert' | 'wordArtVertRtl';
13
+ export type TextWrap = 'none' | 'square';
14
+ export type TextAnchor = 't' | 'ctr' | 'b' | 'just' | 'dist';
15
+ /** `<a:lnSpc>` / `<a:spcBef>` / `<a:spcAft>` — either percent (×1000) or points (×100). */
16
+ export type TextSpacing = {
17
+ kind: 'pct';
18
+ val: number;
19
+ } | {
20
+ kind: 'pts';
21
+ val: number;
22
+ };
23
+ /** `<a:tab>`. */
24
+ export interface TabStop {
25
+ pos: number;
26
+ algn?: 'l' | 'ctr' | 'r' | 'dec';
27
+ }
28
+ /** `<a:latin>` / `<a:ea>` / `<a:cs>` / `<a:sym>`. */
29
+ export interface TextFont {
30
+ typeface: string;
31
+ panose?: string;
32
+ pitchFamily?: number;
33
+ charset?: number;
34
+ }
35
+ /** `<a:hlinkClick>` / `<a:hlinkMouseOver>`. */
36
+ export interface HyperlinkInfo {
37
+ rId?: string;
38
+ invalidUrl?: string;
39
+ action?: string;
40
+ tgtFrame?: string;
41
+ tooltip?: string;
42
+ history?: boolean;
43
+ highlightClick?: boolean;
44
+ endSnd?: boolean;
45
+ }
46
+ /** `<a:rPr>` / `<a:endParaRPr>` / `<a:defRPr>`. */
47
+ export interface RunProperties {
48
+ kumimoji?: boolean;
49
+ lang?: string;
50
+ altLang?: string;
51
+ /** Font size in 1/100ths of a point. */
52
+ sz?: number;
53
+ b?: boolean;
54
+ i?: boolean;
55
+ u?: TextUnderline;
56
+ strike?: TextStrike;
57
+ kern?: number;
58
+ cap?: TextCap;
59
+ spc?: number;
60
+ normalizeH?: boolean;
61
+ /** Baseline shift × 1000 (super/subscript). */
62
+ baseline?: number;
63
+ noProof?: boolean;
64
+ dirty?: boolean;
65
+ err?: boolean;
66
+ smtClean?: boolean;
67
+ smtId?: number;
68
+ bmk?: string;
69
+ /** Right-to-left flag. */
70
+ rtl?: boolean;
71
+ ln?: LineProperties;
72
+ fill?: Fill;
73
+ effects?: EffectsRef;
74
+ highlight?: DmlColorWithMods;
75
+ /** Underline-line: either `'follow'` (`<a:uLnTx/>`) or an explicit LineProperties (`<a:uLn>`). */
76
+ uLn?: 'follow' | LineProperties;
77
+ /** Underline-fill: either `'follow'` (`<a:uFillTx/>`) or an explicit Fill (`<a:uFill>`). */
78
+ uFill?: 'follow' | Fill;
79
+ latin?: TextFont;
80
+ ea?: TextFont;
81
+ cs?: TextFont;
82
+ sym?: TextFont;
83
+ hlinkClick?: HyperlinkInfo;
84
+ hlinkMouseOver?: HyperlinkInfo;
85
+ }
86
+ /** `<a:buChar>` / `<a:buAutoNum>` / `<a:buBlip>` / `<a:buNone>`. */
87
+ export type BulletProperties = {
88
+ kind: 'none';
89
+ } | {
90
+ kind: 'char';
91
+ char: string;
92
+ } | {
93
+ kind: 'autoNum';
94
+ type: string;
95
+ startAt?: number;
96
+ } | {
97
+ kind: 'blip';
98
+ embedRId?: string;
99
+ linkRId?: string;
100
+ };
101
+ /** `<a:pPr>`. */
102
+ export interface ParagraphProperties {
103
+ marL?: number;
104
+ marR?: number;
105
+ /** Indent level (0..8). */
106
+ lvl?: number;
107
+ indent?: number;
108
+ algn?: ParagraphAlign;
109
+ defTabSz?: number;
110
+ rtl?: boolean;
111
+ eaLnBrk?: boolean;
112
+ fontAlgn?: FontAlign;
113
+ latinLnBrk?: boolean;
114
+ hangingPunct?: boolean;
115
+ lnSpc?: TextSpacing;
116
+ spcBef?: TextSpacing;
117
+ spcAft?: TextSpacing;
118
+ tabLst?: TabStop[];
119
+ defRPr?: RunProperties;
120
+ bullet?: BulletProperties;
121
+ /** Bullet font (`<a:buFont>` / `<a:buFontTx/>`). */
122
+ buFont?: 'follow' | TextFont;
123
+ /** Bullet color (`<a:buClr>` / `<a:buClrTx/>`). */
124
+ buClr?: 'follow' | DmlColorWithMods;
125
+ /** Bullet size: percent of run size, points, or "follow run". */
126
+ buSz?: 'follow' | {
127
+ kind: 'pct';
128
+ val: number;
129
+ } | {
130
+ kind: 'pts';
131
+ val: number;
132
+ };
133
+ }
134
+ /** `<a:r>` (regular run), `<a:br>` (line break), `<a:fld>` (field). */
135
+ export type TextRun = {
136
+ kind: 'r';
137
+ rPr?: RunProperties;
138
+ t: string;
139
+ } | {
140
+ kind: 'br';
141
+ rPr?: RunProperties;
142
+ } | {
143
+ kind: 'fld';
144
+ id: string;
145
+ type?: string;
146
+ rPr?: RunProperties;
147
+ pPr?: ParagraphProperties;
148
+ t?: string;
149
+ };
150
+ /** `<a:p>`. */
151
+ export interface TextParagraph {
152
+ pPr?: ParagraphProperties;
153
+ runs: TextRun[];
154
+ endParaRPr?: RunProperties;
155
+ }
156
+ /** `<a:bodyPr>` autofit choice. */
157
+ export type AutoFit = {
158
+ kind: 'noAutofit';
159
+ } | {
160
+ kind: 'normAutofit';
161
+ fontScale?: number;
162
+ lnSpcReduction?: number;
163
+ } | {
164
+ kind: 'spAutoFit';
165
+ };
166
+ /** `<a:bodyPr>`. */
167
+ export interface TextBodyProperties {
168
+ rot?: number;
169
+ spcFirstLastPara?: boolean;
170
+ vertOverflow?: TextOverflow;
171
+ horzOverflow?: TextHorzOverflow;
172
+ vert?: TextVertical;
173
+ wrap?: TextWrap;
174
+ lIns?: number;
175
+ tIns?: number;
176
+ rIns?: number;
177
+ bIns?: number;
178
+ numCol?: number;
179
+ spcCol?: number;
180
+ rtlCol?: boolean;
181
+ fromWordArt?: boolean;
182
+ anchor?: TextAnchor;
183
+ anchorCtr?: boolean;
184
+ forceAA?: boolean;
185
+ upright?: boolean;
186
+ compatLnSpc?: boolean;
187
+ autoFit?: AutoFit;
188
+ flatTxZ?: number;
189
+ }
190
+ /**
191
+ * `<a:lstStyle>` (list / level styles). ECMA-376 §21.1.2.4.12. One
192
+ * ParagraphProperties per indent level (0..8). `defPPr` is the default applied
193
+ * when no level-specific override exists.
194
+ */
195
+ export interface TextListStyle {
196
+ defPPr?: ParagraphProperties;
197
+ lvl1pPr?: ParagraphProperties;
198
+ lvl2pPr?: ParagraphProperties;
199
+ lvl3pPr?: ParagraphProperties;
200
+ lvl4pPr?: ParagraphProperties;
201
+ lvl5pPr?: ParagraphProperties;
202
+ lvl6pPr?: ParagraphProperties;
203
+ lvl7pPr?: ParagraphProperties;
204
+ lvl8pPr?: ParagraphProperties;
205
+ lvl9pPr?: ParagraphProperties;
206
+ }
207
+ export interface TextBody {
208
+ bodyPr: TextBodyProperties;
209
+ lstStyle?: TextListStyle;
210
+ paragraphs: TextParagraph[];
211
+ }
212
+ export declare const makeRunProperties: (opts?: Partial<RunProperties>) => RunProperties;
213
+ export declare const makeRun: (text: string, rPr?: RunProperties) => TextRun;
214
+ export declare const makeBreak: (rPr?: RunProperties) => TextRun;
215
+ export declare const makeParagraph: (runs: TextRun[], pPr?: ParagraphProperties, endParaRPr?: RunProperties) => TextParagraph;
216
+ export declare const makeTextBody: (paragraphs: TextParagraph[], bodyPr?: TextBodyProperties, lstStyle?: TextListStyle) => TextBody;
217
+ /** Convenience: build a single-paragraph body with one run. */
218
+ export declare const makeSimpleTextBody: (text: string, rPr?: RunProperties) => TextBody;
@@ -0,0 +1,5 @@
1
+ import { type Drawing } from './drawing';
2
+ /** Parse a `xl/drawings/drawingN.xml` payload into a Drawing object. */
3
+ export declare function parseDrawingXml(bytes: Uint8Array | string): Drawing;
4
+ /** Serialise a Drawing to its `xl/drawings/drawingN.xml` payload. */
5
+ export declare function drawingToBytes(drawing: Drawing): Uint8Array;
@@ -0,0 +1,117 @@
1
+ import type { ChartSpace } from '../chart/chart';
2
+ import type { CxChartSpace } from '../chart/cx/chartex';
3
+ import type { DrawingAnchor } from './anchor';
4
+ import type { ShapeProperties } from './dml/shape-properties';
5
+ import type { XlsxImage } from './image';
6
+ /** Reference to a chart part — the chart's drawing-rels rId resolves to xl/charts/chartN.xml. */
7
+ export interface ChartReference {
8
+ /** Drawing-rels rId pointing at the chart part. Populated on read; the writer assigns its own. */
9
+ rId?: string;
10
+ /**
11
+ * Legacy ECMA-376 chart payload (`c:chartSpace`). Stage-1 supports BarChart
12
+ * end-to-end; other chart kinds populate this field as their parsers /
13
+ * writers land.
14
+ */
15
+ space?: ChartSpace;
16
+ /**
17
+ * Excel-2016 chartex payload (`cx:chartSpace`). Mutually exclusive with
18
+ * {@link space} for any given drawing item; the parser sniffs the root
19
+ * element and populates whichever is appropriate.
20
+ */
21
+ cxSpace?: CxChartSpace;
22
+ /**
23
+ * `true` when the resolved chart part is a chartex (`cx:`) chart. Set by the
24
+ * package writer so the drawing emitter knows to use the chartex
25
+ * `<a:graphicData uri>` instead of the legacy chart URI — Excel rejects the
26
+ * workbook when the URI doesn't match the chart's actual root namespace.
27
+ */
28
+ isCx?: boolean;
29
+ }
30
+ /** Reference to an embedded picture inside a worksheet drawing. */
31
+ export interface PictureReference {
32
+ /** Drawing-rels rId pointing at the embedded image. Populated on read; the writer assigns its own. */
33
+ rId?: string;
34
+ /** Resolved image bytes + metadata. Populated on read; the writer reads it back. */
35
+ image?: XlsxImage;
36
+ /** Picture display name (`<xdr:cNvPr name="...">`). */
37
+ name?: string;
38
+ /** Optional alt-text description. */
39
+ descr?: string;
40
+ /** Hidden flag (`<xdr:cNvPr hidden="1"/>`). */
41
+ hidden?: boolean;
42
+ /** Per-picture shape properties (extra fill / line / rotation). */
43
+ spPr?: ShapeProperties;
44
+ }
45
+ export interface DrawingItem {
46
+ anchor: DrawingAnchor;
47
+ content: {
48
+ kind: 'chart';
49
+ chart: ChartReference;
50
+ } | {
51
+ kind: 'picture';
52
+ picture: PictureReference;
53
+ } | {
54
+ kind: 'unsupported';
55
+ rawTag: string;
56
+ };
57
+ }
58
+ export interface Drawing {
59
+ items: DrawingItem[];
60
+ }
61
+ export declare function makeDrawing(items?: DrawingItem[]): Drawing;
62
+ export declare function makeChartDrawingItem(anchor: DrawingAnchor, chart?: ChartReference): DrawingItem;
63
+ export declare function makePictureDrawingItem(anchor: DrawingAnchor, picture: PictureReference | XlsxImage): DrawingItem;
64
+ import type { Worksheet } from '../worksheet/worksheet';
65
+ /**
66
+ * Drop an image onto a worksheet at a single-cell anchor. Lazy-allocates
67
+ * `ws.drawing` (as `makeDrawing([])`) on first call and appends a picture
68
+ * DrawingItem.
69
+ *
70
+ * `image` accepts either an `XlsxImage` (already loaded via `loadImage`) or raw
71
+ * image bytes — in the bytes case, this helper sniffs the format with
72
+ * `loadImage` itself.
73
+ *
74
+ * `at` is a cell ref like `"C3"`. Override `widthPx` / `heightPx` to scale;
75
+ * otherwise the helper uses 96×96 defaults that look fine for typical icons.
76
+ */
77
+ export declare const addImageAt: (ws: Worksheet, at: string, image: XlsxImage | Uint8Array, opts?: {
78
+ widthPx?: number;
79
+ heightPx?: number;
80
+ }) => DrawingItem;
81
+ /**
82
+ * Anchor a chart to a worksheet at a single-cell ref. Lazy-allocates
83
+ * `ws.drawing`. `chart` is the same `ChartReference` shape `makeChart
84
+ * DrawingItem` accepts (`{ space }` for legacy chart, `{ cxSpace }` for
85
+ * chartex).
86
+ */
87
+ export declare const addChartAt: (ws: Worksheet, at: string, chart: ChartReference, opts?: {
88
+ widthPx?: number;
89
+ heightPx?: number;
90
+ }) => DrawingItem;
91
+ /**
92
+ * Read-only snapshot of every picture DrawingItem on the sheet. Returns the
93
+ * matching items (each with its anchor + picture reference). Empty array when
94
+ * the sheet has no drawing or only non-picture items.
95
+ */
96
+ export declare const listImagesOnSheet: (ws: Worksheet) => ReadonlyArray<DrawingItem>;
97
+ /**
98
+ * Read-only snapshot of every chart DrawingItem on the sheet. Each item has its
99
+ * anchor + chart reference.
100
+ */
101
+ export declare const listChartsOnSheet: (ws: Worksheet) => ReadonlyArray<DrawingItem>;
102
+ /**
103
+ * Drop every DrawingItem from the worksheet. Returns the count removed. The
104
+ * `ws.drawing` field itself is left in place (empty) so subsequent `addImageAt`
105
+ * / `addChartAt` calls don't have to re-allocate.
106
+ */
107
+ export declare const removeAllDrawingItems: (ws: Worksheet) => number;
108
+ /**
109
+ * Drop every picture DrawingItem from the worksheet, leaving charts and any
110
+ * other content kinds untouched. Returns the count removed.
111
+ */
112
+ export declare const removeAllImages: (ws: Worksheet) => number;
113
+ /**
114
+ * Drop every chart DrawingItem from the worksheet, leaving pictures and any
115
+ * other content kinds untouched. Returns the count removed.
116
+ */
117
+ export declare const removeAllCharts: (ws: Worksheet) => number;
@@ -0,0 +1,40 @@
1
+ export type XlsxImageFormat = 'png' | 'jpeg' | 'gif' | 'bmp' | 'webp' | 'tiff' | 'svg' | 'emf' | 'wmf';
2
+ /**
3
+ * Map from image format to the Content-Types Default extension that Excel uses
4
+ * in `[Content_Types].xml`. SVG / EMF / WMF use the same extension as the
5
+ * format string; PNG/JPEG/GIF/BMP do too. WebP and TIFF use their canonical
6
+ * short names.
7
+ */
8
+ export declare const IMAGE_FORMAT_EXTENSION: Readonly<Record<XlsxImageFormat, string>>;
9
+ /** Map from image format to its IANA `image/*` MIME type. */
10
+ export declare const IMAGE_FORMAT_MIME: Readonly<Record<XlsxImageFormat, string>>;
11
+ export interface XlsxImage {
12
+ bytes: Uint8Array;
13
+ format: XlsxImageFormat;
14
+ /** Pixel width. Zero when dimensions can't be determined for the format. */
15
+ width: number;
16
+ /** Pixel height. Zero when dimensions can't be determined for the format. */
17
+ height: number;
18
+ /** ZIP archive path, e.g. `xl/media/image3.png`. Set by the writer. */
19
+ path?: string;
20
+ /** rels-resolved id used by `<a:blip r:embed="...">`. Set by the loader. */
21
+ rId?: string;
22
+ }
23
+ export declare function detectImageFormat(bytes: Uint8Array): XlsxImageFormat | undefined;
24
+ interface Dimensions {
25
+ width: number;
26
+ height: number;
27
+ }
28
+ export declare function detectImageDimensions(bytes: Uint8Array, format: XlsxImageFormat): Dimensions;
29
+ /**
30
+ * Build an `XlsxImage` from raw bytes. Detects the format and dimensions
31
+ * automatically. Caller may pass an explicit `format` to override detection
32
+ * (e.g. when bytes were read from a `data:` URL with a known MIME type) or
33
+ * `width`/`height` to skip the parser.
34
+ */
35
+ export declare function loadImage(bytes: Uint8Array, opts?: {
36
+ format?: XlsxImageFormat;
37
+ width?: number;
38
+ height?: number;
39
+ }): XlsxImage;
40
+ export {};
@@ -0,0 +1,14 @@
1
+ export type { ChartReference, Drawing, DrawingItem, PictureReference, } from './drawing';
2
+ export { addChartAt, addImageAt, listChartsOnSheet, listImagesOnSheet, makeChartDrawingItem, makeDrawing, makePictureDrawingItem, removeAllCharts, removeAllDrawingItems, removeAllImages, } from './drawing';
3
+ export type { XlsxImage, XlsxImageFormat } from './image';
4
+ export { loadImage } from './image';
5
+ export type { AnchorMarker, DrawingAnchor, Point2D, PositiveSize2D, } from './anchor';
6
+ export { makeOneCellAnchor } from './anchor';
7
+ export type { BlackWhiteMode, ShapeProperties, Transform2D } from './dml/shape-properties';
8
+ export { makeShapeProperties } from './dml/shape-properties';
9
+ export type { ColorMod, DmlColor, DmlColorWithMods, SchemeColorName } from './dml/colors';
10
+ export { makeColor, makeSchemeColor, makeSrgbColor, SCHEME_COLOR_NAMES, VALUED_COLOR_MOD_KINDS, VALUELESS_COLOR_MOD_KINDS, } from './dml/colors';
11
+ export type { Blip, BlipEffect, Fill, GradientLineDir, GradientStop, RelativeRect, TileFill, TileFlip, } from './dml/fill';
12
+ export { makeGradientFill, makeNoFill, makePatternFill, makeSolidFill, PRESET_PATTERN_NAMES, } from './dml/fill';
13
+ export type { AutoFit, BulletProperties, FontAlign, HyperlinkInfo, ParagraphAlign, ParagraphProperties, RunProperties, TabStop, TextAnchor, TextBody, TextBodyProperties, TextCap, TextFont, TextHorzOverflow, TextListStyle, TextOverflow, TextParagraph, TextRun, TextSpacing, TextStrike, TextUnderline, TextVertical, TextWrap, } from './dml/text';
14
+ export { makeBreak, makeParagraph, makeRun, makeRunProperties, makeSimpleTextBody, makeTextBody, } from './dml/text';