@cj-tech-master/excelts 9.4.2 → 9.5.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 (618) hide show
  1. package/dist/browser/index.browser.d.ts +8 -5
  2. package/dist/browser/index.browser.js +19 -1
  3. package/dist/browser/index.d.ts +4 -2
  4. package/dist/browser/index.js +9 -1
  5. package/dist/browser/modules/excel/chart/cache-populator.d.ts +49 -0
  6. package/dist/browser/modules/excel/chart/cache-populator.js +1171 -0
  7. package/dist/browser/modules/excel/chart/chart-api.d.ts +92 -0
  8. package/dist/browser/modules/excel/chart/chart-api.js +364 -0
  9. package/dist/browser/modules/excel/chart/chart-builder.d.ts +48 -0
  10. package/dist/browser/modules/excel/chart/chart-builder.js +2432 -0
  11. package/dist/browser/modules/excel/chart/chart-ex-builder.d.ts +36 -0
  12. package/dist/browser/modules/excel/chart/chart-ex-builder.js +903 -0
  13. package/dist/browser/modules/excel/chart/chart-ex-parser.d.ts +8 -0
  14. package/dist/browser/modules/excel/chart/chart-ex-parser.js +1205 -0
  15. package/dist/browser/modules/excel/chart/chart-ex-renderer.d.ts +187 -0
  16. package/dist/browser/modules/excel/chart/chart-ex-renderer.js +5352 -0
  17. package/dist/browser/modules/excel/chart/chart-ex-types.d.ts +531 -0
  18. package/dist/browser/modules/excel/chart/chart-ex-types.js +11 -0
  19. package/dist/browser/modules/excel/chart/chart-images.d.ts +78 -0
  20. package/dist/browser/modules/excel/chart/chart-images.js +363 -0
  21. package/dist/browser/modules/excel/chart/chart-presets.d.ts +392 -0
  22. package/dist/browser/modules/excel/chart/chart-presets.js +179 -0
  23. package/dist/browser/modules/excel/chart/chart-renderer.d.ts +550 -0
  24. package/dist/browser/modules/excel/chart/chart-renderer.js +6440 -0
  25. package/dist/browser/modules/excel/chart/chart-sidecar.d.ts +21 -0
  26. package/dist/browser/modules/excel/chart/chart-sidecar.js +427 -0
  27. package/dist/browser/modules/excel/chart/chart-utils.d.ts +306 -0
  28. package/dist/browser/modules/excel/chart/chart-utils.js +821 -0
  29. package/dist/browser/modules/excel/chart/chart.d.ts +504 -0
  30. package/dist/browser/modules/excel/chart/chart.js +1320 -0
  31. package/dist/browser/modules/excel/chart/glyph-rasterizer.d.ts +62 -0
  32. package/dist/browser/modules/excel/chart/glyph-rasterizer.js +658 -0
  33. package/dist/browser/modules/excel/chart/index.d.ts +54 -0
  34. package/dist/browser/modules/excel/chart/index.js +46 -0
  35. package/dist/browser/modules/excel/chart/install.d.ts +44 -0
  36. package/dist/browser/modules/excel/chart/install.js +91 -0
  37. package/dist/browser/modules/excel/chart/shape-properties.d.ts +156 -0
  38. package/dist/browser/modules/excel/chart/shape-properties.js +1557 -0
  39. package/dist/browser/modules/excel/chart/stroke-font.d.ts +36 -0
  40. package/dist/browser/modules/excel/chart/stroke-font.js +1556 -0
  41. package/dist/browser/modules/excel/chart/topojson.d.ts +98 -0
  42. package/dist/browser/modules/excel/chart/topojson.js +236 -0
  43. package/dist/browser/modules/excel/chart/types.d.ts +2559 -0
  44. package/dist/browser/modules/excel/chart/types.js +8 -0
  45. package/dist/browser/modules/excel/chart-host-registry.d.ts +157 -0
  46. package/dist/browser/modules/excel/chart-host-registry.js +90 -0
  47. package/dist/browser/modules/excel/chartsheet.d.ts +102 -0
  48. package/dist/browser/modules/excel/chartsheet.js +196 -0
  49. package/dist/browser/modules/excel/defined-names.d.ts +35 -0
  50. package/dist/browser/modules/excel/defined-names.js +44 -4
  51. package/dist/browser/modules/excel/errors.d.ts +6 -0
  52. package/dist/browser/modules/excel/errors.js +9 -0
  53. package/dist/browser/modules/excel/form-control.d.ts +6 -0
  54. package/dist/browser/modules/excel/form-control.js +17 -0
  55. package/dist/browser/modules/excel/image.js +12 -2
  56. package/dist/browser/modules/excel/pivot-chart.d.ts +7 -0
  57. package/dist/browser/modules/excel/pivot-chart.js +53 -0
  58. package/dist/browser/modules/excel/pivot-table.d.ts +55 -0
  59. package/dist/browser/modules/excel/pivot-table.js +35 -0
  60. package/dist/browser/modules/excel/range.js +5 -1
  61. package/dist/browser/modules/excel/sparkline/index.d.ts +7 -0
  62. package/dist/browser/modules/excel/sparkline/index.js +7 -0
  63. package/dist/browser/modules/excel/sparkline/sparkline.d.ts +206 -0
  64. package/dist/browser/modules/excel/sparkline/sparkline.js +750 -0
  65. package/dist/browser/modules/excel/stream/worksheet-writer.js +3 -2
  66. package/dist/browser/modules/excel/table.js +42 -6
  67. package/dist/browser/modules/excel/types.d.ts +72 -0
  68. package/dist/browser/modules/excel/utils/address.d.ts +18 -0
  69. package/dist/browser/modules/excel/utils/address.js +28 -0
  70. package/dist/browser/modules/excel/utils/drawing-utils.js +11 -6
  71. package/dist/browser/modules/excel/utils/guid.d.ts +15 -0
  72. package/dist/browser/modules/excel/utils/guid.js +35 -0
  73. package/dist/browser/modules/excel/utils/ooxml-paths.d.ts +74 -0
  74. package/dist/browser/modules/excel/utils/ooxml-paths.js +206 -9
  75. package/dist/browser/modules/excel/utils/ooxml-validator/check-chart-sidecar.d.ts +35 -0
  76. package/dist/browser/modules/excel/utils/ooxml-validator/check-chart-sidecar.js +101 -0
  77. package/dist/browser/modules/excel/utils/ooxml-validator/check-chart.d.ts +32 -0
  78. package/dist/browser/modules/excel/utils/ooxml-validator/check-chart.js +2125 -0
  79. package/dist/browser/modules/excel/utils/ooxml-validator/check-chartsheet.d.ts +9 -0
  80. package/dist/browser/modules/excel/utils/ooxml-validator/check-chartsheet.js +26 -0
  81. package/dist/browser/modules/excel/utils/ooxml-validator/check-content-types.d.ts +16 -0
  82. package/dist/browser/modules/excel/utils/ooxml-validator/check-content-types.js +181 -0
  83. package/dist/browser/modules/excel/utils/ooxml-validator/check-drawing.d.ts +34 -0
  84. package/dist/browser/modules/excel/utils/ooxml-validator/check-drawing.js +267 -0
  85. package/dist/browser/modules/excel/utils/ooxml-validator/check-pivot.d.ts +14 -0
  86. package/dist/browser/modules/excel/utils/ooxml-validator/check-pivot.js +104 -0
  87. package/dist/browser/modules/excel/utils/ooxml-validator/check-relationships.d.ts +18 -0
  88. package/dist/browser/modules/excel/utils/ooxml-validator/check-relationships.js +184 -0
  89. package/dist/browser/modules/excel/utils/ooxml-validator/check-structure.d.ts +21 -0
  90. package/dist/browser/modules/excel/utils/ooxml-validator/check-structure.js +56 -0
  91. package/dist/browser/modules/excel/utils/ooxml-validator/check-styles.d.ts +15 -0
  92. package/dist/browser/modules/excel/utils/ooxml-validator/check-styles.js +89 -0
  93. package/dist/browser/modules/excel/utils/ooxml-validator/check-table.d.ts +31 -0
  94. package/dist/browser/modules/excel/utils/ooxml-validator/check-table.js +177 -0
  95. package/dist/browser/modules/excel/utils/ooxml-validator/check-workbook.d.ts +19 -0
  96. package/dist/browser/modules/excel/utils/ooxml-validator/check-workbook.js +163 -0
  97. package/dist/browser/modules/excel/utils/ooxml-validator/check-worksheet.d.ts +25 -0
  98. package/dist/browser/modules/excel/utils/ooxml-validator/check-worksheet.js +569 -0
  99. package/dist/browser/modules/excel/utils/ooxml-validator/context.d.ts +85 -0
  100. package/dist/browser/modules/excel/utils/ooxml-validator/context.js +191 -0
  101. package/dist/browser/modules/excel/utils/ooxml-validator/index.d.ts +31 -0
  102. package/dist/browser/modules/excel/utils/ooxml-validator/index.js +102 -0
  103. package/dist/browser/modules/excel/utils/ooxml-validator/path-utils.d.ts +67 -0
  104. package/dist/browser/modules/excel/utils/ooxml-validator/path-utils.js +156 -0
  105. package/dist/browser/modules/excel/utils/ooxml-validator/reporter.d.ts +41 -0
  106. package/dist/browser/modules/excel/utils/ooxml-validator/reporter.js +61 -0
  107. package/dist/browser/modules/excel/utils/ooxml-validator/types.d.ts +109 -0
  108. package/dist/browser/modules/excel/utils/ooxml-validator/types.js +12 -0
  109. package/dist/browser/modules/excel/utils/ooxml-validator/xml-utils.d.ts +38 -0
  110. package/dist/browser/modules/excel/utils/ooxml-validator/xml-utils.js +100 -0
  111. package/dist/browser/modules/excel/workbook.browser.d.ts +248 -30
  112. package/dist/browser/modules/excel/workbook.browser.js +966 -31
  113. package/dist/browser/modules/excel/workbook.d.ts +43 -0
  114. package/dist/browser/modules/excel/workbook.js +48 -0
  115. package/dist/browser/modules/excel/worksheet.d.ts +157 -3
  116. package/dist/browser/modules/excel/worksheet.js +394 -35
  117. package/dist/browser/modules/excel/xlsx/rel-type.d.ts +40 -0
  118. package/dist/browser/modules/excel/xlsx/rel-type.js +41 -1
  119. package/dist/browser/modules/excel/xlsx/xform/book/defined-name-xform.d.ts +1 -0
  120. package/dist/browser/modules/excel/xlsx/xform/book/defined-name-xform.js +11 -2
  121. package/dist/browser/modules/excel/xlsx/xform/book/external-link-xform.js +12 -10
  122. package/dist/browser/modules/excel/xlsx/xform/book/workbook-xform.js +96 -22
  123. package/dist/browser/modules/excel/xlsx/xform/chart/chart-space-xform.d.ts +353 -0
  124. package/dist/browser/modules/excel/xlsx/xform/chart/chart-space-xform.js +6000 -0
  125. package/dist/browser/modules/excel/xlsx/xform/comment/threaded-comments-xform.d.ts +60 -0
  126. package/dist/browser/modules/excel/xlsx/xform/comment/threaded-comments-xform.js +213 -0
  127. package/dist/browser/modules/excel/xlsx/xform/core/content-types-xform.js +150 -11
  128. package/dist/browser/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +20 -1
  129. package/dist/browser/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +1 -1
  130. package/dist/browser/modules/excel/xlsx/xform/drawing/drawing-xform.d.ts +30 -0
  131. package/dist/browser/modules/excel/xlsx/xform/drawing/drawing-xform.js +109 -5
  132. package/dist/browser/modules/excel/xlsx/xform/drawing/graphic-frame-xform.d.ts +54 -0
  133. package/dist/browser/modules/excel/xlsx/xform/drawing/graphic-frame-xform.js +225 -0
  134. package/dist/browser/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.d.ts +3 -1
  135. package/dist/browser/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.js +18 -3
  136. package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +46 -0
  137. package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +294 -12
  138. package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.d.ts +13 -2
  139. package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +32 -6
  140. package/dist/browser/modules/excel/xlsx/xform/sheet/chartsheet-xform.d.ts +185 -0
  141. package/dist/browser/modules/excel/xlsx/xform/sheet/chartsheet-xform.js +441 -0
  142. package/dist/browser/modules/excel/xlsx/xform/sheet/ext-lst-xform.d.ts +1 -0
  143. package/dist/browser/modules/excel/xlsx/xform/sheet/ext-lst-xform.js +51 -2
  144. package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +196 -20
  145. package/dist/browser/modules/excel/xlsx/xform/table/auto-filter-xform.js +16 -1
  146. package/dist/browser/modules/excel/xlsx/xform/table/table-column-xform.js +17 -2
  147. package/dist/browser/modules/excel/xlsx/xform/xsd-values.d.ts +63 -0
  148. package/dist/browser/modules/excel/xlsx/xform/xsd-values.js +101 -0
  149. package/dist/browser/modules/excel/xlsx/xlsx.browser.d.ts +115 -21
  150. package/dist/browser/modules/excel/xlsx/xlsx.browser.js +4422 -78
  151. package/dist/browser/modules/pdf/builder/document-builder.d.ts +74 -0
  152. package/dist/browser/modules/pdf/builder/document-builder.js +507 -2
  153. package/dist/browser/modules/pdf/builder/pdf-editor.js +48 -3
  154. package/dist/browser/modules/pdf/excel-bridge.d.ts +69 -0
  155. package/dist/browser/modules/pdf/excel-bridge.js +683 -12
  156. package/dist/browser/modules/pdf/font/font-manager.d.ts +25 -0
  157. package/dist/browser/modules/pdf/font/font-manager.js +39 -0
  158. package/dist/browser/modules/pdf/index.d.ts +5 -2
  159. package/dist/browser/modules/pdf/index.js +3 -1
  160. package/dist/browser/modules/pdf/render/chart-surface.d.ts +33 -0
  161. package/dist/browser/modules/pdf/render/chart-surface.js +200 -0
  162. package/dist/browser/modules/pdf/render/layout-engine.d.ts +22 -1
  163. package/dist/browser/modules/pdf/render/layout-engine.js +436 -56
  164. package/dist/browser/modules/pdf/render/page-renderer.js +169 -28
  165. package/dist/browser/modules/pdf/render/pdf-exporter.js +117 -7
  166. package/dist/browser/modules/pdf/types.d.ts +227 -23
  167. package/dist/browser/modules/pdf/types.js +4 -0
  168. package/dist/browser/modules/pdf/word-bridge.d.ts +47 -0
  169. package/dist/browser/modules/pdf/word-bridge.js +304 -0
  170. package/dist/browser/modules/word/constants.d.ts +179 -0
  171. package/dist/browser/modules/word/constants.js +231 -0
  172. package/dist/browser/modules/word/content-types.d.ts +27 -0
  173. package/dist/browser/modules/word/content-types.js +53 -0
  174. package/dist/browser/modules/word/digital-signatures.d.ts +87 -0
  175. package/dist/browser/modules/word/digital-signatures.js +134 -0
  176. package/dist/browser/modules/word/document.d.ts +728 -0
  177. package/dist/browser/modules/word/document.js +1795 -0
  178. package/dist/browser/modules/word/docx-packager.d.ts +14 -0
  179. package/dist/browser/modules/word/docx-packager.js +822 -0
  180. package/dist/browser/modules/word/docx-reader.d.ts +11 -0
  181. package/dist/browser/modules/word/docx-reader.js +4929 -0
  182. package/dist/browser/modules/word/encryption.d.ts +102 -0
  183. package/dist/browser/modules/word/encryption.js +274 -0
  184. package/dist/browser/modules/word/errors.d.ts +49 -0
  185. package/dist/browser/modules/word/errors.js +68 -0
  186. package/dist/browser/modules/word/font-obfuscation.d.ts +31 -0
  187. package/dist/browser/modules/word/font-obfuscation.js +83 -0
  188. package/dist/browser/modules/word/html-renderer.d.ts +38 -0
  189. package/dist/browser/modules/word/html-renderer.js +782 -0
  190. package/dist/browser/modules/word/index.base.d.ts +19 -0
  191. package/dist/browser/modules/word/index.base.js +51 -0
  192. package/dist/browser/modules/word/index.browser.d.ts +4 -0
  193. package/dist/browser/modules/word/index.browser.js +4 -0
  194. package/dist/browser/modules/word/index.d.ts +4 -0
  195. package/dist/browser/modules/word/index.js +4 -0
  196. package/dist/browser/modules/word/internal-utils.d.ts +23 -0
  197. package/dist/browser/modules/word/internal-utils.js +54 -0
  198. package/dist/browser/modules/word/relationships.d.ts +31 -0
  199. package/dist/browser/modules/word/relationships.js +56 -0
  200. package/dist/browser/modules/word/types.d.ts +2325 -0
  201. package/dist/browser/modules/word/types.js +10 -0
  202. package/dist/browser/modules/word/units.d.ts +49 -0
  203. package/dist/browser/modules/word/units.js +111 -0
  204. package/dist/browser/modules/word/writers/chart-writer.d.ts +10 -0
  205. package/dist/browser/modules/word/writers/chart-writer.js +385 -0
  206. package/dist/browser/modules/word/writers/checkbox-writer.d.ts +9 -0
  207. package/dist/browser/modules/word/writers/checkbox-writer.js +42 -0
  208. package/dist/browser/modules/word/writers/comment-writer.d.ts +15 -0
  209. package/dist/browser/modules/word/writers/comment-writer.js +70 -0
  210. package/dist/browser/modules/word/writers/document-writer.d.ts +16 -0
  211. package/dist/browser/modules/word/writers/document-writer.js +461 -0
  212. package/dist/browser/modules/word/writers/footnote-writer.d.ts +11 -0
  213. package/dist/browser/modules/word/writers/footnote-writer.js +72 -0
  214. package/dist/browser/modules/word/writers/header-footer-writer.d.ts +13 -0
  215. package/dist/browser/modules/word/writers/header-footer-writer.js +129 -0
  216. package/dist/browser/modules/word/writers/image-writer.d.ts +10 -0
  217. package/dist/browser/modules/word/writers/image-writer.js +185 -0
  218. package/dist/browser/modules/word/writers/math-writer.d.ts +9 -0
  219. package/dist/browser/modules/word/writers/math-writer.js +428 -0
  220. package/dist/browser/modules/word/writers/numbering-writer.d.ts +10 -0
  221. package/dist/browser/modules/word/writers/numbering-writer.js +125 -0
  222. package/dist/browser/modules/word/writers/paragraph-writer.d.ts +13 -0
  223. package/dist/browser/modules/word/writers/paragraph-writer.js +516 -0
  224. package/dist/browser/modules/word/writers/parts-writer.d.ts +26 -0
  225. package/dist/browser/modules/word/writers/parts-writer.js +660 -0
  226. package/dist/browser/modules/word/writers/run-writer.d.ts +15 -0
  227. package/dist/browser/modules/word/writers/run-writer.js +649 -0
  228. package/dist/browser/modules/word/writers/section-writer.d.ts +10 -0
  229. package/dist/browser/modules/word/writers/section-writer.js +238 -0
  230. package/dist/browser/modules/word/writers/styles-writer.d.ts +10 -0
  231. package/dist/browser/modules/word/writers/styles-writer.js +242 -0
  232. package/dist/browser/modules/word/writers/table-writer.d.ts +10 -0
  233. package/dist/browser/modules/word/writers/table-writer.js +503 -0
  234. package/dist/browser/modules/word/writers/textbox-writer.d.ts +9 -0
  235. package/dist/browser/modules/word/writers/textbox-writer.js +53 -0
  236. package/dist/browser/modules/word/writers/toc-writer.d.ts +9 -0
  237. package/dist/browser/modules/word/writers/toc-writer.js +79 -0
  238. package/dist/browser/modules/xml/encode.d.ts +56 -7
  239. package/dist/browser/modules/xml/encode.js +157 -11
  240. package/dist/cjs/index.js +13 -2
  241. package/dist/cjs/modules/excel/chart/cache-populator.js +1178 -0
  242. package/dist/cjs/modules/excel/chart/chart-api.js +371 -0
  243. package/dist/cjs/modules/excel/chart/chart-builder.js +2440 -0
  244. package/dist/cjs/modules/excel/chart/chart-ex-builder.js +907 -0
  245. package/dist/cjs/modules/excel/chart/chart-ex-parser.js +1208 -0
  246. package/dist/cjs/modules/excel/chart/chart-ex-renderer.js +5364 -0
  247. package/dist/cjs/modules/excel/chart/chart-ex-types.js +12 -0
  248. package/dist/cjs/modules/excel/chart/chart-images.js +366 -0
  249. package/dist/cjs/modules/excel/chart/chart-presets.js +184 -0
  250. package/dist/cjs/modules/excel/chart/chart-renderer.js +6450 -0
  251. package/dist/cjs/modules/excel/chart/chart-sidecar.js +433 -0
  252. package/dist/cjs/modules/excel/chart/chart-utils.js +845 -0
  253. package/dist/cjs/modules/excel/chart/chart.js +1324 -0
  254. package/dist/cjs/modules/excel/chart/glyph-rasterizer.js +664 -0
  255. package/dist/cjs/modules/excel/chart/index.js +101 -0
  256. package/dist/cjs/modules/excel/chart/install.js +95 -0
  257. package/dist/cjs/modules/excel/chart/shape-properties.js +1577 -0
  258. package/dist/cjs/modules/excel/chart/stroke-font.js +1559 -0
  259. package/dist/cjs/modules/excel/chart/topojson.js +239 -0
  260. package/dist/cjs/modules/excel/chart/types.js +9 -0
  261. package/dist/cjs/modules/excel/chart-host-registry.js +96 -0
  262. package/dist/cjs/modules/excel/chartsheet.js +199 -0
  263. package/dist/cjs/modules/excel/defined-names.js +44 -4
  264. package/dist/cjs/modules/excel/errors.js +11 -1
  265. package/dist/cjs/modules/excel/form-control.js +17 -0
  266. package/dist/cjs/modules/excel/image.js +12 -2
  267. package/dist/cjs/modules/excel/pivot-chart.js +56 -0
  268. package/dist/cjs/modules/excel/pivot-table.js +35 -0
  269. package/dist/cjs/modules/excel/range.js +5 -1
  270. package/dist/cjs/modules/excel/sparkline/index.js +23 -0
  271. package/dist/cjs/modules/excel/sparkline/sparkline.js +756 -0
  272. package/dist/cjs/modules/excel/stream/worksheet-writer.js +3 -2
  273. package/dist/cjs/modules/excel/table.js +42 -6
  274. package/dist/cjs/modules/excel/utils/address.js +29 -0
  275. package/dist/cjs/modules/excel/utils/drawing-utils.js +11 -6
  276. package/dist/cjs/modules/excel/utils/guid.js +38 -0
  277. package/dist/cjs/modules/excel/utils/ooxml-paths.js +246 -9
  278. package/dist/cjs/modules/excel/utils/ooxml-validator/check-chart-sidecar.js +103 -0
  279. package/dist/cjs/modules/excel/utils/ooxml-validator/check-chart.js +2128 -0
  280. package/dist/cjs/modules/excel/utils/ooxml-validator/check-chartsheet.js +29 -0
  281. package/dist/cjs/modules/excel/utils/ooxml-validator/check-content-types.js +184 -0
  282. package/dist/cjs/modules/excel/utils/ooxml-validator/check-drawing.js +270 -0
  283. package/dist/cjs/modules/excel/utils/ooxml-validator/check-pivot.js +107 -0
  284. package/dist/cjs/modules/excel/utils/ooxml-validator/check-relationships.js +188 -0
  285. package/dist/cjs/modules/excel/utils/ooxml-validator/check-structure.js +60 -0
  286. package/dist/cjs/modules/excel/utils/ooxml-validator/check-styles.js +92 -0
  287. package/dist/cjs/modules/excel/utils/ooxml-validator/check-table.js +180 -0
  288. package/dist/cjs/modules/excel/utils/ooxml-validator/check-workbook.js +166 -0
  289. package/dist/cjs/modules/excel/utils/ooxml-validator/check-worksheet.js +572 -0
  290. package/dist/cjs/modules/excel/utils/ooxml-validator/context.js +196 -0
  291. package/dist/cjs/modules/excel/utils/ooxml-validator/index.js +105 -0
  292. package/dist/cjs/modules/excel/utils/ooxml-validator/path-utils.js +168 -0
  293. package/dist/cjs/modules/excel/utils/ooxml-validator/reporter.js +66 -0
  294. package/dist/cjs/modules/excel/utils/ooxml-validator/types.js +13 -0
  295. package/dist/cjs/modules/excel/utils/ooxml-validator/xml-utils.js +110 -0
  296. package/dist/cjs/modules/excel/workbook.browser.js +973 -38
  297. package/dist/cjs/modules/excel/workbook.js +48 -0
  298. package/dist/cjs/modules/excel/worksheet.js +393 -34
  299. package/dist/cjs/modules/excel/xlsx/rel-type.js +41 -1
  300. package/dist/cjs/modules/excel/xlsx/xform/book/defined-name-xform.js +11 -2
  301. package/dist/cjs/modules/excel/xlsx/xform/book/external-link-xform.js +12 -10
  302. package/dist/cjs/modules/excel/xlsx/xform/book/workbook-xform.js +96 -22
  303. package/dist/cjs/modules/excel/xlsx/xform/chart/chart-space-xform.js +6003 -0
  304. package/dist/cjs/modules/excel/xlsx/xform/comment/threaded-comments-xform.js +219 -0
  305. package/dist/cjs/modules/excel/xlsx/xform/core/content-types-xform.js +149 -10
  306. package/dist/cjs/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +20 -1
  307. package/dist/cjs/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +1 -1
  308. package/dist/cjs/modules/excel/xlsx/xform/drawing/drawing-xform.js +109 -5
  309. package/dist/cjs/modules/excel/xlsx/xform/drawing/graphic-frame-xform.js +228 -0
  310. package/dist/cjs/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.js +18 -3
  311. package/dist/cjs/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +294 -12
  312. package/dist/cjs/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +32 -6
  313. package/dist/cjs/modules/excel/xlsx/xform/sheet/chartsheet-xform.js +444 -0
  314. package/dist/cjs/modules/excel/xlsx/xform/sheet/ext-lst-xform.js +51 -2
  315. package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +195 -19
  316. package/dist/cjs/modules/excel/xlsx/xform/table/auto-filter-xform.js +16 -1
  317. package/dist/cjs/modules/excel/xlsx/xform/table/table-column-xform.js +17 -2
  318. package/dist/cjs/modules/excel/xlsx/xform/xsd-values.js +106 -0
  319. package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +4420 -76
  320. package/dist/cjs/modules/pdf/builder/document-builder.js +506 -1
  321. package/dist/cjs/modules/pdf/builder/pdf-editor.js +48 -3
  322. package/dist/cjs/modules/pdf/excel-bridge.js +684 -12
  323. package/dist/cjs/modules/pdf/font/font-manager.js +39 -0
  324. package/dist/cjs/modules/pdf/index.js +5 -1
  325. package/dist/cjs/modules/pdf/render/chart-surface.js +203 -0
  326. package/dist/cjs/modules/pdf/render/layout-engine.js +437 -56
  327. package/dist/cjs/modules/pdf/render/page-renderer.js +169 -28
  328. package/dist/cjs/modules/pdf/render/pdf-exporter.js +115 -5
  329. package/dist/cjs/modules/pdf/types.js +5 -0
  330. package/dist/cjs/modules/pdf/word-bridge.js +307 -0
  331. package/dist/cjs/modules/word/constants.js +234 -0
  332. package/dist/cjs/modules/word/content-types.js +57 -0
  333. package/dist/cjs/modules/word/digital-signatures.js +140 -0
  334. package/dist/cjs/modules/word/document.js +1909 -0
  335. package/dist/cjs/modules/word/docx-packager.js +825 -0
  336. package/dist/cjs/modules/word/docx-reader.js +4932 -0
  337. package/dist/cjs/modules/word/encryption.js +282 -0
  338. package/dist/cjs/modules/word/errors.js +88 -0
  339. package/dist/cjs/modules/word/font-obfuscation.js +88 -0
  340. package/dist/cjs/modules/word/html-renderer.js +785 -0
  341. package/dist/cjs/modules/word/index.base.js +199 -0
  342. package/dist/cjs/modules/word/index.browser.js +20 -0
  343. package/dist/cjs/modules/word/index.js +20 -0
  344. package/dist/cjs/modules/word/internal-utils.js +59 -0
  345. package/dist/cjs/modules/word/relationships.js +60 -0
  346. package/dist/cjs/modules/word/types.js +11 -0
  347. package/dist/cjs/modules/word/units.js +135 -0
  348. package/dist/cjs/modules/word/writers/chart-writer.js +388 -0
  349. package/dist/cjs/modules/word/writers/checkbox-writer.js +45 -0
  350. package/dist/cjs/modules/word/writers/comment-writer.js +74 -0
  351. package/dist/cjs/modules/word/writers/document-writer.js +465 -0
  352. package/dist/cjs/modules/word/writers/footnote-writer.js +76 -0
  353. package/dist/cjs/modules/word/writers/header-footer-writer.js +134 -0
  354. package/dist/cjs/modules/word/writers/image-writer.js +188 -0
  355. package/dist/cjs/modules/word/writers/math-writer.js +431 -0
  356. package/dist/cjs/modules/word/writers/numbering-writer.js +128 -0
  357. package/dist/cjs/modules/word/writers/paragraph-writer.js +521 -0
  358. package/dist/cjs/modules/word/writers/parts-writer.js +671 -0
  359. package/dist/cjs/modules/word/writers/run-writer.js +655 -0
  360. package/dist/cjs/modules/word/writers/section-writer.js +241 -0
  361. package/dist/cjs/modules/word/writers/styles-writer.js +245 -0
  362. package/dist/cjs/modules/word/writers/table-writer.js +506 -0
  363. package/dist/cjs/modules/word/writers/textbox-writer.js +56 -0
  364. package/dist/cjs/modules/word/writers/toc-writer.js +82 -0
  365. package/dist/cjs/modules/xml/encode.js +158 -11
  366. package/dist/esm/index.browser.js +20 -2
  367. package/dist/esm/index.js +9 -1
  368. package/dist/esm/modules/excel/chart/cache-populator.js +1171 -0
  369. package/dist/esm/modules/excel/chart/chart-api.js +364 -0
  370. package/dist/esm/modules/excel/chart/chart-builder.js +2432 -0
  371. package/dist/esm/modules/excel/chart/chart-ex-builder.js +903 -0
  372. package/dist/esm/modules/excel/chart/chart-ex-parser.js +1205 -0
  373. package/dist/esm/modules/excel/chart/chart-ex-renderer.js +5352 -0
  374. package/dist/esm/modules/excel/chart/chart-ex-types.js +11 -0
  375. package/dist/esm/modules/excel/chart/chart-images.js +363 -0
  376. package/dist/esm/modules/excel/chart/chart-presets.js +179 -0
  377. package/dist/esm/modules/excel/chart/chart-renderer.js +6440 -0
  378. package/dist/esm/modules/excel/chart/chart-sidecar.js +427 -0
  379. package/dist/esm/modules/excel/chart/chart-utils.js +821 -0
  380. package/dist/esm/modules/excel/chart/chart.js +1320 -0
  381. package/dist/esm/modules/excel/chart/glyph-rasterizer.js +658 -0
  382. package/dist/esm/modules/excel/chart/index.js +46 -0
  383. package/dist/esm/modules/excel/chart/install.js +91 -0
  384. package/dist/esm/modules/excel/chart/shape-properties.js +1557 -0
  385. package/dist/esm/modules/excel/chart/stroke-font.js +1556 -0
  386. package/dist/esm/modules/excel/chart/topojson.js +236 -0
  387. package/dist/esm/modules/excel/chart/types.js +8 -0
  388. package/dist/esm/modules/excel/chart-host-registry.js +90 -0
  389. package/dist/esm/modules/excel/chartsheet.js +196 -0
  390. package/dist/esm/modules/excel/defined-names.js +44 -4
  391. package/dist/esm/modules/excel/errors.js +9 -0
  392. package/dist/esm/modules/excel/form-control.js +17 -0
  393. package/dist/esm/modules/excel/image.js +12 -2
  394. package/dist/esm/modules/excel/pivot-chart.js +53 -0
  395. package/dist/esm/modules/excel/pivot-table.js +35 -0
  396. package/dist/esm/modules/excel/range.js +5 -1
  397. package/dist/esm/modules/excel/sparkline/index.js +7 -0
  398. package/dist/esm/modules/excel/sparkline/sparkline.js +750 -0
  399. package/dist/esm/modules/excel/stream/worksheet-writer.js +3 -2
  400. package/dist/esm/modules/excel/table.js +42 -6
  401. package/dist/esm/modules/excel/utils/address.js +28 -0
  402. package/dist/esm/modules/excel/utils/drawing-utils.js +11 -6
  403. package/dist/esm/modules/excel/utils/guid.js +35 -0
  404. package/dist/esm/modules/excel/utils/ooxml-paths.js +206 -9
  405. package/dist/esm/modules/excel/utils/ooxml-validator/check-chart-sidecar.js +101 -0
  406. package/dist/esm/modules/excel/utils/ooxml-validator/check-chart.js +2125 -0
  407. package/dist/esm/modules/excel/utils/ooxml-validator/check-chartsheet.js +26 -0
  408. package/dist/esm/modules/excel/utils/ooxml-validator/check-content-types.js +181 -0
  409. package/dist/esm/modules/excel/utils/ooxml-validator/check-drawing.js +267 -0
  410. package/dist/esm/modules/excel/utils/ooxml-validator/check-pivot.js +104 -0
  411. package/dist/esm/modules/excel/utils/ooxml-validator/check-relationships.js +184 -0
  412. package/dist/esm/modules/excel/utils/ooxml-validator/check-structure.js +56 -0
  413. package/dist/esm/modules/excel/utils/ooxml-validator/check-styles.js +89 -0
  414. package/dist/esm/modules/excel/utils/ooxml-validator/check-table.js +177 -0
  415. package/dist/esm/modules/excel/utils/ooxml-validator/check-workbook.js +163 -0
  416. package/dist/esm/modules/excel/utils/ooxml-validator/check-worksheet.js +569 -0
  417. package/dist/esm/modules/excel/utils/ooxml-validator/context.js +191 -0
  418. package/dist/esm/modules/excel/utils/ooxml-validator/index.js +102 -0
  419. package/dist/esm/modules/excel/utils/ooxml-validator/path-utils.js +156 -0
  420. package/dist/esm/modules/excel/utils/ooxml-validator/reporter.js +61 -0
  421. package/dist/esm/modules/excel/utils/ooxml-validator/types.js +12 -0
  422. package/dist/esm/modules/excel/utils/ooxml-validator/xml-utils.js +100 -0
  423. package/dist/esm/modules/excel/workbook.browser.js +969 -34
  424. package/dist/esm/modules/excel/workbook.js +48 -0
  425. package/dist/esm/modules/excel/worksheet.js +394 -35
  426. package/dist/esm/modules/excel/xlsx/rel-type.js +41 -1
  427. package/dist/esm/modules/excel/xlsx/xform/book/defined-name-xform.js +11 -2
  428. package/dist/esm/modules/excel/xlsx/xform/book/external-link-xform.js +12 -10
  429. package/dist/esm/modules/excel/xlsx/xform/book/workbook-xform.js +96 -22
  430. package/dist/esm/modules/excel/xlsx/xform/chart/chart-space-xform.js +6000 -0
  431. package/dist/esm/modules/excel/xlsx/xform/comment/threaded-comments-xform.js +213 -0
  432. package/dist/esm/modules/excel/xlsx/xform/core/content-types-xform.js +150 -11
  433. package/dist/esm/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +20 -1
  434. package/dist/esm/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +1 -1
  435. package/dist/esm/modules/excel/xlsx/xform/drawing/drawing-xform.js +109 -5
  436. package/dist/esm/modules/excel/xlsx/xform/drawing/graphic-frame-xform.js +225 -0
  437. package/dist/esm/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.js +18 -3
  438. package/dist/esm/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +294 -12
  439. package/dist/esm/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +32 -6
  440. package/dist/esm/modules/excel/xlsx/xform/sheet/chartsheet-xform.js +441 -0
  441. package/dist/esm/modules/excel/xlsx/xform/sheet/ext-lst-xform.js +51 -2
  442. package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +196 -20
  443. package/dist/esm/modules/excel/xlsx/xform/table/auto-filter-xform.js +16 -1
  444. package/dist/esm/modules/excel/xlsx/xform/table/table-column-xform.js +17 -2
  445. package/dist/esm/modules/excel/xlsx/xform/xsd-values.js +101 -0
  446. package/dist/esm/modules/excel/xlsx/xlsx.browser.js +4422 -78
  447. package/dist/esm/modules/pdf/builder/document-builder.js +507 -2
  448. package/dist/esm/modules/pdf/builder/pdf-editor.js +48 -3
  449. package/dist/esm/modules/pdf/excel-bridge.js +683 -12
  450. package/dist/esm/modules/pdf/font/font-manager.js +39 -0
  451. package/dist/esm/modules/pdf/index.js +3 -1
  452. package/dist/esm/modules/pdf/render/chart-surface.js +200 -0
  453. package/dist/esm/modules/pdf/render/layout-engine.js +436 -56
  454. package/dist/esm/modules/pdf/render/page-renderer.js +169 -28
  455. package/dist/esm/modules/pdf/render/pdf-exporter.js +117 -7
  456. package/dist/esm/modules/pdf/types.js +4 -0
  457. package/dist/esm/modules/pdf/word-bridge.js +304 -0
  458. package/dist/esm/modules/word/constants.js +231 -0
  459. package/dist/esm/modules/word/content-types.js +53 -0
  460. package/dist/esm/modules/word/digital-signatures.js +134 -0
  461. package/dist/esm/modules/word/document.js +1795 -0
  462. package/dist/esm/modules/word/docx-packager.js +822 -0
  463. package/dist/esm/modules/word/docx-reader.js +4929 -0
  464. package/dist/esm/modules/word/encryption.js +274 -0
  465. package/dist/esm/modules/word/errors.js +68 -0
  466. package/dist/esm/modules/word/font-obfuscation.js +83 -0
  467. package/dist/esm/modules/word/html-renderer.js +782 -0
  468. package/dist/esm/modules/word/index.base.js +51 -0
  469. package/dist/esm/modules/word/index.browser.js +4 -0
  470. package/dist/esm/modules/word/index.js +4 -0
  471. package/dist/esm/modules/word/internal-utils.js +54 -0
  472. package/dist/esm/modules/word/relationships.js +56 -0
  473. package/dist/esm/modules/word/types.js +10 -0
  474. package/dist/esm/modules/word/units.js +111 -0
  475. package/dist/esm/modules/word/writers/chart-writer.js +385 -0
  476. package/dist/esm/modules/word/writers/checkbox-writer.js +42 -0
  477. package/dist/esm/modules/word/writers/comment-writer.js +70 -0
  478. package/dist/esm/modules/word/writers/document-writer.js +461 -0
  479. package/dist/esm/modules/word/writers/footnote-writer.js +72 -0
  480. package/dist/esm/modules/word/writers/header-footer-writer.js +129 -0
  481. package/dist/esm/modules/word/writers/image-writer.js +185 -0
  482. package/dist/esm/modules/word/writers/math-writer.js +428 -0
  483. package/dist/esm/modules/word/writers/numbering-writer.js +125 -0
  484. package/dist/esm/modules/word/writers/paragraph-writer.js +516 -0
  485. package/dist/esm/modules/word/writers/parts-writer.js +660 -0
  486. package/dist/esm/modules/word/writers/run-writer.js +649 -0
  487. package/dist/esm/modules/word/writers/section-writer.js +238 -0
  488. package/dist/esm/modules/word/writers/styles-writer.js +242 -0
  489. package/dist/esm/modules/word/writers/table-writer.js +503 -0
  490. package/dist/esm/modules/word/writers/textbox-writer.js +53 -0
  491. package/dist/esm/modules/word/writers/toc-writer.js +79 -0
  492. package/dist/esm/modules/xml/encode.js +157 -11
  493. package/dist/iife/excelts.iife.js +11789 -687
  494. package/dist/iife/excelts.iife.js.map +1 -1
  495. package/dist/iife/excelts.iife.min.js +52 -44
  496. package/dist/types/index.browser.d.ts +8 -5
  497. package/dist/types/index.d.ts +4 -2
  498. package/dist/types/modules/excel/chart/cache-populator.d.ts +49 -0
  499. package/dist/types/modules/excel/chart/chart-api.d.ts +92 -0
  500. package/dist/types/modules/excel/chart/chart-builder.d.ts +48 -0
  501. package/dist/types/modules/excel/chart/chart-ex-builder.d.ts +36 -0
  502. package/dist/types/modules/excel/chart/chart-ex-parser.d.ts +8 -0
  503. package/dist/types/modules/excel/chart/chart-ex-renderer.d.ts +187 -0
  504. package/dist/types/modules/excel/chart/chart-ex-types.d.ts +531 -0
  505. package/dist/types/modules/excel/chart/chart-images.d.ts +78 -0
  506. package/dist/types/modules/excel/chart/chart-presets.d.ts +392 -0
  507. package/dist/types/modules/excel/chart/chart-renderer.d.ts +550 -0
  508. package/dist/types/modules/excel/chart/chart-sidecar.d.ts +21 -0
  509. package/dist/types/modules/excel/chart/chart-utils.d.ts +306 -0
  510. package/dist/types/modules/excel/chart/chart.d.ts +504 -0
  511. package/dist/types/modules/excel/chart/glyph-rasterizer.d.ts +62 -0
  512. package/dist/types/modules/excel/chart/index.d.ts +54 -0
  513. package/dist/types/modules/excel/chart/install.d.ts +44 -0
  514. package/dist/types/modules/excel/chart/shape-properties.d.ts +156 -0
  515. package/dist/types/modules/excel/chart/stroke-font.d.ts +36 -0
  516. package/dist/types/modules/excel/chart/topojson.d.ts +98 -0
  517. package/dist/types/modules/excel/chart/types.d.ts +2559 -0
  518. package/dist/types/modules/excel/chart-host-registry.d.ts +157 -0
  519. package/dist/types/modules/excel/chartsheet.d.ts +102 -0
  520. package/dist/types/modules/excel/defined-names.d.ts +35 -0
  521. package/dist/types/modules/excel/errors.d.ts +6 -0
  522. package/dist/types/modules/excel/form-control.d.ts +6 -0
  523. package/dist/types/modules/excel/pivot-chart.d.ts +7 -0
  524. package/dist/types/modules/excel/pivot-table.d.ts +55 -0
  525. package/dist/types/modules/excel/sparkline/index.d.ts +7 -0
  526. package/dist/types/modules/excel/sparkline/sparkline.d.ts +206 -0
  527. package/dist/types/modules/excel/types.d.ts +72 -0
  528. package/dist/types/modules/excel/utils/address.d.ts +18 -0
  529. package/dist/types/modules/excel/utils/guid.d.ts +15 -0
  530. package/dist/types/modules/excel/utils/ooxml-paths.d.ts +74 -0
  531. package/dist/types/modules/excel/utils/ooxml-validator/check-chart-sidecar.d.ts +35 -0
  532. package/dist/types/modules/excel/utils/ooxml-validator/check-chart.d.ts +32 -0
  533. package/dist/types/modules/excel/utils/ooxml-validator/check-chartsheet.d.ts +9 -0
  534. package/dist/types/modules/excel/utils/ooxml-validator/check-content-types.d.ts +16 -0
  535. package/dist/types/modules/excel/utils/ooxml-validator/check-drawing.d.ts +34 -0
  536. package/dist/types/modules/excel/utils/ooxml-validator/check-pivot.d.ts +14 -0
  537. package/dist/types/modules/excel/utils/ooxml-validator/check-relationships.d.ts +18 -0
  538. package/dist/types/modules/excel/utils/ooxml-validator/check-structure.d.ts +21 -0
  539. package/dist/types/modules/excel/utils/ooxml-validator/check-styles.d.ts +15 -0
  540. package/dist/types/modules/excel/utils/ooxml-validator/check-table.d.ts +31 -0
  541. package/dist/types/modules/excel/utils/ooxml-validator/check-workbook.d.ts +19 -0
  542. package/dist/types/modules/excel/utils/ooxml-validator/check-worksheet.d.ts +25 -0
  543. package/dist/types/modules/excel/utils/ooxml-validator/context.d.ts +85 -0
  544. package/dist/types/modules/excel/utils/ooxml-validator/index.d.ts +31 -0
  545. package/dist/types/modules/excel/utils/ooxml-validator/path-utils.d.ts +67 -0
  546. package/dist/types/modules/excel/utils/ooxml-validator/reporter.d.ts +41 -0
  547. package/dist/types/modules/excel/utils/ooxml-validator/types.d.ts +109 -0
  548. package/dist/types/modules/excel/utils/ooxml-validator/xml-utils.d.ts +38 -0
  549. package/dist/types/modules/excel/workbook.browser.d.ts +248 -30
  550. package/dist/types/modules/excel/workbook.d.ts +43 -0
  551. package/dist/types/modules/excel/worksheet.d.ts +157 -3
  552. package/dist/types/modules/excel/xlsx/rel-type.d.ts +40 -0
  553. package/dist/types/modules/excel/xlsx/xform/book/defined-name-xform.d.ts +1 -0
  554. package/dist/types/modules/excel/xlsx/xform/chart/chart-space-xform.d.ts +353 -0
  555. package/dist/types/modules/excel/xlsx/xform/comment/threaded-comments-xform.d.ts +60 -0
  556. package/dist/types/modules/excel/xlsx/xform/drawing/drawing-xform.d.ts +30 -0
  557. package/dist/types/modules/excel/xlsx/xform/drawing/graphic-frame-xform.d.ts +54 -0
  558. package/dist/types/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.d.ts +3 -1
  559. package/dist/types/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +46 -0
  560. package/dist/types/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.d.ts +13 -2
  561. package/dist/types/modules/excel/xlsx/xform/sheet/chartsheet-xform.d.ts +185 -0
  562. package/dist/types/modules/excel/xlsx/xform/sheet/ext-lst-xform.d.ts +1 -0
  563. package/dist/types/modules/excel/xlsx/xform/xsd-values.d.ts +63 -0
  564. package/dist/types/modules/excel/xlsx/xlsx.browser.d.ts +115 -21
  565. package/dist/types/modules/pdf/builder/document-builder.d.ts +74 -0
  566. package/dist/types/modules/pdf/excel-bridge.d.ts +69 -0
  567. package/dist/types/modules/pdf/font/font-manager.d.ts +25 -0
  568. package/dist/types/modules/pdf/index.d.ts +5 -2
  569. package/dist/types/modules/pdf/render/chart-surface.d.ts +33 -0
  570. package/dist/types/modules/pdf/render/layout-engine.d.ts +22 -1
  571. package/dist/types/modules/pdf/types.d.ts +227 -23
  572. package/dist/types/modules/pdf/word-bridge.d.ts +47 -0
  573. package/dist/types/modules/word/constants.d.ts +179 -0
  574. package/dist/types/modules/word/content-types.d.ts +27 -0
  575. package/dist/types/modules/word/digital-signatures.d.ts +87 -0
  576. package/dist/types/modules/word/document.d.ts +728 -0
  577. package/dist/types/modules/word/docx-packager.d.ts +14 -0
  578. package/dist/types/modules/word/docx-reader.d.ts +11 -0
  579. package/dist/types/modules/word/encryption.d.ts +102 -0
  580. package/dist/types/modules/word/errors.d.ts +49 -0
  581. package/dist/types/modules/word/font-obfuscation.d.ts +31 -0
  582. package/dist/types/modules/word/html-renderer.d.ts +38 -0
  583. package/dist/types/modules/word/index.base.d.ts +19 -0
  584. package/dist/types/modules/word/index.browser.d.ts +4 -0
  585. package/dist/types/modules/word/index.d.ts +4 -0
  586. package/dist/types/modules/word/internal-utils.d.ts +23 -0
  587. package/dist/types/modules/word/relationships.d.ts +31 -0
  588. package/dist/types/modules/word/types.d.ts +2325 -0
  589. package/dist/types/modules/word/units.d.ts +49 -0
  590. package/dist/types/modules/word/writers/chart-writer.d.ts +10 -0
  591. package/dist/types/modules/word/writers/checkbox-writer.d.ts +9 -0
  592. package/dist/types/modules/word/writers/comment-writer.d.ts +15 -0
  593. package/dist/types/modules/word/writers/document-writer.d.ts +16 -0
  594. package/dist/types/modules/word/writers/footnote-writer.d.ts +11 -0
  595. package/dist/types/modules/word/writers/header-footer-writer.d.ts +13 -0
  596. package/dist/types/modules/word/writers/image-writer.d.ts +10 -0
  597. package/dist/types/modules/word/writers/math-writer.d.ts +9 -0
  598. package/dist/types/modules/word/writers/numbering-writer.d.ts +10 -0
  599. package/dist/types/modules/word/writers/paragraph-writer.d.ts +13 -0
  600. package/dist/types/modules/word/writers/parts-writer.d.ts +26 -0
  601. package/dist/types/modules/word/writers/run-writer.d.ts +15 -0
  602. package/dist/types/modules/word/writers/section-writer.d.ts +10 -0
  603. package/dist/types/modules/word/writers/styles-writer.d.ts +10 -0
  604. package/dist/types/modules/word/writers/table-writer.d.ts +10 -0
  605. package/dist/types/modules/word/writers/textbox-writer.d.ts +9 -0
  606. package/dist/types/modules/word/writers/toc-writer.d.ts +9 -0
  607. package/dist/types/modules/xml/encode.d.ts +56 -7
  608. package/package.json +29 -11
  609. package/dist/browser/modules/excel/utils/ooxml-validator.d.ts +0 -48
  610. package/dist/browser/modules/excel/utils/ooxml-validator.js +0 -493
  611. package/dist/browser/modules/excel/utils/passthrough-manager.d.ts +0 -77
  612. package/dist/browser/modules/excel/utils/passthrough-manager.js +0 -129
  613. package/dist/cjs/modules/excel/utils/ooxml-validator.js +0 -499
  614. package/dist/cjs/modules/excel/utils/passthrough-manager.js +0 -133
  615. package/dist/esm/modules/excel/utils/ooxml-validator.js +0 -493
  616. package/dist/esm/modules/excel/utils/passthrough-manager.js +0 -129
  617. package/dist/types/modules/excel/utils/ooxml-validator.d.ts +0 -48
  618. package/dist/types/modules/excel/utils/passthrough-manager.d.ts +0 -77
