@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
@@ -0,0 +1,1178 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fillChartCaches = fillChartCaches;
4
+ exports.fillChartExCaches = fillChartExCaches;
5
+ exports.fillNumRef = fillNumRef;
6
+ exports.fillStrRef = fillStrRef;
7
+ exports.fillMultiLvlStrRef = fillMultiLvlStrRef;
8
+ const col_cache_1 = require("../utils/col-cache.js");
9
+ const utils_base_1 = require("../../../utils/utils.base.js");
10
+ /**
11
+ * Populate all number/string caches in a ChartModel from the given workbook.
12
+ * Mutates the model in place. Safe to call multiple times (idempotent).
13
+ *
14
+ * @param model - The chart model to enrich
15
+ * @param workbook - The workbook used to resolve sheet/cell references
16
+ * @param contextWorksheet - Optional worksheet providing the default scope for
17
+ * defined-name resolution. When a defined name has a sheet-scoped entry
18
+ * matching this worksheet's workbook index (`localSheetId`), that entry
19
+ * wins over the workbook-scoped entry. Supplying this argument is required
20
+ * to correctly resolve sheet-scoped names; omitting it falls back to
21
+ * workbook-scoped names only.
22
+ */
23
+ function fillChartCaches(model, workbook, contextWorksheet) {
24
+ const plotArea = model.chart?.plotArea;
25
+ if (!plotArea) {
26
+ return;
27
+ }
28
+ const date1904 = workbook.properties?.date1904;
29
+ const ctx = buildResolverContext(workbook, contextWorksheet);
30
+ // Fill the classic chart title's `<c:strRef>` cache when the title
31
+ // was authored as `{ formula: "..." }`. The writer already emits
32
+ // `<c:strCache>` for any `strRef.cache.points` it finds; without
33
+ // this fill a formula-bound title round-trips as
34
+ // `<c:strRef><c:f>…</c:f></c:strRef>` with no cache, so readers that
35
+ // don't recalculate formulas (preview tooling, headless converters)
36
+ // see a blank title frame. ChartEx has the same machinery in
37
+ // `fillChartExCaches`; keeping them symmetric.
38
+ fillClassicTitleCache(model.chart?.title, ctx);
39
+ // Axis titles follow the same shape — `ChartTitle` is the same type
40
+ // on `axis.title` and carries the same `strRef.cache`. Round-trip
41
+ // parity requires filling them too.
42
+ for (const axis of plotArea.axes ?? []) {
43
+ fillClassicTitleCache(axis.title, ctx);
44
+ }
45
+ for (const group of plotArea.chartTypes) {
46
+ fillGroupCaches(group, ctx, date1904);
47
+ }
48
+ }
49
+ /**
50
+ * Populate a classic `ChartTitle.strRef.cache` from its formula when
51
+ * the cache is empty. Shared between chart title and axis titles.
52
+ * No-ops for titles that were authored as rich text / rawTx / a
53
+ * literal string — only formula-bound titles carry a strRef.
54
+ */
55
+ function fillClassicTitleCache(title, ctx) {
56
+ const strRef = title?.strRef;
57
+ if (!strRef?.formula) {
58
+ return;
59
+ }
60
+ if (strRef.cache?.points && strRef.cache.points.length > 0) {
61
+ return;
62
+ }
63
+ const resolved = resolveReference(strRef.formula, ctx);
64
+ if (!resolved) {
65
+ return;
66
+ }
67
+ const points = [];
68
+ let idx = 0;
69
+ for (const cell of resolved.cells) {
70
+ const s = toString(cell.value);
71
+ if (s !== undefined) {
72
+ points.push({ index: idx, value: s });
73
+ }
74
+ idx += 1;
75
+ }
76
+ // Gate on "any resolved cell", not "any non-empty stringified
77
+ // value". Sibling fillers (`fillNumRefInternal` / `fillStrRefInternal`)
78
+ // emit a sparse cache `{ pointCount: N, points: [] }` when the
79
+ // resolved range had no stringifiable cells — that's the whole
80
+ // reason the fill exists: readers that don't recalculate formulas
81
+ // still need the `pointCount` envelope to size sparse arrays
82
+ // correctly. The title filler was previously inconsistent: it
83
+ // tracked `idx` through empty cells but then dropped the cache
84
+ // entirely unless at least one cell yielded a non-empty string.
85
+ // That meant a formula-bound title whose source cell is currently
86
+ // blank round-tripped as `<c:strRef><c:f>…</c:f></c:strRef>` with
87
+ // no cache — exactly the failure mode the fill was written to
88
+ // prevent.
89
+ if (resolved.cells.length > 0) {
90
+ strRef.cache = { pointCount: idx, points };
91
+ }
92
+ }
93
+ function fillChartExCaches(model, workbook, contextWorksheet) {
94
+ // Defensive guard — parseChartEx emits `chartData.data = []` even for
95
+ // malformed documents, but downstream callers (and unit fixtures) can
96
+ // construct partial models. Match the classic `fillChartCaches` which
97
+ // no-ops when `plotArea` is missing.
98
+ const data = model.chartSpace?.chartData?.data;
99
+ const ctx = buildResolverContext(workbook, contextWorksheet);
100
+ // Fill the ChartEx title's `<cx:txData>` cache. The builder accepts a
101
+ // `{ formula: string }` title and parks `strRef: { formula, cache:
102
+ // { points: [] } }` on the model; the writer emits `<cx:v>` from the
103
+ // first cached point. Without this fill, a formula-linked title
104
+ // round-trips as `<cx:txData><cx:f>…</cx:f></cx:txData>` (no cached
105
+ // value), so readers without a formula engine see an empty title
106
+ // until Excel recalculates.
107
+ const title = model.chartSpace?.chart?.title;
108
+ const titleStrRef = title?.strRef;
109
+ if (titleStrRef?.formula && (titleStrRef.cache?.points?.length ?? 0) === 0) {
110
+ const resolved = resolveReference(titleStrRef.formula, ctx);
111
+ if (resolved) {
112
+ const first = resolved.cells.find(cell => toString(cell.value) !== undefined);
113
+ if (first) {
114
+ const value = toString(first.value);
115
+ if (value !== undefined) {
116
+ titleStrRef.cache = { points: [{ index: 0, value }] };
117
+ }
118
+ }
119
+ }
120
+ }
121
+ if (!data || data.length === 0) {
122
+ return;
123
+ }
124
+ for (const entry of data) {
125
+ if (entry.strDim?.formula && !hasChartExStringPoints(entry.strDim)) {
126
+ const resolved = resolveReference(entry.strDim.formula, ctx);
127
+ if (resolved && resolved.cells.length > 0) {
128
+ const points = [];
129
+ let idx = 0;
130
+ for (const cell of resolved.cells) {
131
+ const value = toString(cell.value);
132
+ if (value !== undefined && value !== "") {
133
+ points.push({ index: idx, value });
134
+ }
135
+ idx++;
136
+ }
137
+ // Write levels whenever we had resolvable cells: even all-empty
138
+ // resolves should emit `[{ ptCount: N, points: [] }]` so Excel
139
+ // sizes the sparse array correctly. This matches the classic
140
+ // `fillNumRefInternal` / `fillStrRefInternal` behaviour which
141
+ // the null-value-cell test explicitly depends on.
142
+ entry.strDim.levels = [{ ptCount: idx, points }];
143
+ }
144
+ }
145
+ if (entry.numDim?.formula && !hasChartExNumberPoints(entry.numDim)) {
146
+ const resolved = resolveReference(entry.numDim.formula, ctx);
147
+ if (resolved && resolved.cells.length > 0) {
148
+ const points = [];
149
+ let idx = 0;
150
+ for (const cell of resolved.cells) {
151
+ const value = toNumber(cell.value, workbook.properties?.date1904);
152
+ if (value !== undefined) {
153
+ points.push({ index: idx, value });
154
+ }
155
+ idx++;
156
+ }
157
+ // Preserve any `formatCode` already attached to the original
158
+ // numeric level so a round-tripped `<cx:lvl formatCode="…">`
159
+ // keeps its numFmt — the old path blindly replaced `levels`
160
+ // with a freshly-built object and silently dropped the
161
+ // attribute on every save.
162
+ const existingLvl = entry.numDim.levels?.[0];
163
+ entry.numDim.levels = [
164
+ {
165
+ ptCount: idx,
166
+ points,
167
+ ...(existingLvl?.formatCode ? { formatCode: existingLvl.formatCode } : {})
168
+ }
169
+ ];
170
+ }
171
+ }
172
+ }
173
+ }
174
+ function fillGroupCaches(group, ctx, date1904) {
175
+ // Group-level `dataLabels.dataLabelsRange` (Excel 2013+ "Value From
176
+ // Cells" at the chart-type group level). The builder places
177
+ // `dataLabelsRange` on the group when the caller passes `dataLabels:
178
+ // { valueFromCells }` at the group level — we previously only filled
179
+ // the per-series variant, so a group-wide value-from-cells range
180
+ // silently stayed empty until a formula engine recalculated it.
181
+ const groupDataLabels = group
182
+ .dataLabels;
183
+ if (groupDataLabels?.dataLabelsRange?.formula) {
184
+ fillDataLabelsRange(groupDataLabels.dataLabelsRange, ctx);
185
+ }
186
+ const series = group.series;
187
+ if (!series) {
188
+ return;
189
+ }
190
+ for (const s of series) {
191
+ fillSeriesCaches(s, ctx, date1904);
192
+ }
193
+ }
194
+ function hasChartExStringPoints(dim) {
195
+ // Hierarchical charts (treemap / sunburst) point their `<cx:strDim>`
196
+ // at a contiguous multi-column range (`$A$2:$C$N`). A single flat
197
+ // `<cx:lvl>` cache across 3 columns × N rows (3×N points) does not
198
+ // survive Excel's hierarchical-data pivot: the chart draws nothing
199
+ // because the loader cannot re-derive the row × column layout from
200
+ // a flat point list. Excel's own writer omits the cache entirely for
201
+ // treemap + sunburst and re-reads the cells on open. Mirror that:
202
+ // when a strDim is tagged `_skipCache` (set by the builder for
203
+ // hierarchical chartEx series), treat it as "already populated"
204
+ // so `fillChartExCaches` leaves it alone and the renderer emits
205
+ // just the `<cx:f>` reference.
206
+ if (dim._skipCache) {
207
+ return true;
208
+ }
209
+ return dim.levels?.some(level => level.points.length > 0) ?? false;
210
+ }
211
+ function hasChartExNumberPoints(dim) {
212
+ if (dim._skipCache) {
213
+ return true;
214
+ }
215
+ return dim.levels?.some(level => level.points.length > 0) ?? false;
216
+ }
217
+ function fillSeriesCaches(series, ctx, date1904) {
218
+ // Series name (tx): may be strRef
219
+ const tx = series.tx;
220
+ if (tx?.strRef) {
221
+ fillStrRefInternal(tx.strRef, ctx);
222
+ }
223
+ // Category / X axis data source
224
+ const cat = series.cat;
225
+ if (cat) {
226
+ fillAxisDataSource(cat, ctx, date1904);
227
+ }
228
+ const xVal = series.xVal;
229
+ if (xVal) {
230
+ fillAxisDataSource(xVal, ctx, date1904);
231
+ }
232
+ // Numeric values — val, yVal, bubbleSize
233
+ const val = series.val;
234
+ if (val?.numRef) {
235
+ fillNumRefInternal(val.numRef, ctx, date1904);
236
+ }
237
+ const yVal = series.yVal;
238
+ if (yVal?.numRef) {
239
+ fillNumRefInternal(yVal.numRef, ctx, date1904);
240
+ }
241
+ const bubbleSize = series.bubbleSize;
242
+ if (bubbleSize?.numRef) {
243
+ fillNumRefInternal(bubbleSize.numRef, ctx, date1904);
244
+ }
245
+ // Error bars may have custom plus/minus references
246
+ const errorBars = series.errorBars;
247
+ if (errorBars) {
248
+ const list = Array.isArray(errorBars) ? errorBars : [errorBars];
249
+ for (const eb of list) {
250
+ if (eb.plus?.numRef) {
251
+ fillNumRefInternal(eb.plus.numRef, ctx, date1904);
252
+ }
253
+ if (eb.minus?.numRef) {
254
+ fillNumRefInternal(eb.minus.numRef, ctx, date1904);
255
+ }
256
+ }
257
+ }
258
+ // "Value From Cells" data labels (Excel 2013+) — populate the
259
+ // `c15:datalabelsRange` cache so readers without a formula engine see
260
+ // the right labels and so the writer can emit `<c15:dlblRangeCache>`.
261
+ const dataLabels = series.dataLabels;
262
+ if (dataLabels?.dataLabelsRange?.formula) {
263
+ fillDataLabelsRange(dataLabels.dataLabelsRange, ctx);
264
+ }
265
+ }
266
+ function fillDataLabelsRange(range, ctx) {
267
+ if (range.cache?.points && range.cache.points.length > 0) {
268
+ return;
269
+ }
270
+ const resolved = resolveReference(range.formula, ctx);
271
+ if (!resolved) {
272
+ return;
273
+ }
274
+ const points = [];
275
+ let idx = 0;
276
+ for (const cell of resolved.cells) {
277
+ const s = toString(cell.value);
278
+ if (s !== undefined && s !== "") {
279
+ points.push({ index: idx, value: s });
280
+ }
281
+ idx++;
282
+ }
283
+ // Match the sibling fillers (`fillNumRefInternal`, `fillStrRefInternal`,
284
+ // `fillChartExCaches`) — gate on "resolved any cells" rather than
285
+ // "collected any non-empty values". An all-blank range still needs a
286
+ // sparse `{ pointCount: N, points: [] }` cache so Excel sizes the
287
+ // label array correctly; dropping the cache entirely under-counted
288
+ // the label index and desynchronised labels from their data points.
289
+ if (idx > 0) {
290
+ range.cache = { pointCount: idx, points };
291
+ }
292
+ }
293
+ function fillAxisDataSource(src, ctx, date1904) {
294
+ if (src.strRef) {
295
+ fillStrRefInternal(src.strRef, ctx);
296
+ }
297
+ if (src.numRef) {
298
+ fillNumRefInternal(src.numRef, ctx, date1904);
299
+ }
300
+ if (src.multiLvlStrRef) {
301
+ fillMultiLvlStrRefInternal(src.multiLvlStrRef, ctx);
302
+ }
303
+ }
304
+ /**
305
+ * Populate a NumberReference cache from the workbook.
306
+ * Only fills if `cache.points` is currently empty.
307
+ *
308
+ * @param contextWorksheet - Optional worksheet whose sheet-scoped defined
309
+ * names take precedence over workbook-scoped ones.
310
+ */
311
+ function fillNumRef(ref, workbook, date1904, contextWorksheet) {
312
+ fillNumRefInternal(ref, buildResolverContext(workbook, contextWorksheet), date1904);
313
+ }
314
+ function fillNumRefInternal(ref, ctx, date1904) {
315
+ if (!ref.formula) {
316
+ return;
317
+ }
318
+ if (ref.cache?.points && ref.cache.points.length > 0) {
319
+ return; // already populated
320
+ }
321
+ const resolved = resolveReference(ref.formula, ctx);
322
+ if (!resolved) {
323
+ return;
324
+ }
325
+ const points = [];
326
+ let idx = 0;
327
+ for (const cell of resolved.cells) {
328
+ const n = toNumber(cell.value, date1904);
329
+ if (n !== undefined) {
330
+ points.push({ index: idx, value: n });
331
+ }
332
+ idx++;
333
+ }
334
+ // `idx === 0` means we resolved no cells at all — treat the same as
335
+ // an un-resolvable reference and keep any pre-existing cache intact.
336
+ // When we did resolve cells but all of them were empty/undefined,
337
+ // still emit the cache with `points: []` and the correct
338
+ // `pointCount`: Excel needs the pointCount to size sparse arrays
339
+ // correctly even when every slot is blank.
340
+ if (idx === 0) {
341
+ return;
342
+ }
343
+ if (!ref.cache) {
344
+ ref.cache = { points: [] };
345
+ }
346
+ ref.cache.points = points;
347
+ ref.cache.pointCount = idx; // total slots (including empty)
348
+ }
349
+ /**
350
+ * Populate a StringReference cache from the workbook.
351
+ * Only fills if `cache.points` is currently empty.
352
+ *
353
+ * @param contextWorksheet - Optional worksheet whose sheet-scoped defined
354
+ * names take precedence over workbook-scoped ones.
355
+ */
356
+ function fillStrRef(ref, workbook, contextWorksheet) {
357
+ fillStrRefInternal(ref, buildResolverContext(workbook, contextWorksheet));
358
+ }
359
+ function fillStrRefInternal(ref, ctx) {
360
+ if (!ref.formula) {
361
+ return;
362
+ }
363
+ if (ref.cache?.points && ref.cache.points.length > 0) {
364
+ return;
365
+ }
366
+ const resolved = resolveReference(ref.formula, ctx);
367
+ if (!resolved) {
368
+ return;
369
+ }
370
+ const points = [];
371
+ let idx = 0;
372
+ for (const cell of resolved.cells) {
373
+ const s = toString(cell.value);
374
+ if (s !== undefined && s !== "") {
375
+ points.push({ index: idx, value: s });
376
+ }
377
+ idx++;
378
+ }
379
+ // See `fillNumRefInternal`: no cells resolved → preserve any
380
+ // pre-existing cache; otherwise write the computed cache (possibly
381
+ // with `points: []` and `pointCount` reflecting blank slots).
382
+ if (idx === 0) {
383
+ return;
384
+ }
385
+ if (!ref.cache) {
386
+ ref.cache = { points: [] };
387
+ }
388
+ ref.cache.points = points;
389
+ ref.cache.pointCount = idx;
390
+ }
391
+ function fillMultiLvlStrRef(ref, workbook, contextWorksheet) {
392
+ fillMultiLvlStrRefInternal(ref, buildResolverContext(workbook, contextWorksheet));
393
+ }
394
+ function fillMultiLvlStrRefInternal(ref, ctx) {
395
+ if (!ref.formula) {
396
+ return;
397
+ }
398
+ if (ref.cache?.levels?.some(level => level.points.length > 0)) {
399
+ return;
400
+ }
401
+ const resolved = resolveReferenceMatrix(ref.formula, ctx);
402
+ if (!resolved) {
403
+ return;
404
+ }
405
+ const levels = [];
406
+ for (let col = 0; col < resolved.columnCount; col++) {
407
+ const points = [];
408
+ for (let row = 0; row < resolved.rowCount; row++) {
409
+ const value = toString(resolved.values[row]?.[col]);
410
+ if (value !== undefined && value !== "") {
411
+ points.push({ index: row, value });
412
+ }
413
+ }
414
+ levels.push({ pointCount: resolved.rowCount, points });
415
+ }
416
+ ref.cache = { pointCount: resolved.rowCount, levels };
417
+ }
418
+ /**
419
+ * Maximum defined-name expansion depth. Picked to match LibreOffice and
420
+ * comfortably exceed anything a legitimate workbook produces (Excel's UI
421
+ * stops the user well before this).
422
+ */
423
+ const MAX_DEFINED_NAME_DEPTH = 128;
424
+ function buildResolverContext(workbook, contextWorksheet) {
425
+ let localSheetId;
426
+ if (contextWorksheet) {
427
+ // OOXML `definedName/@localSheetId` is a 0-based index into the
428
+ // workbook-level `<sheets>` element, which INTERLEAVES worksheets
429
+ // and chartsheets. Previously this helper used
430
+ // `workbook.worksheets.indexOf(contextWorksheet)` — the compressed
431
+ // worksheets-only position — so an interleaved
432
+ // `[WS1, CS, WS2]` workbook resolved WS2's `localSheetId` to `1`,
433
+ // colliding with the chartsheet's real tab position and making
434
+ // every sheet-scoped defined name on WS2 miss.
435
+ //
436
+ // `worksheet.orderNo` is set at BOTH save time (addWorksheet /
437
+ // addChartsheet use a unified counter) and load time
438
+ // (workbook-xform assigns `sheetPosition` across the mixed
439
+ // `<sheets>` list), so it is the authoritative mixed-tab index.
440
+ // Fall back to the compressed lookup for test worksheets that
441
+ // bypass the allocator and never receive an `orderNo`.
442
+ if (typeof contextWorksheet.orderNo === "number") {
443
+ localSheetId = contextWorksheet.orderNo;
444
+ }
445
+ else {
446
+ const idx = workbook.worksheets.indexOf(contextWorksheet);
447
+ if (idx >= 0) {
448
+ localSheetId = idx;
449
+ }
450
+ }
451
+ }
452
+ return {
453
+ workbook,
454
+ contextWorksheet,
455
+ localSheetId,
456
+ visitedDefinedNames: new Set(),
457
+ definedNameDepth: 0
458
+ };
459
+ }
460
+ /**
461
+ * Resolve a chart formula like `Sheet1!$A$1:$A$4` or `'My Sheet'!$B$2:$B$5`
462
+ * into a sequence of cell values in row-major order.
463
+ *
464
+ * Multi-range unions (`Sheet1!A1:A3,Sheet1!A5:A7`) are flattened preserving order.
465
+ * Returns undefined if the reference cannot be resolved.
466
+ *
467
+ * Resolution strategy (first match wins):
468
+ * 1. Structured table reference (`Table1[Column]`)
469
+ * 2. Defined name (workbook- or sheet-scoped), recursively expanded
470
+ * 3. Direct A1 cell/range references (possibly comma-separated union)
471
+ */
472
+ function resolveReference(formula, ctx) {
473
+ const structured = resolveStructuredReference(formula, ctx.workbook);
474
+ if (structured) {
475
+ return structured;
476
+ }
477
+ const named = resolveDefinedNameReference(formula, ctx);
478
+ if (named) {
479
+ return named;
480
+ }
481
+ // Multi-range support: Excel uses commas or semicolons between sub-refs.
482
+ // Inside quoted sheet names, commas don't count — do a safe split.
483
+ const parts = splitFormulaRanges(formula);
484
+ let worksheet;
485
+ const cells = [];
486
+ for (const part of parts) {
487
+ const trimmed = part.trim();
488
+ if (!trimmed) {
489
+ continue;
490
+ }
491
+ let decoded;
492
+ try {
493
+ decoded = col_cache_1.colCache.decodeEx(trimmed);
494
+ }
495
+ catch {
496
+ return undefined;
497
+ }
498
+ // `decodeEx` can also return `{ sheetName, error: "#REF!" }` for
499
+ // malformed references — that shape has neither `row`/`col` nor
500
+ // `top`/`left`, so without an explicit check we would return
501
+ // `{ worksheet, cells: [] }` and silently mask an invalid formula as a
502
+ // successful empty resolution.
503
+ if ("error" in decoded) {
504
+ return undefined;
505
+ }
506
+ const sheetName = decoded.sheetName;
507
+ if (!sheetName) {
508
+ return undefined;
509
+ }
510
+ const ws = ctx.workbook.getWorksheet(sheetName);
511
+ if (!ws) {
512
+ return undefined;
513
+ }
514
+ // Track first resolved worksheet for the return value
515
+ if (!worksheet) {
516
+ worksheet = ws;
517
+ }
518
+ if ("top" in decoded && "left" in decoded) {
519
+ // Range: iterate in row-major order matching Excel's cache layout.
520
+ // For vertical ranges (single column), this is top→bottom.
521
+ // For horizontal ranges (single row), this is left→right.
522
+ // For 2D ranges, row-major (left→right, top→bottom).
523
+ const top = decoded.top;
524
+ const left = decoded.left;
525
+ const bottom = decoded.bottom;
526
+ const right = decoded.right;
527
+ for (let r = top; r <= bottom; r++) {
528
+ for (let c = left; c <= right; c++) {
529
+ cells.push({ value: extractCellValue(ws, r, c) });
530
+ }
531
+ }
532
+ }
533
+ else if ("row" in decoded && "col" in decoded) {
534
+ const r = decoded.row;
535
+ const c = decoded.col;
536
+ cells.push({ value: extractCellValue(ws, r, c) });
537
+ }
538
+ }
539
+ if (!worksheet) {
540
+ return undefined;
541
+ }
542
+ return { worksheet, cells };
543
+ }
544
+ /**
545
+ * Regex matching a bare Excel defined name (no sheet prefix, no `$`, no `:`,
546
+ * no `!`, no `,`). Excel's grammar requires the first character to be a
547
+ * letter, underscore, or backslash, and disallows names that look like cell
548
+ * references; we don't try to validate name legality here — the final
549
+ * authority is whether `workbook.definedNames` has a matching entry.
550
+ *
551
+ * Allowing Unicode letters makes this work for CJK defined names, which are
552
+ * common in Chinese Excel files.
553
+ */
554
+ const BARE_DEFINED_NAME_RE = /^[A-Za-z_\\\u00A0-\uFFFF][\w.?\\\u00A0-\uFFFF]*$/;
555
+ /**
556
+ * Attempt to resolve {@link formula} as a defined name and expand to the
557
+ * underlying A1 ranges. Supports both bare names (`MyRange`) and qualified
558
+ * names (`Sheet1!MyRange`, `'My Sheet'!MyRange`).
559
+ *
560
+ * Name-scope resolution matches Excel semantics:
561
+ * - Qualified `Sheet!Name` → sheet-scoped entry on `Sheet`, else
562
+ * workbook-scoped
563
+ * - Bare `Name` → sheet-scoped entry on the context worksheet (when
564
+ * provided), else workbook-scoped
565
+ *
566
+ * The result of expanding the name is resolved recursively, so chart
567
+ * formulas that target a named formula (e.g. `OFFSET(...)` stored as a
568
+ * defined name) do not silently fall through — when the name resolves to
569
+ * another reference-like expression, we follow it.
570
+ */
571
+ function resolveDefinedNameReference(formula, ctx) {
572
+ const resolution = findDefinedName(formula, ctx);
573
+ if (!resolution) {
574
+ return undefined;
575
+ }
576
+ // Cycle guard: A -> B -> A must terminate.
577
+ const visitKey = storageKey(resolution.name, resolution.localSheetId);
578
+ if (ctx.visitedDefinedNames.has(visitKey)) {
579
+ return undefined;
580
+ }
581
+ // Depth guard: terminate pathological non-cyclic chains
582
+ // (A → B → C → D → … with hundreds of links) before the JS call
583
+ // stack blows up.
584
+ if (ctx.definedNameDepth >= MAX_DEFINED_NAME_DEPTH) {
585
+ return undefined;
586
+ }
587
+ ctx.visitedDefinedNames.add(visitKey);
588
+ ctx.definedNameDepth += 1;
589
+ try {
590
+ // A defined name may expand to multiple ranges (comma-separated union).
591
+ // We recursively resolve each part through the full reference pipeline
592
+ // so that nested names, structured refs, and A1 refs all work.
593
+ const aggregated = [];
594
+ let firstWorksheet;
595
+ for (const rangeStr of resolution.ranges) {
596
+ if (!rangeStr) {
597
+ continue;
598
+ }
599
+ const inner = resolveReference(rangeStr, ctx);
600
+ if (!inner) {
601
+ continue;
602
+ }
603
+ if (!firstWorksheet) {
604
+ firstWorksheet = inner.worksheet;
605
+ }
606
+ for (const cell of inner.cells) {
607
+ aggregated.push(cell);
608
+ }
609
+ }
610
+ if (!firstWorksheet) {
611
+ return undefined;
612
+ }
613
+ return { worksheet: firstWorksheet, cells: aggregated };
614
+ }
615
+ finally {
616
+ ctx.visitedDefinedNames.delete(visitKey);
617
+ ctx.definedNameDepth -= 1;
618
+ }
619
+ }
620
+ /**
621
+ * Look up a defined name in the workbook, honouring sheet-scoped vs
622
+ * workbook-scoped precedence. Returns `undefined` when the formula does not
623
+ * look like a defined-name reference at all, or when no entry matches.
624
+ */
625
+ function findDefinedName(formula, ctx) {
626
+ const trimmed = formula.trim();
627
+ if (!trimmed) {
628
+ return undefined;
629
+ }
630
+ // Qualified form: Sheet!Name or 'Sheet Name'!Name
631
+ const qualified = splitQualifiedName(trimmed);
632
+ if (qualified) {
633
+ // Sheet-scoped entry on the qualifying sheet wins; fall back to
634
+ // workbook-scoped if the sheet has no matching entry.
635
+ const qualifyingSheet = ctx.workbook.getWorksheet(qualified.sheetName);
636
+ if (qualifyingSheet) {
637
+ // Match the scoping key used in `buildResolverContext` — always
638
+ // prefer `orderNo` (the mixed-tab workbook position, counting
639
+ // chartsheets) over `worksheets.indexOf` (the worksheets-only
640
+ // position). When these disagree — e.g. in a workbook ordered
641
+ // `[WS1, ChartSheet, WS2]`, `WS2.orderNo === 2` but
642
+ // `worksheets.indexOf(WS2) === 1` — sheet-scoped defined name
643
+ // lookups via bare and qualified paths must agree, otherwise
644
+ // the qualified path silently falls back to the workbook-scoped
645
+ // entry (or misses entirely) while the bare path finds the
646
+ // correct sheet-scoped one.
647
+ const sheetIdx = typeof qualifyingSheet.orderNo === "number"
648
+ ? qualifyingSheet.orderNo
649
+ : ctx.workbook.worksheets.indexOf(qualifyingSheet);
650
+ if (sheetIdx >= 0) {
651
+ const scoped = getDefinedNameRanges(ctx.workbook, qualified.name, sheetIdx);
652
+ if (scoped) {
653
+ return { name: qualified.name, localSheetId: sheetIdx, ranges: scoped };
654
+ }
655
+ }
656
+ }
657
+ const global = getDefinedNameRanges(ctx.workbook, qualified.name, undefined);
658
+ if (global) {
659
+ return { name: qualified.name, ranges: global };
660
+ }
661
+ return undefined;
662
+ }
663
+ // Bare form: must pass the name shape gate to avoid calling into the
664
+ // defined-names API for every failed cell reference.
665
+ if (!BARE_DEFINED_NAME_RE.test(trimmed)) {
666
+ return undefined;
667
+ }
668
+ // Sheet-scoped on the context worksheet wins, then workbook-scoped.
669
+ if (ctx.localSheetId !== undefined) {
670
+ const scoped = getDefinedNameRanges(ctx.workbook, trimmed, ctx.localSheetId);
671
+ if (scoped) {
672
+ return { name: trimmed, localSheetId: ctx.localSheetId, ranges: scoped };
673
+ }
674
+ }
675
+ const global = getDefinedNameRanges(ctx.workbook, trimmed, undefined);
676
+ if (global) {
677
+ return { name: trimmed, ranges: global };
678
+ }
679
+ return undefined;
680
+ }
681
+ /**
682
+ * Read the ranges (or formula expression) associated with a defined name at
683
+ * a specific scope. Returns `undefined` when no entry exists at that scope.
684
+ */
685
+ function getDefinedNameRanges(workbook, name, localSheetId) {
686
+ const definedNames = workbook.definedNames;
687
+ if (!definedNames) {
688
+ return undefined;
689
+ }
690
+ const model = definedNames.getRangesScoped(name, localSheetId);
691
+ if (!model.ranges || model.ranges.length === 0) {
692
+ return undefined;
693
+ }
694
+ // Verify the entry actually exists at the requested scope — getRangesScoped
695
+ // falls back to the bare name when the scoped key is missing, and we must
696
+ // not return workbook-scoped results from a sheet-scoped lookup.
697
+ const matrixMap = definedNames.matrixMap;
698
+ const formulaMap = definedNames.formulaMap;
699
+ const sKey = localSheetId !== undefined ? `${name}\0${localSheetId}` : name;
700
+ if (!matrixMap[sKey] && formulaMap[sKey] === undefined) {
701
+ return undefined;
702
+ }
703
+ return model.ranges;
704
+ }
705
+ function storageKey(name, localSheetId) {
706
+ return localSheetId !== undefined ? `${name}\0${localSheetId}` : name;
707
+ }
708
+ /**
709
+ * Split `Sheet!Name` or `'Quoted Sheet'!Name` into its components. Returns
710
+ * `undefined` when the input is not of that shape or the right-hand side
711
+ * contains range punctuation (in which case it is a cell reference, not a
712
+ * defined-name reference).
713
+ */
714
+ function splitQualifiedName(formula) {
715
+ let i = 0;
716
+ let sheetName = "";
717
+ if (formula[0] === "'") {
718
+ // Walk a quoted sheet name, treating '' as an escaped single quote.
719
+ i = 1;
720
+ while (i < formula.length) {
721
+ if (formula[i] === "'" && formula[i + 1] === "'") {
722
+ sheetName += "'";
723
+ i += 2;
724
+ }
725
+ else if (formula[i] === "'") {
726
+ i++;
727
+ break;
728
+ }
729
+ else {
730
+ sheetName += formula[i];
731
+ i++;
732
+ }
733
+ }
734
+ }
735
+ else {
736
+ // Unquoted sheet name — ends at the first '!'.
737
+ const bang = formula.indexOf("!");
738
+ if (bang <= 0) {
739
+ return undefined;
740
+ }
741
+ sheetName = formula.slice(0, bang);
742
+ i = bang;
743
+ }
744
+ if (formula[i] !== "!") {
745
+ return undefined;
746
+ }
747
+ const name = formula.slice(i + 1);
748
+ if (!BARE_DEFINED_NAME_RE.test(name)) {
749
+ return undefined;
750
+ }
751
+ return { sheetName, name };
752
+ }
753
+ /**
754
+ * Peel off an optional `Sheet1!` or `'My Sheet'!` prefix from a formula
755
+ * without validating the shape of the remainder. Unlike
756
+ * {@link splitQualifiedName} (which additionally checks that the RHS is a
757
+ * bare defined name), this helper is safe to use on structured
758
+ * references (`Table1[Col]`), absolute ranges (`$A$1:$B$2`) and anything
759
+ * else that might follow a sheet prefix.
760
+ *
761
+ * Returns `undefined` when the input has no sheet prefix — callers should
762
+ * treat that as "use the input unchanged".
763
+ */
764
+ function splitSheetPrefix(formula) {
765
+ let i = 0;
766
+ let sheetName = "";
767
+ if (formula[0] === "'") {
768
+ i = 1;
769
+ while (i < formula.length) {
770
+ if (formula[i] === "'" && formula[i + 1] === "'") {
771
+ sheetName += "'";
772
+ i += 2;
773
+ }
774
+ else if (formula[i] === "'") {
775
+ i++;
776
+ break;
777
+ }
778
+ else {
779
+ sheetName += formula[i];
780
+ i++;
781
+ }
782
+ }
783
+ if (formula[i] !== "!") {
784
+ return undefined;
785
+ }
786
+ }
787
+ else {
788
+ const bang = formula.indexOf("!");
789
+ if (bang <= 0) {
790
+ return undefined;
791
+ }
792
+ sheetName = formula.slice(0, bang);
793
+ i = bang;
794
+ }
795
+ if (formula[i] !== "!") {
796
+ return undefined;
797
+ }
798
+ return { sheetName, remainder: formula.slice(i + 1) };
799
+ }
800
+ function resolveStructuredReference(formula, workbook) {
801
+ // Excel accepts both bare (`Table1[Col]`) and sheet-qualified
802
+ // (`Sheet1!Table1[Col]`) structured references. Strip the optional sheet
803
+ // prefix so table lookup can operate on the bare `Table1[Col]` form; we
804
+ // also use the prefix to bias the worksheet search order so a same-named
805
+ // table on the referenced sheet wins over an unrelated sheet that
806
+ // happens to carry the same name.
807
+ //
808
+ // NOTE: `splitQualifiedName` validates the RHS against
809
+ // `BARE_DEFINED_NAME_RE`, which rejects structured references because
810
+ // they contain `[`. We therefore use a dedicated sheet-prefix splitter
811
+ // that does not gate on name shape — `splitSheetPrefix` only peels off
812
+ // the quoted / unquoted sheet name, leaving the table reference
813
+ // syntactically intact.
814
+ const split = splitSheetPrefix(formula.trim());
815
+ const bareFormula = split ? split.remainder : formula.trim();
816
+ const preferredSheetName = split?.sheetName;
817
+ const parsed = parseStructuredReference(bareFormula);
818
+ if (!parsed) {
819
+ return undefined;
820
+ }
821
+ const worksheets = [...workbook.worksheets];
822
+ if (preferredSheetName) {
823
+ // Move the preferred sheet to the front of the search (case-insensitive).
824
+ const target = preferredSheetName.toLowerCase();
825
+ const idx = worksheets.findIndex(ws => ws.name.toLowerCase() === target);
826
+ if (idx > 0) {
827
+ worksheets.unshift(...worksheets.splice(idx, 1));
828
+ }
829
+ }
830
+ for (const worksheet of worksheets) {
831
+ const table = worksheet
832
+ .getTables()
833
+ .find(t => t.name === parsed.tableName || t.displayName === parsed.tableName);
834
+ if (!table) {
835
+ continue;
836
+ }
837
+ const model = table.model;
838
+ const columnIndex = model.columns.findIndex(column => column.name === parsed.columnName);
839
+ if (columnIndex < 0) {
840
+ return undefined;
841
+ }
842
+ const tableRef = col_cache_1.colCache.decode(model.tableRef ?? model.ref);
843
+ if (!("top" in tableRef)) {
844
+ return undefined;
845
+ }
846
+ const dataStartRow = tableRef.top + (model.headerRow === false ? 0 : 1);
847
+ const dataEndRow = tableRef.bottom - (model.totalsRow ? 1 : 0);
848
+ const col = tableRef.left + columnIndex;
849
+ const cells = [];
850
+ for (let row = dataStartRow; row <= dataEndRow; row++) {
851
+ cells.push({ value: extractCellValue(worksheet, row, col) });
852
+ }
853
+ return { worksheet, cells };
854
+ }
855
+ return undefined;
856
+ }
857
+ function parseStructuredReference(formula) {
858
+ const table = readStructuredTableName(formula);
859
+ if (!table || formula[table.end] !== "[" || !formula.endsWith("]")) {
860
+ return undefined;
861
+ }
862
+ const body = formula.slice(table.end + 1, -1);
863
+ if (body.length === 0) {
864
+ return undefined;
865
+ }
866
+ const columnName = extractStructuredReferenceColumn(body);
867
+ return columnName ? { tableName: table.name, columnName } : undefined;
868
+ }
869
+ function readStructuredTableName(formula) {
870
+ if (formula.startsWith("'")) {
871
+ let name = "";
872
+ for (let i = 1; i < formula.length; i++) {
873
+ if (formula[i] === "'" && formula[i + 1] === "'") {
874
+ name += "'";
875
+ i++;
876
+ }
877
+ else if (formula[i] === "'") {
878
+ return { name, end: i + 1 };
879
+ }
880
+ else {
881
+ name += formula[i];
882
+ }
883
+ }
884
+ return undefined;
885
+ }
886
+ const bracket = formula.indexOf("[");
887
+ if (bracket <= 0) {
888
+ return undefined;
889
+ }
890
+ return { name: formula.slice(0, bracket), end: bracket };
891
+ }
892
+ function extractStructuredReferenceColumn(body) {
893
+ if (body.startsWith("@")) {
894
+ const inner = body.slice(1).replace(/^\[(.*)\]$/, "$1");
895
+ const item = readStructuredReferenceItem(`${inner}]`, 0);
896
+ return item.value;
897
+ }
898
+ if (!body.startsWith("[")) {
899
+ if (body.startsWith("#")) {
900
+ return undefined;
901
+ }
902
+ const item = readStructuredReferenceItem(`${body}]`, 0);
903
+ return item.value;
904
+ }
905
+ const items = [];
906
+ let i = 0;
907
+ while (i < body.length) {
908
+ if (body[i] !== "[") {
909
+ i++;
910
+ continue;
911
+ }
912
+ const item = readStructuredReferenceItem(body, i + 1);
913
+ items.push(item.value);
914
+ i = item.end;
915
+ }
916
+ return items.filter(item => item && !item.startsWith("#")).pop();
917
+ }
918
+ function readStructuredReferenceItem(value, start) {
919
+ let i = start;
920
+ let result = "";
921
+ while (i < value.length) {
922
+ if (value[i] === "'" && i + 1 < value.length) {
923
+ result += value[i + 1];
924
+ i += 2;
925
+ }
926
+ else if (value[i] === "]") {
927
+ i++;
928
+ break;
929
+ }
930
+ else {
931
+ result += value[i];
932
+ i++;
933
+ }
934
+ }
935
+ return { value: result.trim(), end: i };
936
+ }
937
+ function resolveReferenceMatrix(formula, ctx) {
938
+ // Expand defined-name references up front so a named multi-area range can
939
+ // still drive a multi-level string cache.
940
+ const named = findDefinedName(formula, ctx);
941
+ if (named) {
942
+ const visitKey = storageKey(named.name, named.localSheetId);
943
+ if (ctx.visitedDefinedNames.has(visitKey)) {
944
+ return undefined;
945
+ }
946
+ // Same depth guard as `resolveDefinedNameReference`; matrices route
947
+ // through a separate code path so they need their own bail-out.
948
+ if (ctx.definedNameDepth >= MAX_DEFINED_NAME_DEPTH) {
949
+ return undefined;
950
+ }
951
+ ctx.visitedDefinedNames.add(visitKey);
952
+ ctx.definedNameDepth += 1;
953
+ try {
954
+ let firstWorksheet;
955
+ const mergedValues = [];
956
+ let mergedColumnCount = 0;
957
+ for (const rangeStr of named.ranges) {
958
+ const inner = resolveReferenceMatrix(rangeStr, ctx);
959
+ if (!inner) {
960
+ continue;
961
+ }
962
+ if (!firstWorksheet) {
963
+ firstWorksheet = inner.worksheet;
964
+ }
965
+ mergedValues.push(...inner.values);
966
+ mergedColumnCount = Math.max(mergedColumnCount, inner.columnCount);
967
+ }
968
+ if (!firstWorksheet) {
969
+ return undefined;
970
+ }
971
+ return {
972
+ worksheet: firstWorksheet,
973
+ values: mergedValues,
974
+ rowCount: mergedValues.length,
975
+ columnCount: mergedColumnCount
976
+ };
977
+ }
978
+ finally {
979
+ ctx.visitedDefinedNames.delete(visitKey);
980
+ ctx.definedNameDepth -= 1;
981
+ }
982
+ }
983
+ const parts = splitFormulaRanges(formula);
984
+ let worksheet;
985
+ const rows = [];
986
+ let columnCount = 0;
987
+ for (const part of parts) {
988
+ const trimmed = part.trim();
989
+ if (!trimmed) {
990
+ continue;
991
+ }
992
+ let decoded;
993
+ try {
994
+ decoded = col_cache_1.colCache.decodeEx(trimmed);
995
+ }
996
+ catch {
997
+ return undefined;
998
+ }
999
+ // See `resolveReference`: treat `{ error: ... }` results from
1000
+ // `decodeEx` as unresolved rather than as empty cell sets.
1001
+ if ("error" in decoded) {
1002
+ return undefined;
1003
+ }
1004
+ const sheetName = decoded.sheetName;
1005
+ if (!sheetName) {
1006
+ return undefined;
1007
+ }
1008
+ const ws = ctx.workbook.getWorksheet(sheetName);
1009
+ if (!ws) {
1010
+ return undefined;
1011
+ }
1012
+ if (!worksheet) {
1013
+ worksheet = ws;
1014
+ }
1015
+ if ("top" in decoded && "left" in decoded) {
1016
+ const top = decoded.top;
1017
+ const left = decoded.left;
1018
+ const bottom = decoded.bottom;
1019
+ const right = decoded.right;
1020
+ columnCount = Math.max(columnCount, right - left + 1);
1021
+ for (let r = top; r <= bottom; r++) {
1022
+ const row = [];
1023
+ for (let c = left; c <= right; c++) {
1024
+ row.push(extractCellValue(ws, r, c));
1025
+ }
1026
+ rows.push(row);
1027
+ }
1028
+ }
1029
+ else if ("row" in decoded && "col" in decoded) {
1030
+ columnCount = Math.max(columnCount, 1);
1031
+ rows.push([extractCellValue(ws, decoded.row, decoded.col)]);
1032
+ }
1033
+ }
1034
+ if (!worksheet) {
1035
+ return undefined;
1036
+ }
1037
+ return { worksheet, values: rows, rowCount: rows.length, columnCount };
1038
+ }
1039
+ /**
1040
+ * Split a chart formula that may contain multiple ranges (union) separated
1041
+ * by commas or semicolons, respecting quoted sheet names.
1042
+ */
1043
+ function splitFormulaRanges(formula) {
1044
+ const parts = [];
1045
+ let current = "";
1046
+ let inQuote = false;
1047
+ for (let i = 0; i < formula.length; i++) {
1048
+ const ch = formula[i];
1049
+ if (ch === "'") {
1050
+ // Excel escapes a single quote inside a sheet name as ''
1051
+ if (inQuote && formula[i + 1] === "'") {
1052
+ current += "''";
1053
+ i++;
1054
+ continue;
1055
+ }
1056
+ inQuote = !inQuote;
1057
+ current += ch;
1058
+ }
1059
+ else if (!inQuote && (ch === "," || ch === ";")) {
1060
+ parts.push(current);
1061
+ current = "";
1062
+ }
1063
+ else {
1064
+ current += ch;
1065
+ }
1066
+ }
1067
+ if (current) {
1068
+ parts.push(current);
1069
+ }
1070
+ return parts;
1071
+ }
1072
+ /**
1073
+ * Extract a raw value from a worksheet cell.
1074
+ * Avoids forcing creation of empty cells by using the row-level accessor.
1075
+ */
1076
+ function extractCellValue(ws, row, col) {
1077
+ // Worksheet.getCell creates sparse cell slots but does not mutate existing
1078
+ // values — safe to call.
1079
+ const cell = ws.getCell(row, col);
1080
+ const v = cell.value;
1081
+ if (v === null || v === undefined) {
1082
+ return undefined;
1083
+ }
1084
+ // Formula values are wrapped: { formula, result }
1085
+ if (typeof v === "object" && "result" in v) {
1086
+ const result = v.result;
1087
+ return result;
1088
+ }
1089
+ // Rich text
1090
+ if (typeof v === "object" && "richText" in v) {
1091
+ const rt = v.richText;
1092
+ if (rt) {
1093
+ return rt.map(r => r.text ?? "").join("");
1094
+ }
1095
+ }
1096
+ // Hyperlink / error
1097
+ if (typeof v === "object") {
1098
+ if ("error" in v) {
1099
+ return undefined;
1100
+ }
1101
+ if ("text" in v && "hyperlink" in v) {
1102
+ return v.text;
1103
+ }
1104
+ }
1105
+ return v;
1106
+ }
1107
+ function toNumber(v, date1904) {
1108
+ if (v === null || v === undefined) {
1109
+ return undefined;
1110
+ }
1111
+ if (typeof v === "number") {
1112
+ return Number.isFinite(v) ? v : undefined;
1113
+ }
1114
+ if (typeof v === "boolean") {
1115
+ return v ? 1 : 0;
1116
+ }
1117
+ if (v instanceof Date) {
1118
+ // Delegate to the canonical converter in `@utils/utils.base` so the
1119
+ // epoch / date1904 offset stays consistent with the rest of the
1120
+ // codebase (`cell-format`, formula engine, XML writer). A previous
1121
+ // local implementation used a `Date.UTC(1899, 11, 30)` epoch with
1122
+ // its own `serial >= 60 → +1` hack that was both off-by-one
1123
+ // (canonical epoch is Dec 31 1899) AND timezone-dependent (since
1124
+ // callers may pass local-time `Date`s whose UTC projection differs).
1125
+ return (0, utils_base_1.dateToExcel)(v, date1904);
1126
+ }
1127
+ if (typeof v === "string") {
1128
+ // Try to coerce numeric string
1129
+ const n = Number(v);
1130
+ if (Number.isFinite(n) && v.trim() !== "") {
1131
+ return n;
1132
+ }
1133
+ }
1134
+ return undefined;
1135
+ }
1136
+ function toString(v) {
1137
+ if (v === null || v === undefined) {
1138
+ return undefined;
1139
+ }
1140
+ if (typeof v === "string") {
1141
+ return v;
1142
+ }
1143
+ if (typeof v === "number" || typeof v === "boolean") {
1144
+ return String(v);
1145
+ }
1146
+ if (v instanceof Date) {
1147
+ // Date-cells feeding a chart's category axis (via a `strRef` — e.g.
1148
+ // `=Sheet1!$A$1:$A$10` where A1:A10 are dates) should surface as
1149
+ // human-readable labels, not ISO 8601 timestamps. `toISOString()`
1150
+ // produced output like `"2023-01-15T00:00:00.000Z"` which rendered
1151
+ // verbatim on axis labels and diverged from Excel's cache (Excel
1152
+ // stores the formatted display text per the referenced cell's
1153
+ // numFmt).
1154
+ //
1155
+ // We don't have access to the source cell's numFmt from this
1156
+ // fallback path, but a locale-neutral `YYYY-MM-DD` (or
1157
+ // `YYYY-MM-DD HH:mm:ss` when the time portion is non-zero) is a
1158
+ // reasonable approximation that renders well in every preview and
1159
+ // matches Excel's default date format more closely than ISO.
1160
+ if (Number.isNaN(v.getTime())) {
1161
+ return undefined;
1162
+ }
1163
+ const year = v.getUTCFullYear().toString().padStart(4, "0");
1164
+ const month = (v.getUTCMonth() + 1).toString().padStart(2, "0");
1165
+ const day = v.getUTCDate().toString().padStart(2, "0");
1166
+ const hour = v.getUTCHours();
1167
+ const min = v.getUTCMinutes();
1168
+ const sec = v.getUTCSeconds();
1169
+ if (hour === 0 && min === 0 && sec === 0) {
1170
+ return `${year}-${month}-${day}`;
1171
+ }
1172
+ const hh = hour.toString().padStart(2, "0");
1173
+ const mm = min.toString().padStart(2, "0");
1174
+ const ss = sec.toString().padStart(2, "0");
1175
+ return `${year}-${month}-${day} ${hh}:${mm}:${ss}`;
1176
+ }
1177
+ return undefined;
1178
+ }