@@ -13,13 +13,22 @@ import { formatCsv } from "../csv/format/index.js";
13
13
  import { parseCsv } from "../csv/parse/index.js";
14
14
  import { CsvParserStream, CsvFormatterStream } from "../csv/stream/index.js";
15
15
  import { parseNumberFromCsv } from "../csv/utils/number.js";
16
+ // Chart runtime accessed through the host-registry slot; see
17
+ // `chart-host-registry.ts` and `chart/install.ts`. Keeps chart code
18
+ // out of consumer bundles when they don't import
19
+ // `@cj-tech-master/excelts/chart`.
20
+ import { getChartSupport } from "./chart-host-registry.js";
21
+ import { Chartsheet } from "./chartsheet.js";
16
22
  import { DefinedNames } from "./defined-names.js";
17
- import { ExcelDownloadError, ExcelNotSupportedError } from "./errors.js";
18
- import { WorkbookReader } from "./stream/workbook-reader.js";
19
- import { WorkbookWriter } from "./stream/workbook-writer.js";
23
+ import { ExcelDownloadError, ExcelNotSupportedError, WorksheetNameError } from "./errors.js";
24
+ import { withPivotChartSource } from "./pivot-chart.js";
25
+ import { WorkbookReader } from "./stream/workbook-reader.browser.js";
26
+ import { WorkbookWriter } from "./stream/workbook-writer.browser.js";
27
+ import { synthGuid } from "./utils/guid.js";
20
28
  import { buildWorkbookProtection } from "./utils/workbook-protection.js";
21
29
  import { Worksheet } from "./worksheet.js";
22
- import { XLSX } from "./xlsx/xlsx.js";
30
+ import { RelType } from "./xlsx/rel-type.js";
31
+ import { XLSX } from "./xlsx/xlsx.browser.js";
23
32
  import { invokeFormulaEngine } from "../formula/host-registry.js";
24
33
  import { formatMarkdown } from "../markdown/format/index.js";
25
34
  import { parseMarkdown, parseMarkdownAll } from "../markdown/parse/index.js";
@@ -265,6 +274,22 @@ function buildFormatterOptions(options) {
265
274
  writeHeaders: options?.writeHeaders
266
275
  };
267
276
  }
277
+ function isComboChartOptions(chart) {
278
+ return !!chart && typeof chart === "object" && "groups" in chart;
279
+ }
280
+ function isChartExOptions(chart) {
281
+ return !!chart && typeof chart === "object" && "type" in chart && isChartExType(chart.type);
282
+ }
283
+ function isChartExType(type) {
284
+ return (type === "sunburst" ||
285
+ type === "treemap" ||
286
+ type === "waterfall" ||
287
+ type === "funnel" ||
288
+ type === "histogram" ||
289
+ type === "pareto" ||
290
+ type === "boxWhisker" ||
291
+ type === "regionMap");
292
+ }
268
293
  // =============================================================================
269
294
  // Workbook Class
270
295
  // =============================================================================
@@ -300,8 +325,21 @@ class Workbook {
300
325
  this.media = [];
301
326
  this.pivotTables = [];
302
327
  this.externalLinks = [];
303
- this._passthrough = {};
304
- this._rawDrawings = {};
328
+ this._chartEntries = {};
329
+ this._chartRels = {};
330
+ this._chartStyles = {};
331
+ this._chartColors = {};
332
+ this._chartExStyles = {};
333
+ this._chartExColors = {};
334
+ this._chartExEntries = {};
335
+ this._chartExRels = {};
336
+ this._chartExStructuredEntries = {};
337
+ this._chartsheets = [];
338
+ this._persons = [];
339
+ this._slicerParts = {};
340
+ this._slicerCacheParts = {};
341
+ this._timelineParts = {};
342
+ this._timelineCacheParts = {};
305
343
  this._writerExternalLinkCache = new Map();
306
344
  this._definedNames = new DefinedNames(options?.formulaSyntaxProbe);
307
345
  }
@@ -346,11 +384,97 @@ class Workbook {
346
384
  // Deep copy via model: the getter serializes ALL worksheet properties and the
347
385
  // setter deserializes them, so future properties are automatically included.
348
386
  const sourceModel = source.model;
387
+ // Remap chart numbers so the source's `chartNumber` / `chartExNumber`
388
+ // references point at entries we actually copy into the target
389
+ // workbook. Build the map here so the rewritten `charts` array and
390
+ // the copied entries use consistent ids.
391
+ const chartMap = new Map();
392
+ const chartExMap = new Map();
393
+ const sourceWorkbook = source.workbook;
394
+ const differentWorkbook = sourceWorkbook !== this;
395
+ const sourceCharts = sourceModel.charts ?? [];
396
+ // `nextChartNumber()` / `nextChartExNumber()` compute `max(existing) + 1`
397
+ // from the entry maps — they do NOT reserve a slot. Calling them in
398
+ // a tight loop without an intervening `addChartEntry` therefore
399
+ // returns the SAME number N times, and the second loop below then
400
+ // overwrites `_chartEntries[dstNum]` repeatedly — only the last
401
+ // cloned entry survives, the others are silently lost. Track the
402
+ // allocator locally so each source chart gets a unique target slot.
403
+ let nextChartAlloc = this.nextChartNumber();
404
+ let nextChartExAlloc = this.nextChartExNumber();
405
+ for (const anchor of sourceCharts) {
406
+ if (anchor.chartNumber && anchor.chartNumber > 0 && !chartMap.has(anchor.chartNumber)) {
407
+ chartMap.set(anchor.chartNumber, nextChartAlloc++);
408
+ }
409
+ if (anchor.chartExNumber &&
410
+ anchor.chartExNumber > 0 &&
411
+ !chartExMap.has(anchor.chartExNumber)) {
412
+ chartExMap.set(anchor.chartExNumber, nextChartExAlloc++);
413
+ }
414
+ }
415
+ const remappedCharts = sourceCharts.map(anchor => ({
416
+ ...anchor,
417
+ chartNumber: anchor.chartNumber
418
+ ? (chartMap.get(anchor.chartNumber) ?? anchor.chartNumber)
419
+ : anchor.chartNumber,
420
+ chartExNumber: anchor.chartExNumber
421
+ ? (chartExMap.get(anchor.chartExNumber) ?? anchor.chartExNumber)
422
+ : anchor.chartExNumber
423
+ }));
349
424
  newWs.model = {
350
425
  ...sourceModel,
351
426
  id: newWs.id,
352
- name: newWs.name
427
+ name: newWs.name,
428
+ charts: remappedCharts
353
429
  };
430
+ // Copy the actual chart parts + sidecars into the target workbook
431
+ // so the remapped `charts` array references live entries. Without
432
+ // this, `importSheet` left the target with chart anchors but no
433
+ // backing chart XML, producing a broken package on save. We copy
434
+ // both the structured model (via `getChartEntry` / `addChartEntry`
435
+ // — the public API) and all sidecars (`copyChartSidecars` /
436
+ // `copyChartExSidecars`).
437
+ if (chartMap.size > 0 || chartExMap.size > 0) {
438
+ for (const [srcNum, dstNum] of chartMap) {
439
+ const entry = sourceWorkbook.getChartEntry(srcNum);
440
+ if (!entry) {
441
+ continue;
442
+ }
443
+ // Deep-clone the entry with every metadata field preserved —
444
+ // rawData / userShapesXml (byte slices), modelSnapshot and the
445
+ // dirty / preferRawPatch / requireRawPatch writer hints, plus
446
+ // per-entry `rels`. Previously only `model`, `rawData`, and
447
+ // `userShapesXml` were copied, so the cross-workbook import
448
+ // path produced charts where the raw-patch fast path couldn't
449
+ // run and the change-detection snapshot didn't reflect the
450
+ // source entry's load-time state.
451
+ this.addChartEntry(cloneChartEntry(entry, dstNum));
452
+ if (differentWorkbook) {
453
+ sourceWorkbook.copyChartSidecars(srcNum, dstNum, this);
454
+ }
455
+ else {
456
+ this.copyChartSidecars(srcNum, dstNum);
457
+ }
458
+ }
459
+ for (const [srcNum, dstNum] of chartExMap) {
460
+ const exEntry = sourceWorkbook.getChartExStructuredEntry?.(srcNum);
461
+ if (exEntry) {
462
+ this.addChartExStructuredEntry(cloneChartExEntry(exEntry, dstNum));
463
+ }
464
+ else {
465
+ const rawBytes = sourceWorkbook._chartExEntries?.[srcNum];
466
+ if (rawBytes) {
467
+ this._chartExEntries[dstNum] = rawBytes.slice();
468
+ }
469
+ }
470
+ if (differentWorkbook) {
471
+ sourceWorkbook.copyChartExSidecars(srcNum, dstNum, this);
472
+ }
473
+ else {
474
+ this.copyChartExSidecars(srcNum, dstNum);
475
+ }
476
+ }
477
+ }
354
478
  return newWs;
355
479
  }
356
480
  // ===========================================================================
@@ -885,17 +1009,14 @@ class Workbook {
885
1009
  * Create a streaming workbook writer for large files.
886
1010
  * This is more memory-efficient than using Workbook for large datasets.
887
1011
  *
888
- * @param options - Options for the workbook writer
889
- * - Node.js: can use { filename } or { stream }
890
- * - Browser: must use { stream }
891
- * @returns A new WorkbookWriter instance
1012
+ * File-path output (`{ filename }`) is a Node.js-only feature and is
1013
+ * exposed by the Node `Workbook` subclass, which overrides this
1014
+ * factory to return the Node `WorkbookWriter`. This browser base
1015
+ * only accepts `{ stream }`.
892
1016
  *
893
1017
  * @example
894
1018
  * ```ts
895
- * // Node.js with filename
896
- * const writer = Workbook.createStreamWriter({ filename: "large-file.xlsx" });
897
- *
898
- * // Browser or Node.js with stream
1019
+ * // Browser (or Node.js with an explicit stream)
899
1020
  * const writer = Workbook.createStreamWriter({ stream: writableStream });
900
1021
  *
901
1022
  * const sheet = writer.addWorksheet("Sheet1");
@@ -912,16 +1033,15 @@ class Workbook {
912
1033
  * Create a streaming workbook reader for large files.
913
1034
  * This is more memory-efficient than using Workbook.xlsx.readFile for large datasets.
914
1035
  *
915
- * @param input - File path (Node.js only) or readable stream
916
- * @param options - Options for the workbook reader
917
- * @returns A new WorkbookReader instance
1036
+ * File-path input (`string`) is a Node.js-only feature and is exposed
1037
+ * by the Node `Workbook` subclass, which overrides this factory to
1038
+ * return the Node `WorkbookReader`. This browser base accepts the
1039
+ * cross-platform `CommonInput` type
1040
+ * (`Uint8Array | ArrayBuffer | Readable | ReadableStream`).
918
1041
  *
919
1042
  * @example
920
1043
  * ```ts
921
- * // Node.js with file path
922
- * const reader = Workbook.createStreamReader("large-file.xlsx");
923
- *
924
- * // Browser or Node.js with stream
1044
+ * // Browser or Node.js with stream / buffer
925
1045
  * const reader = Workbook.createStreamReader(readableStream);
926
1046
  *
927
1047
  * for await (const event of reader) {
@@ -941,25 +1061,59 @@ class Workbook {
941
1061
  // Worksheet Management
942
1062
  // ===========================================================================
943
1063
  get nextId() {
944
- // Find the next unique spot to add worksheet
1064
+ // Worksheets and chartsheets share a single `sheetId` namespace in
1065
+ // `workbook.xml`'s `<sheets>` element (OOXML requires each
1066
+ // `sheetId` to be globally unique across both families). Allocating
1067
+ // from `_worksheets` alone used to hand out an id already claimed
1068
+ // by a chartsheet whenever the author interleaved their calls —
1069
+ // e.g. `addWorksheet(×16)` → ids 1-16; `addChartsheet(×2)` → ids
1070
+ // 17-18 (via `_nextSheetId()`); then `addWorksheet("X")` walked
1071
+ // `_worksheets` slots 1..16, found them full, and returned
1072
+ // `_worksheets.length = 17`, colliding with the first chartsheet.
1073
+ // Excel rejects the resulting workbook as corrupt. Collect
1074
+ // chartsheet ids up front so the search honours the shared pool.
1075
+ const chartsheetIds = new Set();
1076
+ for (const cs of this._chartsheets) {
1077
+ if (cs && typeof cs.id === "number" && Number.isFinite(cs.id)) {
1078
+ chartsheetIds.add(cs.id);
1079
+ }
1080
+ }
1081
+ // Prefer reusing vacated `_worksheets` slots (left as holes by
1082
+ // `removeWorksheetEx`) so ids stay stable across delete+add cycles.
945
1083
  for (let i = 1; i < this._worksheets.length; i++) {
946
- if (!this._worksheets[i]) {
1084
+ if (!this._worksheets[i] && !chartsheetIds.has(i)) {
947
1085
  return i;
948
1086
  }
949
1087
  }
950
- return this._worksheets.length || 1;
1088
+ // No reusable hole — hand out the next id beyond the current
1089
+ // tail, skipping any slots already taken by chartsheets.
1090
+ let candidate = this._worksheets.length || 1;
1091
+ while (chartsheetIds.has(candidate)) {
1092
+ candidate++;
1093
+ }
1094
+ return candidate;
951
1095
  }
952
1096
  /**
953
1097
  * Add a new worksheet and return a reference to it
954
1098
  */
955
1099
  addWorksheet(name, options) {
956
1100
  const id = this.nextId;
957
- const lastOrderNo = this._worksheets.reduce((acc, ws) => ((ws && ws.orderNo) > acc ? ws.orderNo : acc), 0);
1101
+ // Allocate `orderNo` from the unified worksheet+chartsheet counter.
1102
+ // Looking only at `_worksheets` here (the previous implementation)
1103
+ // silently collides when a chartsheet has been added in between:
1104
+ // e.g. `addWorksheet("A")` → orderNo 0; `addChartsheet(…)` → 1
1105
+ // (via `_nextSheetOrderNo()`); `addWorksheet("B")` → 1 again
1106
+ // (because `max(worksheets.orderNo) + 1 = 0 + 1 = 1`), so A and
1107
+ // B share an ordinal with the chartsheet. The writer's stable
1108
+ // sort then interleaves them non-deterministically, scrambling
1109
+ // the user's tab order (`[A, CS, B]` could come out as
1110
+ // `[A, B, CS]` or `[A, CS, B]` across runs).
1111
+ const orderNo = this._nextSheetOrderNo();
958
1112
  const worksheetOptions = {
959
1113
  ...options,
960
1114
  id,
961
1115
  name,
962
- orderNo: lastOrderNo + 1,
1116
+ orderNo,
963
1117
  workbook: this
964
1118
  };
965
1119
  const worksheet = new Worksheet(worksheetOptions);
@@ -967,6 +1121,15 @@ class Workbook {
967
1121
  return worksheet;
968
1122
  }
969
1123
  removeWorksheetEx(worksheet) {
1124
+ // Release any workbook-wide table names this sheet held so the names can
1125
+ // be reused by future tables on other sheets without spurious "name
1126
+ // already exists" errors.
1127
+ const tables = worksheet.tables;
1128
+ if (tables) {
1129
+ for (const tableName of Object.keys(tables)) {
1130
+ this._tableNames.delete(tableName.toLowerCase());
1131
+ }
1132
+ }
970
1133
  this._worksheets[worksheet.id] = undefined;
971
1134
  }
972
1135
  removeWorksheet(id) {
@@ -1000,6 +1163,269 @@ class Workbook {
1000
1163
  .sort((a, b) => a.orderNo - b.orderNo)
1001
1164
  .filter(Boolean);
1002
1165
  }
1166
+ /**
1167
+ * Add a chartsheet containing a single chart and return the created chartsheet.
1168
+ */
1169
+ addChartsheet(name, options) {
1170
+ const sheetName = this._validateChartsheetName(name ?? `Chart${this._chartsheets.length + 1}`);
1171
+ const sheetNo = this._nextChartsheetNo();
1172
+ const id = this._nextSheetId();
1173
+ // Assign a unified `orderNo` across worksheets and chartsheets so
1174
+ // the writer can preserve the author's interleaved tab layout.
1175
+ // Without this, workbook-xform `prepare()` sorted by `sheetNo`
1176
+ // (file-path number, independent per family) and reordered
1177
+ // `[ws1, cs1, ws2]` into `[ws1, ws2, cs1]`.
1178
+ const orderNo = this._nextSheetOrderNo();
1179
+ const chartsheet = {
1180
+ sheetNo,
1181
+ id,
1182
+ name: sheetName,
1183
+ orderNo,
1184
+ state: options.state ?? "visible",
1185
+ tabSelected: options.tabSelected,
1186
+ zoomScale: options.zoomScale,
1187
+ workbookViewId: options.workbookViewId,
1188
+ zoomToFit: options.zoomToFit,
1189
+ pageMargins: options.pageMargins,
1190
+ pageSetup: options.pageSetup,
1191
+ drawing: { rId: "rId1" }
1192
+ };
1193
+ if (isChartExOptions(options.chart)) {
1194
+ const chartSupport = getChartSupport();
1195
+ const chartExNumber = this.nextChartExNumber();
1196
+ const model = chartSupport.buildChartExModel(options.chart);
1197
+ try {
1198
+ chartSupport.fillChartExCaches(model, this);
1199
+ }
1200
+ catch {
1201
+ // Cache population is best-effort; never let it break chart creation.
1202
+ }
1203
+ this.addChartExStructuredEntry({ chartExNumber, model });
1204
+ chartsheet.chartExNumber = chartExNumber;
1205
+ }
1206
+ else {
1207
+ const chartSupport = getChartSupport();
1208
+ const chartNumber = this.nextChartNumber();
1209
+ const chartModel = isComboChartOptions(options.chart)
1210
+ ? chartSupport.buildComboChartModel(options.chart)
1211
+ : chartSupport.buildChartModel(options.chart);
1212
+ try {
1213
+ chartSupport.fillChartCaches(chartModel, this);
1214
+ }
1215
+ catch {
1216
+ // Cache population is best-effort; never let it break chart creation.
1217
+ }
1218
+ const entry = { chartNumber, model: chartModel };
1219
+ // Resolve programmatic `series.spPr.fill.blip._pendingImage`
1220
+ // payloads into workbook media entries and chart rels. The
1221
+ // worksheet-embedded `addChart` path does this immediately
1222
+ // after `fillChartCaches`; chartsheets ran the same builder
1223
+ // output but skipped the image-resolution step entirely, so a
1224
+ // picture-fill series authored via `addChartsheet` was
1225
+ // registered with its `_pendingImage` stuck on the model and
1226
+ // never reached `media/imageN.{ext}` — Excel rendered the
1227
+ // series as a transparent fill. Safe to call before
1228
+ // `addChartEntry` so the stored entry carries its resolved
1229
+ // `entry.rels` from the start.
1230
+ try {
1231
+ chartSupport.resolvePendingChartImages(entry, this, chartNumber);
1232
+ }
1233
+ catch {
1234
+ // Image resolution is best-effort; a broken image payload
1235
+ // should never take down chart creation — the series keeps
1236
+ // its `pictureOptions`, just without the blipFill.
1237
+ }
1238
+ this.addChartEntry(entry);
1239
+ this._applyChartsheetSidecars(chartNumber, options.chart);
1240
+ chartsheet.chartNumber = chartNumber;
1241
+ }
1242
+ this._chartsheets.push(chartsheet);
1243
+ return new Chartsheet(chartsheet, this);
1244
+ }
1245
+ /**
1246
+ * Add a chartsheet containing a classic pivot chart linked to an existing pivot table.
1247
+ */
1248
+ addPivotChartsheet(name, pivotTable, options) {
1249
+ return this.addChartsheet(name, {
1250
+ ...options,
1251
+ chart: withPivotChartSource(pivotTable, options.chart)
1252
+ });
1253
+ }
1254
+ /** Return chartsheets in workbook order. */
1255
+ get chartsheets() {
1256
+ return this._chartsheets.map(model => new Chartsheet(model, this));
1257
+ }
1258
+ getChartsheet(nameOrIndex) {
1259
+ const model = this._getChartsheetModel(nameOrIndex);
1260
+ return model ? new Chartsheet(model, this) : undefined;
1261
+ }
1262
+ removeChartsheet(nameOrIndex) {
1263
+ const index = typeof nameOrIndex === "number"
1264
+ ? nameOrIndex
1265
+ : this._chartsheets.findIndex(sheet => sheet.name.toLowerCase() === nameOrIndex.toLowerCase());
1266
+ if (index < 0 || index >= this._chartsheets.length) {
1267
+ return false;
1268
+ }
1269
+ const [removed] = this._chartsheets.splice(index, 1);
1270
+ if (removed.chartNumber) {
1271
+ this.removeChartEntry?.(removed.chartNumber);
1272
+ }
1273
+ if (removed.chartExNumber) {
1274
+ this.removeChartExStructuredEntry?.(removed.chartExNumber);
1275
+ }
1276
+ return true;
1277
+ }
1278
+ _getChartsheetModel(nameOrIndex) {
1279
+ return typeof nameOrIndex === "number"
1280
+ ? this._chartsheets[nameOrIndex]
1281
+ : this._chartsheets.find(sheet => sheet.name.toLowerCase() === nameOrIndex.toLowerCase());
1282
+ }
1283
+ renameChartsheet(nameOrIndex, name) {
1284
+ const model = this._getChartsheetModel(nameOrIndex);
1285
+ if (!model) {
1286
+ return false;
1287
+ }
1288
+ const currentName = model.name;
1289
+ if (currentName === name) {
1290
+ return true;
1291
+ }
1292
+ model.name = "__excelts_pending_chartsheet_rename__";
1293
+ try {
1294
+ model.name = this._validateChartsheetName(name);
1295
+ return true;
1296
+ }
1297
+ catch (error) {
1298
+ model.name = currentName;
1299
+ throw error;
1300
+ }
1301
+ }
1302
+ copyChartsheet(nameOrIndex, name) {
1303
+ const source = this._getChartsheetModel(nameOrIndex);
1304
+ if (!source) {
1305
+ return undefined;
1306
+ }
1307
+ const cloneName = this._validateChartsheetName(name ?? `${source.name} Copy`);
1308
+ const clone = {
1309
+ ...deepClone(source),
1310
+ id: this._nextSheetId(),
1311
+ sheetNo: this._nextChartsheetNo(),
1312
+ // New tab position — the clone goes to the tail of the tab
1313
+ // bar, matching Excel's "Duplicate" behaviour. Drop the
1314
+ // deep-cloned `orderNo` from the source.
1315
+ orderNo: this._nextSheetOrderNo(),
1316
+ name: cloneName,
1317
+ drawingName: undefined,
1318
+ relationships: source.relationships ? deepClone(source.relationships) : undefined
1319
+ };
1320
+ if (source.chartNumber) {
1321
+ const entry = this.getChartEntry(source.chartNumber);
1322
+ if (entry) {
1323
+ const chartNumber = this.nextChartNumber();
1324
+ // Clone the entry with ALL metadata: rawData, modelSnapshot,
1325
+ // dirty, preferRawPatch, requireRawPatch, rels (per-entry),
1326
+ // userShapesXml. A freshly-created entry carrying only `model`
1327
+ // would lose Excel-authored user-shape overlays, the raw-patch
1328
+ // fast path, and any per-entry rels that aren't in
1329
+ // `_chartRels`. Keeping them in lockstep means a clone of a
1330
+ // just-loaded chart matches the source byte-for-byte.
1331
+ this.addChartEntry(cloneChartEntry(entry, chartNumber));
1332
+ this.copyChartSidecars(source.chartNumber, chartNumber);
1333
+ clone.chartNumber = chartNumber;
1334
+ clone.chartExNumber = undefined;
1335
+ }
1336
+ }
1337
+ else if (source.chartExNumber) {
1338
+ const entry = this.getChartExStructuredEntry(source.chartExNumber);
1339
+ const chartExNumber = this.nextChartExNumber();
1340
+ if (entry) {
1341
+ // Same rationale as the classic branch — carry dirty /
1342
+ // preferRawPatch / requireRawPatch / rawData / modelSnapshot
1343
+ // across the clone so the raw-patch path keeps working on
1344
+ // the duplicate.
1345
+ this.addChartExStructuredEntry(cloneChartExEntry(entry, chartExNumber));
1346
+ }
1347
+ else if (this._chartExEntries[source.chartExNumber]) {
1348
+ this._chartExEntries[chartExNumber] = this._chartExEntries[source.chartExNumber].slice();
1349
+ }
1350
+ // Copy the chartEx sidecars (authored rels) so the cloned
1351
+ // chartsheet's XML references stay valid. Previously a chartEx
1352
+ // with `cx14:` / media rels on the source lost every relationship
1353
+ // on the clone.
1354
+ this.copyChartExSidecars(source.chartExNumber, chartExNumber);
1355
+ clone.chartExNumber = chartExNumber;
1356
+ clone.chartNumber = undefined;
1357
+ }
1358
+ this._chartsheets.push(clone);
1359
+ return new Chartsheet(clone, this);
1360
+ }
1361
+ replaceChartsheetChart(nameOrIndex, chart) {
1362
+ const wrapper = this.getChartsheet(nameOrIndex);
1363
+ if (!wrapper) {
1364
+ return false;
1365
+ }
1366
+ const model = wrapper.model;
1367
+ const chartSupport = getChartSupport();
1368
+ // Build the replacement first so a malformed options object throws
1369
+ // *before* we remove the existing chart entry. Without this, a
1370
+ // failed `buildChartExModel` / `buildChartModel` would leave the
1371
+ // chartsheet empty (old chart nuked, new chart never registered).
1372
+ let newChartExModel;
1373
+ let newChartModel;
1374
+ if (isChartExOptions(chart)) {
1375
+ newChartExModel = chartSupport.buildChartExModel(chart);
1376
+ }
1377
+ else if (isComboChartOptions(chart)) {
1378
+ newChartModel = chartSupport.buildComboChartModel(chart);
1379
+ }
1380
+ else {
1381
+ newChartModel = chartSupport.buildChartModel(chart);
1382
+ }
1383
+ // Remove existing entries only after the new model builds cleanly.
1384
+ if (model.chartNumber) {
1385
+ this.removeChartEntry?.(model.chartNumber);
1386
+ model.chartNumber = undefined;
1387
+ }
1388
+ if (model.chartExNumber) {
1389
+ this.removeChartExStructuredEntry?.(model.chartExNumber);
1390
+ model.chartExNumber = undefined;
1391
+ }
1392
+ if (newChartExModel) {
1393
+ const chartExNumber = this.nextChartExNumber();
1394
+ try {
1395
+ chartSupport.fillChartExCaches(newChartExModel, this);
1396
+ }
1397
+ catch {
1398
+ // Cache population is best-effort; never let it break chart replacement.
1399
+ }
1400
+ this.addChartExStructuredEntry({ chartExNumber, model: newChartExModel });
1401
+ model.chartExNumber = chartExNumber;
1402
+ }
1403
+ else if (newChartModel) {
1404
+ const chartNumber = this.nextChartNumber();
1405
+ try {
1406
+ chartSupport.fillChartCaches(newChartModel, this);
1407
+ }
1408
+ catch {
1409
+ // Cache population is best-effort; never let it break chart replacement.
1410
+ }
1411
+ const entry = { chartNumber, model: newChartModel };
1412
+ // Resolve programmatic `series.spPr.fill.blip._pendingImage`
1413
+ // payloads — matches the classic `addChart` and `addChartsheet`
1414
+ // paths. Previously replacement via `replaceChartsheetChart`
1415
+ // silently dropped picture-fill payloads on the floor.
1416
+ try {
1417
+ chartSupport.resolvePendingChartImages(entry, this, chartNumber);
1418
+ }
1419
+ catch {
1420
+ // Image resolution is best-effort; a broken image payload
1421
+ // should never take down chart replacement.
1422
+ }
1423
+ this.addChartEntry(entry);
1424
+ this._applyChartsheetSidecars(chartNumber, chart);
1425
+ model.chartNumber = chartNumber;
1426
+ }
1427
+ return true;
1428
+ }
1003
1429
  /**
1004
1430
  * Iterate over all sheets.
1005
1431
  *
@@ -1016,6 +1442,47 @@ class Workbook {
1016
1442
  get definedNames() {
1017
1443
  return this._definedNames;
1018
1444
  }
1445
+ /**
1446
+ * Workbook-level directory of people referenced by threaded comments.
1447
+ * Mutating the returned array adds/removes entries in the persistent
1448
+ * state; writers emit `xl/persons/person.xml` only when this list is
1449
+ * non-empty.
1450
+ *
1451
+ * Most callers don't need to touch this directly — creating a
1452
+ * {@link ThreadedComment} through `cell.note` handles registration
1453
+ * automatically.
1454
+ */
1455
+ get persons() {
1456
+ return this._persons;
1457
+ }
1458
+ /**
1459
+ * Register a person in the workbook persons list and return its id.
1460
+ *
1461
+ * When an entry with the same {@link displayName} + {@link userId}
1462
+ * already exists, its existing id is returned so duplicate
1463
+ * commenters collapse onto a single entry. New entries receive a
1464
+ * synthesised `{GUID}` id.
1465
+ *
1466
+ * @param displayName — shown in the comment bubble author line
1467
+ * @param userId — optional identity-provider user id (email / SID)
1468
+ * @param providerId — optional provider identifier ("AD", …)
1469
+ */
1470
+ registerPerson(displayName, userId, providerId) {
1471
+ const existing = this._persons.find(p => p.displayName === displayName && p.userId === userId);
1472
+ if (existing) {
1473
+ return existing.id;
1474
+ }
1475
+ const id = `{${synthGuid()}}`;
1476
+ const entry = { id, displayName };
1477
+ if (userId !== undefined) {
1478
+ entry.userId = userId;
1479
+ }
1480
+ if (providerId !== undefined) {
1481
+ entry.providerId = providerId;
1482
+ }
1483
+ this._persons.push(entry);
1484
+ return id;
1485
+ }
1019
1486
  // ===========================================================================
1020
1487
  // Formula Calculation
1021
1488
  // ===========================================================================
@@ -1131,6 +1598,371 @@ class Workbook {
1131
1598
  return this.media[Number(id)];
1132
1599
  }
1133
1600
  // ===========================================================================
1601
+ // Charts
1602
+ // ===========================================================================
1603
+ /**
1604
+ * Return the next available 1-based chart number.
1605
+ */
1606
+ nextChartNumber() {
1607
+ const existing = Object.keys(this._chartEntries).map(Number);
1608
+ return existing.length > 0 ? Math.max(...existing) + 1 : 1;
1609
+ }
1610
+ /**
1611
+ * Store a chart entry in the workbook (keyed by chartNumber).
1612
+ */
1613
+ addChartEntry(entry) {
1614
+ this._chartEntries[entry.chartNumber] = entry;
1615
+ }
1616
+ setChartStyle(chartNumber, data) {
1617
+ this._chartStyles[chartNumber] = data;
1618
+ }
1619
+ setChartColors(chartNumber, data) {
1620
+ this._chartColors[chartNumber] = data;
1621
+ }
1622
+ copyChartSidecars(sourceChartNumber, targetChartNumber, targetWorkbook = this) {
1623
+ const style = this._chartStyles[sourceChartNumber];
1624
+ if (style) {
1625
+ targetWorkbook.setChartStyle(targetChartNumber, style.slice());
1626
+ }
1627
+ const colors = this._chartColors[sourceChartNumber];
1628
+ if (colors) {
1629
+ targetWorkbook.setChartColors(targetChartNumber, colors.slice());
1630
+ }
1631
+ // Copy the full chart rels bag (`_chartRels`), not just the
1632
+ // style/colors pair. A classic chart can carry rels to embedded
1633
+ // images (pictureFill), external data links, and `<c:userShapes>`
1634
+ // drawing parts — without copying those the clone ends up with
1635
+ // dangling rIds. Deep-copy each rel so a later mutation on the
1636
+ // source doesn't leak into the clone.
1637
+ //
1638
+ // Rewrite style/colors Targets to the destination chart number —
1639
+ // verbatim copy would leave the rel pointing at the source's
1640
+ // `style{src}.xml`, while the writer emits `style{dst}.xml` and
1641
+ // produces a chart whose .rels references a non-existent file.
1642
+ //
1643
+ // For image rels on a cross-workbook copy (`targetWorkbook !==
1644
+ // this`), re-register each referenced image in the destination
1645
+ // workbook and rewrite the Target to point at the new media
1646
+ // file. Without this, a pictureFill that round-tripped through
1647
+ // `importSheet` pointed at the source workbook's media array —
1648
+ // which the destination package doesn't ship, so Excel shows a
1649
+ // broken image icon.
1650
+ const srcRels = this._chartRels[sourceChartNumber];
1651
+ if (Array.isArray(srcRels) && srcRels.length > 0) {
1652
+ const crossWorkbook = targetWorkbook !== this;
1653
+ targetWorkbook._chartRels[targetChartNumber] = srcRels.map(rel => {
1654
+ if (typeof rel !== "object" || rel === null) {
1655
+ return rel;
1656
+ }
1657
+ const cloned = { ...rel };
1658
+ const target = typeof cloned.Target === "string" ? cloned.Target : undefined;
1659
+ if (target) {
1660
+ if (/^style\d+\.xml$/.test(target)) {
1661
+ cloned.Target = `style${targetChartNumber}.xml`;
1662
+ }
1663
+ else if (/^colors\d+\.xml$/.test(target)) {
1664
+ cloned.Target = `colors${targetChartNumber}.xml`;
1665
+ }
1666
+ else if (crossWorkbook && cloned.Type === RelType.Image) {
1667
+ const rewritten = this._rewriteCrossWorkbookImageTarget(target, targetWorkbook);
1668
+ if (rewritten !== undefined) {
1669
+ cloned.Target = rewritten;
1670
+ }
1671
+ }
1672
+ }
1673
+ return cloned;
1674
+ });
1675
+ }
1676
+ }
1677
+ /**
1678
+ * Copy the media referenced by `target` (e.g. `../media/image3.png`)
1679
+ * from this workbook's media collection into `targetWorkbook`, then
1680
+ * return the rewritten Target pointing at the destination workbook's
1681
+ * copy. Returns `undefined` when the source media can't be
1682
+ * resolved — callers leave the original target in place and let
1683
+ * the writer emit a broken rel (same degradation as before the
1684
+ * cross-workbook rewrite landed).
1685
+ *
1686
+ * The on-disk naming convention is determined by the destination
1687
+ * workbook's `addImage`, so we take the `id` the new image gets and
1688
+ * compute `../media/image{id+1}.{ext}` (the same formula used in
1689
+ * `chart-images.ts:resolvePendingChartImages`). Centralising the
1690
+ * mapping here keeps the cross-workbook copy robust against future
1691
+ * media-naming changes on either workbook.
1692
+ */
1693
+ _rewriteCrossWorkbookImageTarget(target, targetWorkbook) {
1694
+ const match = /\/media\/image(\d+)\.([a-zA-Z0-9]+)$/.exec(target);
1695
+ if (!match) {
1696
+ return undefined;
1697
+ }
1698
+ const sourceMediaIndex = parseInt(match[1], 10) - 1;
1699
+ if (!Number.isFinite(sourceMediaIndex) || sourceMediaIndex < 0) {
1700
+ return undefined;
1701
+ }
1702
+ const medium = this.getImage?.(sourceMediaIndex);
1703
+ if (!medium) {
1704
+ return undefined;
1705
+ }
1706
+ const ext = medium.extension;
1707
+ if (ext !== "png" && ext !== "jpeg" && ext !== "gif") {
1708
+ return undefined;
1709
+ }
1710
+ const payload = {
1711
+ extension: ext
1712
+ };
1713
+ // `instanceof Uint8Array` is realm-sensitive: buffers that crossed
1714
+ // a Worker / iframe / `structuredClone` boundary carry a different
1715
+ // `Uint8Array` prototype and fail the operator even though they
1716
+ // are byte-granular typed arrays. Duck-type via `ArrayBuffer.isView`
1717
+ // + `BYTES_PER_ELEMENT === 1` so cross-workbook copies from a
1718
+ // worker-loaded Workbook preserve the image bytes; otherwise the
1719
+ // copy path silently falls through to `return undefined`, dropping
1720
+ // every image from the chart. Matches `chart-images.ts`'s handling
1721
+ // of the same realm-crossing issue.
1722
+ const buf = medium.buffer;
1723
+ if (buf &&
1724
+ ArrayBuffer.isView(buf) &&
1725
+ buf.BYTES_PER_ELEMENT === 1) {
1726
+ payload.buffer =
1727
+ buf instanceof Uint8Array
1728
+ ? buf.slice()
1729
+ : new Uint8Array(buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength));
1730
+ }
1731
+ else if (typeof medium.base64 === "string") {
1732
+ payload.base64 = medium.base64;
1733
+ }
1734
+ else {
1735
+ return undefined;
1736
+ }
1737
+ const newId = targetWorkbook.addImage(payload);
1738
+ return `../media/image${newId + 1}.${ext}`;
1739
+ }
1740
+ /**
1741
+ * Copy the ChartEx-specific sidecar state from one `chartExNumber` slot
1742
+ * to another. Classic charts have `copyChartSidecars` for chart-style /
1743
+ * chart-colors; ChartEx charts carry their own `_chartExRels`
1744
+ * (relationship entries for extension packages, embedded images, etc.)
1745
+ * that the classic helper does not touch. Without this, cloning a
1746
+ * ChartEx via {@link Chart.copyTo} / {@link Chartsheet.clone} silently
1747
+ * dropped every relationship the source had — authored `cx14:`
1748
+ * extensions, embedded custom geometry, or linked media ended up
1749
+ * pointing at an undefined rel id on the clone.
1750
+ */
1751
+ copyChartExSidecars(sourceChartExNumber, targetChartExNumber, targetWorkbook = this) {
1752
+ const rels = this._chartExRels[sourceChartExNumber];
1753
+ if (rels && rels.length > 0) {
1754
+ // Rewrite `Target` for rels that point at numbered sidecars
1755
+ // (styleEx / colorsEx / userShapes). Those files get different
1756
+ // on-disk numbers on the clone — copying the rel verbatim
1757
+ // leaves it pointing at the source's sidecar, so saving the
1758
+ // package produces a chartEx whose .rels references
1759
+ // `styleEx{src}.xml` while the writer emits `styleEx{dst}.xml`.
1760
+ // Strip the number from the source Target and re-stamp it with
1761
+ // the target's number.
1762
+ //
1763
+ // For image rels on a cross-workbook copy (`targetWorkbook !==
1764
+ // this`), re-register each referenced image in the destination
1765
+ // workbook and rewrite the Target — same logic as classic chart
1766
+ // sidecars. Without this, a ChartEx with embedded images (e.g.
1767
+ // pictureFill or custom geometry) would reference media that
1768
+ // doesn't exist in the destination package.
1769
+ const crossWorkbook = targetWorkbook !== this;
1770
+ targetWorkbook._chartExRels[targetChartExNumber] = rels.map(r => {
1771
+ if (typeof r !== "object" || r === null) {
1772
+ return r;
1773
+ }
1774
+ const cloned = { ...r };
1775
+ const target = typeof cloned.Target === "string" ? cloned.Target : undefined;
1776
+ if (target) {
1777
+ const styleExMatch = /^styleEx\d+\.xml$/.exec(target);
1778
+ if (styleExMatch) {
1779
+ cloned.Target = `styleEx${targetChartExNumber}.xml`;
1780
+ }
1781
+ else if (/^colorsEx\d+\.xml$/.exec(target)) {
1782
+ cloned.Target = `colorsEx${targetChartExNumber}.xml`;
1783
+ }
1784
+ else if (crossWorkbook && cloned.Type === RelType.Image) {
1785
+ const rewritten = this._rewriteCrossWorkbookImageTarget(target, targetWorkbook);
1786
+ if (rewritten !== undefined) {
1787
+ cloned.Target = rewritten;
1788
+ }
1789
+ }
1790
+ }
1791
+ return cloned;
1792
+ });
1793
+ }
1794
+ // ChartEx style / colors sidecars (matching `_chartStyles` /
1795
+ // `_chartColors` for classic charts). Previously only `_chartExRels`
1796
+ // was copied — a cloned chartEx lost its authored chartExStyle and
1797
+ // chartExColors bytes, so the saved package re-derived them from
1798
+ // defaults and the clone looked different from the source.
1799
+ const exStyle = this._chartExStyles[sourceChartExNumber];
1800
+ if (exStyle) {
1801
+ targetWorkbook._chartExStyles[targetChartExNumber] = exStyle.slice();
1802
+ }
1803
+ const exColors = this._chartExColors[sourceChartExNumber];
1804
+ if (exColors) {
1805
+ targetWorkbook._chartExColors[targetChartExNumber] = exColors.slice();
1806
+ }
1807
+ }
1808
+ _applyChartsheetSidecars(chartNumber, chartOptions) {
1809
+ if (isChartExOptions(chartOptions)) {
1810
+ return;
1811
+ }
1812
+ if (!chartOptions.chartStyle && !chartOptions.chartColors) {
1813
+ return;
1814
+ }
1815
+ const chartSupport = getChartSupport();
1816
+ if (chartOptions.chartStyle) {
1817
+ this.setChartStyle(chartNumber, new TextEncoder().encode(chartSupport.buildChartStyle(chartOptions.chartStyle)));
1818
+ }
1819
+ if (chartOptions.chartColors) {
1820
+ this.setChartColors(chartNumber, new TextEncoder().encode(chartSupport.buildChartColors(chartOptions.chartColors)));
1821
+ }
1822
+ }
1823
+ /**
1824
+ * Retrieve a chart entry by its 1-based chart number.
1825
+ */
1826
+ getChartEntry(chartNumber) {
1827
+ return this._chartEntries[chartNumber];
1828
+ }
1829
+ /**
1830
+ * Remove a chart entry from the workbook.
1831
+ * Safe to call even if the chart number doesn't exist.
1832
+ */
1833
+ removeChartEntry(chartNumber) {
1834
+ delete this._chartEntries[chartNumber];
1835
+ delete this._chartRels[chartNumber];
1836
+ delete this._chartStyles[chartNumber];
1837
+ delete this._chartColors[chartNumber];
1838
+ }
1839
+ // ===========================================================================
1840
+ // ChartEx (Office 2016+) structured entries
1841
+ // ===========================================================================
1842
+ /** Return the next available 1-based chartEx number. */
1843
+ nextChartExNumber() {
1844
+ const rawKeys = Object.keys(this._chartExEntries ?? {}).map(Number);
1845
+ const structKeys = Object.keys(this._chartExStructuredEntries ?? {}).map(Number);
1846
+ const combined = [...rawKeys, ...structKeys];
1847
+ return combined.length > 0 ? Math.max(...combined) + 1 : 1;
1848
+ }
1849
+ /**
1850
+ * Store a structured chartEx entry.
1851
+ * Loaded entries may also keep raw bytes for clean passthrough.
1852
+ */
1853
+ addChartExStructuredEntry(entry) {
1854
+ if (!this._chartExStructuredEntries) {
1855
+ this._chartExStructuredEntries = {};
1856
+ }
1857
+ this._chartExStructuredEntries[entry.chartExNumber] = entry;
1858
+ }
1859
+ /** Get a structured chartEx entry by number. */
1860
+ getChartExStructuredEntry(chartExNumber) {
1861
+ return this._chartExStructuredEntries?.[chartExNumber];
1862
+ }
1863
+ _nextChartsheetNo() {
1864
+ const existing = this._chartsheets.map(cs => cs.sheetNo).filter(Number.isFinite);
1865
+ return existing.length > 0 ? Math.max(...existing) + 1 : 1;
1866
+ }
1867
+ /**
1868
+ * Next value for the unified `orderNo` (tab-bar position) counter
1869
+ * shared between worksheets and chartsheets. Used by the writer's
1870
+ * `prepare()` to emit `<sheets>` in the author's insertion order,
1871
+ * preserving interleaved `[ws, cs, ws]` layouts that the old
1872
+ * sheetNo-based sort used to reshuffle.
1873
+ */
1874
+ _nextSheetOrderNo() {
1875
+ let max = -1;
1876
+ for (const ws of this._worksheets) {
1877
+ if (ws && typeof ws.orderNo === "number" && ws.orderNo > max) {
1878
+ max = ws.orderNo;
1879
+ }
1880
+ }
1881
+ for (const cs of this._chartsheets) {
1882
+ if (typeof cs.orderNo === "number" && cs.orderNo > max) {
1883
+ max = cs.orderNo;
1884
+ }
1885
+ }
1886
+ return max + 1;
1887
+ }
1888
+ _nextSheetId() {
1889
+ const worksheetIds = this.worksheets.map(ws => ws.id);
1890
+ const chartsheetIds = this._chartsheets.map(cs => cs.id).filter(Number.isFinite);
1891
+ const ids = [...worksheetIds, ...chartsheetIds];
1892
+ return ids.length > 0 ? Math.max(...ids) + 1 : 1;
1893
+ }
1894
+ /**
1895
+ * Validate a sheet name (worksheet OR chartsheet) against Excel's
1896
+ * single unified namespace. Returns the (possibly truncated) name on
1897
+ * success; throws {@link WorksheetNameError} on invalid input.
1898
+ *
1899
+ * Unifying the check at the workbook level fixes three related
1900
+ * regressions that used to exist in the per-family validators:
1901
+ * 1. `Worksheet.name` setter only cross-checked against other
1902
+ * worksheets, so `addChartsheet("S")` followed by
1903
+ * `addWorksheet("S")` silently produced a duplicate tab name.
1904
+ * 2. The chartsheet regex was missing the backslash, so
1905
+ * `addChartsheet("A\\B")` sneaked through — Excel rejects it.
1906
+ * 3. `Chartsheet.name = …` bypassed validation entirely, letting
1907
+ * users mutate the model into a corrupt state.
1908
+ *
1909
+ * @param name - Proposed sheet name. `undefined` / empty / over-31
1910
+ * chars / containing any of `* ? : \\ / [ ]` / leading or trailing
1911
+ * single-quote is rejected. Names ≤31 chars are passed through;
1912
+ * longer ones are truncated (non-production builds emit a warning).
1913
+ * @param existing - The sheet being renamed (if any) — it is
1914
+ * excluded from the duplicate check so `sheet.name = sheet.name`
1915
+ * is a no-op rather than a self-collision.
1916
+ */
1917
+ validateSheetName(name, existing) {
1918
+ if (typeof name !== "string") {
1919
+ throw new WorksheetNameError("The name has to be a string.");
1920
+ }
1921
+ if (name === "") {
1922
+ throw new WorksheetNameError("The name can't be empty.");
1923
+ }
1924
+ if (name === "History") {
1925
+ throw new WorksheetNameError('The name "History" is protected. Please use a different name.');
1926
+ }
1927
+ // Illegal characters per Excel's own naming rules: asterisk (*),
1928
+ // question mark (?), colon (:), forward slash (/), backslash (\),
1929
+ // left bracket ([), right bracket (]). The chartsheet regex used
1930
+ // to omit `\\`; unified here so both families enforce the same
1931
+ // char set.
1932
+ if (/[*?:/\\[\]]/.test(name)) {
1933
+ throw new WorksheetNameError(`Sheet name ${name} cannot include any of the following characters: * ? : \\ / [ ]`);
1934
+ }
1935
+ if (/(^')|('$)/.test(name)) {
1936
+ throw new WorksheetNameError(`The first or last character of sheet name cannot be a single quotation mark: ${name}`);
1937
+ }
1938
+ if (name.length > 31) {
1939
+ if (process.env.NODE_ENV !== "production") {
1940
+ console.warn(`Sheet name ${name} exceeds 31 chars. This will be truncated`);
1941
+ }
1942
+ name = name.substring(0, 31);
1943
+ }
1944
+ const nameLower = name.toLowerCase();
1945
+ const duplicateWorksheet = this.worksheets.find(ws => ws && ws !== existing && ws.name.toLowerCase() === nameLower);
1946
+ const duplicateChartsheet = this._chartsheets.find(cs => cs && cs !== existing && cs.name.toLowerCase() === nameLower);
1947
+ if (duplicateWorksheet || duplicateChartsheet) {
1948
+ throw new WorksheetNameError(`Sheet name already exists: ${name}`);
1949
+ }
1950
+ return name;
1951
+ }
1952
+ _validateChartsheetName(name) {
1953
+ return this.validateSheetName(name);
1954
+ }
1955
+ /** Remove a structured chartEx entry. */
1956
+ removeChartExStructuredEntry(chartExNumber) {
1957
+ if (this._chartExStructuredEntries) {
1958
+ delete this._chartExStructuredEntries[chartExNumber];
1959
+ }
1960
+ delete this._chartExEntries[chartExNumber];
1961
+ delete this._chartExRels[chartExNumber];
1962
+ delete this._chartExStyles[chartExNumber];
1963
+ delete this._chartExColors[chartExNumber];
1964
+ }
1965
+ // ===========================================================================
1134
1966
  // External Workbook Links
1135
1967
  // ===========================================================================
1136
1968
  /**
@@ -1284,6 +2116,12 @@ class Workbook {
1284
2116
  worksheets: this.worksheets.map(worksheet => worksheet.model),
1285
2117
  sheets: this.worksheets.map(ws => ws.model).filter(Boolean),
1286
2118
  definedNames: this._definedNames.model,
2119
+ // Live `DefinedNames` instance — required by the write-time
2120
+ // chartEx transform `prepareChartExSidecars`, which registers
2121
+ // hidden `_xlchart.vN.M` names on the fly and needs an object
2122
+ // that can mutate in place. The serialised `definedNames`
2123
+ // array above is re-materialised after the transform runs.
2124
+ definedNamesInstance: this._definedNames,
1287
2125
  views: this.views,
1288
2126
  company: this.company,
1289
2127
  manager: this.manager,
@@ -1299,10 +2137,23 @@ class Workbook {
1299
2137
  media: this.media,
1300
2138
  pivotTables: this.pivotTables,
1301
2139
  calcProperties: this.calcProperties,
1302
- passthrough: this._passthrough,
1303
- rawDrawings: this._rawDrawings,
1304
2140
  defaultFont: this._defaultFont,
1305
- externalLinks: this.externalLinks
2141
+ externalLinks: this.externalLinks,
2142
+ chartEntries: this._chartEntries,
2143
+ chartRels: this._chartRels,
2144
+ chartStyles: this._chartStyles,
2145
+ chartColors: this._chartColors,
2146
+ chartExStyles: this._chartExStyles,
2147
+ chartExColors: this._chartExColors,
2148
+ chartExEntries: this._chartExEntries,
2149
+ chartExRels: this._chartExRels,
2150
+ chartExStructuredEntries: this._chartExStructuredEntries,
2151
+ chartsheets: this._chartsheets,
2152
+ persons: this._persons,
2153
+ slicerParts: this._slicerParts,
2154
+ slicerCacheParts: this._slicerCacheParts,
2155
+ timelineParts: this._timelineParts,
2156
+ timelineCacheParts: this._timelineCacheParts
1306
2157
  };
1307
2158
  }
1308
2159
  set model(value) {
@@ -1345,12 +2196,44 @@ class Workbook {
1345
2196
  // Handle pivot tables - either newly created or loaded from file
1346
2197
  // Loaded pivot tables come from loadedPivotTables after reconciliation
1347
2198
  this.pivotTables = value.pivotTables || value.loadedPivotTables || [];
1348
- // Preserve passthrough files (charts, etc.) for round-trip preservation
1349
- this._passthrough = value.passthrough || {};
1350
- // Preserve raw drawing data for drawings with chart references
1351
- this._rawDrawings = value.rawDrawings || {};
1352
2199
  // Preserve default font for round-trip fidelity
1353
2200
  this._defaultFont = value.defaultFont;
2201
+ // Restore chart entries
2202
+ this._chartEntries = value.chartEntries || {};
2203
+ this._chartRels = value.chartRels || {};
2204
+ this._chartStyles = value.chartStyles || {};
2205
+ this._chartColors = value.chartColors || {};
2206
+ this._chartExStyles = value.chartExStyles || {};
2207
+ this._chartExColors = value.chartExColors || {};
2208
+ this._chartExEntries = value.chartExEntries || {};
2209
+ this._chartExRels = value.chartExRels || {};
2210
+ this._chartExStructuredEntries = value.chartExStructuredEntries || {};
2211
+ // Restore chartsheets. Populate each chartsheet's `orderNo` from
2212
+ // the position in `value.sheets` (workbook.xml tab order) so the
2213
+ // writer's `prepare()` can sort interleaved worksheets +
2214
+ // chartsheets back into the author's layout. Matches the
2215
+ // equivalent loop above for worksheets.
2216
+ this._chartsheets = value.chartsheets || [];
2217
+ if (value.sheets) {
2218
+ for (const cs of this._chartsheets) {
2219
+ const idx = value.sheets.findIndex((s) => s.id === cs.id);
2220
+ if (idx !== -1) {
2221
+ cs.orderNo = idx;
2222
+ }
2223
+ }
2224
+ }
2225
+ // Restore threaded-comment person directory. Always assign a new
2226
+ // list so callers editing the previous value don't mutate the
2227
+ // newly-loaded workbook by accident.
2228
+ this._persons = value.persons ? [...value.persons] : [];
2229
+ // Restore raw-passthrough slicer/timeline parts so dashboards
2230
+ // survive round-trip. The maps are stored by reference — loaders
2231
+ // and writers treat them as read-only; mutating them between
2232
+ // load and save is not supported.
2233
+ this._slicerParts = value.slicerParts ?? {};
2234
+ this._slicerCacheParts = value.slicerCacheParts ?? {};
2235
+ this._timelineParts = value.timelineParts ?? {};
2236
+ this._timelineCacheParts = value.timelineCacheParts ?? {};
1354
2237
  // Preserve external workbook references (empty array if none)
1355
2238
  this.externalLinks = value.externalLinks ? [...value.externalLinks] : [];
1356
2239
  // Reset the writer-scoped auto-discovery cache — loading a fresh
@@ -1375,4 +2258,56 @@ Workbook.Writer = WorkbookWriter;
1375
2258
  * // Browser: new Workbook.Reader(readableStream)
1376
2259
  */
1377
2260
  Workbook.Reader = WorkbookReader;
2261
+ function deepClone(value) {
2262
+ if (typeof structuredClone === "function") {
2263
+ return structuredClone(value);
2264
+ }
2265
+ return JSON.parse(JSON.stringify(value));
2266
+ }
2267
+ /**
2268
+ * Deep-copy a {@link ChartEntry}, preserving every field that affects
2269
+ * write-time behaviour — rawData (for the raw-patch fast path),
2270
+ * modelSnapshot (change detection), dirty / preferRawPatch /
2271
+ * requireRawPatch (writer hints), style / colors (ancillary parts),
2272
+ * rels (per-entry relationship bag), and userShapesXml (annotation
2273
+ * overlay). The caller supplies the new `chartNumber`; everything
2274
+ * else is a structural clone so later mutations on one entry don't
2275
+ * leak into the other.
2276
+ *
2277
+ * `rawData` and `userShapesXml` are `Uint8Array`s — `.slice()` is
2278
+ * used instead of `structuredClone` to keep the fast path cheap.
2279
+ */
2280
+ function cloneChartEntry(entry, chartNumber) {
2281
+ return {
2282
+ chartNumber,
2283
+ model: deepClone(entry.model),
2284
+ ...(entry.rawData ? { rawData: entry.rawData.slice() } : {}),
2285
+ ...(entry.modelSnapshot !== undefined ? { modelSnapshot: entry.modelSnapshot } : {}),
2286
+ ...(entry.dirty !== undefined ? { dirty: entry.dirty } : {}),
2287
+ ...(entry.preferRawPatch !== undefined ? { preferRawPatch: entry.preferRawPatch } : {}),
2288
+ ...(entry.requireRawPatch !== undefined ? { requireRawPatch: entry.requireRawPatch } : {}),
2289
+ ...(entry.style ? { style: deepClone(entry.style) } : {}),
2290
+ ...(entry.colors ? { colors: deepClone(entry.colors) } : {}),
2291
+ ...(entry.rels ? { rels: entry.rels.map(r => ({ ...r })) } : {}),
2292
+ ...(entry.userShapesXml ? { userShapesXml: entry.userShapesXml.slice() } : {})
2293
+ };
2294
+ }
2295
+ /**
2296
+ * Deep-copy a {@link ChartExEntry}, preserving the same write-time
2297
+ * fields as {@link cloneChartEntry} but for the ChartEx family
2298
+ * (structured model + rawData + dirty / preferRawPatch /
2299
+ * requireRawPatch + rels).
2300
+ */
2301
+ function cloneChartExEntry(entry, chartExNumber) {
2302
+ return {
2303
+ chartExNumber,
2304
+ model: deepClone(entry.model),
2305
+ ...(entry.rawData ? { rawData: entry.rawData.slice() } : {}),
2306
+ ...(entry.modelSnapshot !== undefined ? { modelSnapshot: entry.modelSnapshot } : {}),
2307
+ ...(entry.dirty !== undefined ? { dirty: entry.dirty } : {}),
2308
+ ...(entry.preferRawPatch !== undefined ? { preferRawPatch: entry.preferRawPatch } : {}),
2309
+ ...(entry.requireRawPatch !== undefined ? { requireRawPatch: entry.requireRawPatch } : {}),
2310
+ ...(entry.rels ? { rels: entry.rels.map(r => ({ ...r })) } : {})
2311
+ };
2312
+ }
1378
2313
  export { Workbook };