@cj-tech-master/excelts 9.2.1 → 9.3.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 (383) hide show
  1. package/README.md +25 -2
  2. package/README_zh.md +29 -6
  3. package/dist/browser/index.browser.d.ts +1 -1
  4. package/dist/browser/index.browser.js +4 -0
  5. package/dist/browser/index.d.ts +1 -1
  6. package/dist/browser/index.js +4 -0
  7. package/dist/browser/modules/excel/cell.d.ts +17 -3
  8. package/dist/browser/modules/excel/cell.js +170 -22
  9. package/dist/browser/modules/excel/defined-names.d.ts +96 -1
  10. package/dist/browser/modules/excel/defined-names.js +411 -21
  11. package/dist/browser/modules/excel/image.d.ts +11 -0
  12. package/dist/browser/modules/excel/image.js +24 -1
  13. package/dist/browser/modules/excel/stream/workbook-reader.browser.d.ts +9 -3
  14. package/dist/browser/modules/excel/stream/workbook-reader.browser.js +14 -0
  15. package/dist/browser/modules/excel/stream/workbook-reader.d.ts +2 -1
  16. package/dist/browser/modules/excel/stream/workbook-writer.browser.d.ts +39 -5
  17. package/dist/browser/modules/excel/stream/workbook-writer.browser.js +48 -1
  18. package/dist/browser/modules/excel/stream/workbook-writer.d.ts +3 -2
  19. package/dist/browser/modules/excel/stream/worksheet-reader.js +17 -1
  20. package/dist/browser/modules/excel/stream/worksheet-writer.d.ts +39 -6
  21. package/dist/browser/modules/excel/stream/worksheet-writer.js +45 -5
  22. package/dist/browser/modules/excel/table.js +15 -2
  23. package/dist/browser/modules/excel/types.d.ts +133 -2
  24. package/dist/browser/modules/excel/utils/col-cache.d.ts +1 -0
  25. package/dist/browser/modules/excel/utils/col-cache.js +15 -0
  26. package/dist/browser/modules/excel/utils/drawing-utils.d.ts +3 -3
  27. package/dist/browser/modules/excel/utils/drawing-utils.js +4 -0
  28. package/dist/browser/modules/excel/utils/external-link-formula.d.ts +76 -0
  29. package/dist/browser/modules/excel/utils/external-link-formula.js +208 -0
  30. package/dist/browser/modules/excel/utils/iterate-stream.d.ts +9 -3
  31. package/dist/browser/modules/excel/utils/iterate-stream.js +3 -1
  32. package/dist/browser/modules/excel/utils/ooxml-paths.d.ts +19 -0
  33. package/dist/browser/modules/excel/utils/ooxml-paths.js +37 -2
  34. package/dist/browser/modules/excel/utils/shared-strings.d.ts +8 -3
  35. package/dist/browser/modules/excel/utils/shared-strings.js +21 -2
  36. package/dist/browser/modules/excel/utils/workbook-protection.d.ts +30 -0
  37. package/dist/browser/modules/excel/utils/workbook-protection.js +30 -0
  38. package/dist/browser/modules/excel/workbook.browser.d.ts +257 -6
  39. package/dist/browser/modules/excel/workbook.browser.js +318 -34
  40. package/dist/browser/modules/excel/workbook.d.ts +1 -1
  41. package/dist/browser/modules/excel/worksheet.d.ts +3 -1
  42. package/dist/browser/modules/excel/worksheet.js +21 -2
  43. package/dist/browser/modules/excel/xlsx/rel-type.d.ts +15 -0
  44. package/dist/browser/modules/excel/xlsx/rel-type.js +16 -1
  45. package/dist/browser/modules/excel/xlsx/xform/book/defined-name-xform.d.ts +6 -5
  46. package/dist/browser/modules/excel/xlsx/xform/book/defined-name-xform.js +21 -86
  47. package/dist/browser/modules/excel/xlsx/xform/book/external-link-xform.d.ts +84 -0
  48. package/dist/browser/modules/excel/xlsx/xform/book/external-link-xform.js +330 -0
  49. package/dist/browser/modules/excel/xlsx/xform/book/external-reference-xform.d.ts +17 -0
  50. package/dist/browser/modules/excel/xlsx/xform/book/external-reference-xform.js +24 -0
  51. package/dist/browser/modules/excel/xlsx/xform/book/workbook-calc-properties-xform.d.ts +3 -0
  52. package/dist/browser/modules/excel/xlsx/xform/book/workbook-calc-properties-xform.js +11 -2
  53. package/dist/browser/modules/excel/xlsx/xform/book/workbook-protection-xform.d.ts +20 -0
  54. package/dist/browser/modules/excel/xlsx/xform/book/workbook-protection-xform.js +66 -0
  55. package/dist/browser/modules/excel/xlsx/xform/book/workbook-xform.js +38 -5
  56. package/dist/browser/modules/excel/xlsx/xform/core/content-types-xform.js +19 -1
  57. package/dist/browser/modules/excel/xlsx/xform/core/metadata-xform.d.ts +56 -0
  58. package/dist/browser/modules/excel/xlsx/xform/core/metadata-xform.js +158 -0
  59. package/dist/browser/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.d.ts +26 -0
  60. package/dist/browser/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +105 -0
  61. package/dist/browser/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +3 -0
  62. package/dist/browser/modules/excel/xlsx/xform/drawing/drawing-xform.js +10 -2
  63. package/dist/browser/modules/excel/xlsx/xform/sheet/cell-xform.d.ts +1 -1
  64. package/dist/browser/modules/excel/xlsx/xform/sheet/cell-xform.js +166 -8
  65. package/dist/browser/modules/excel/xlsx/xform/sheet/data-validations-xform.js +1 -1
  66. package/dist/browser/modules/excel/xlsx/xform/sheet/ignored-errors-xform.d.ts +21 -0
  67. package/dist/browser/modules/excel/xlsx/xform/sheet/ignored-errors-xform.js +80 -0
  68. package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +9 -4
  69. package/dist/browser/modules/excel/xlsx/xform/style/border-xform.js +4 -1
  70. package/dist/browser/modules/excel/xlsx/xlsx.browser.d.ts +172 -13
  71. package/dist/browser/modules/excel/xlsx/xlsx.browser.js +410 -20
  72. package/dist/browser/modules/excel/xlsx/xlsx.d.ts +7 -4
  73. package/dist/browser/modules/excel/xlsx/xlsx.js +4 -5
  74. package/dist/browser/modules/formula/compile/address-utils.d.ts +62 -0
  75. package/dist/browser/modules/formula/compile/address-utils.js +83 -0
  76. package/dist/browser/modules/formula/compile/binder.d.ts +42 -0
  77. package/dist/browser/modules/formula/compile/binder.js +487 -0
  78. package/dist/browser/modules/formula/compile/bound-ast.d.ts +230 -0
  79. package/dist/browser/modules/formula/compile/bound-ast.js +80 -0
  80. package/dist/browser/modules/formula/compile/compiled-formula.d.ts +137 -0
  81. package/dist/browser/modules/formula/compile/compiled-formula.js +383 -0
  82. package/dist/browser/modules/formula/compile/dependency-analysis.d.ts +93 -0
  83. package/dist/browser/modules/formula/compile/dependency-analysis.js +432 -0
  84. package/dist/browser/modules/formula/compile/structured-ref-utils.d.ts +93 -0
  85. package/dist/browser/modules/formula/compile/structured-ref-utils.js +136 -0
  86. package/dist/browser/modules/formula/default-syntax-probe.d.ts +79 -0
  87. package/dist/browser/modules/formula/default-syntax-probe.js +83 -0
  88. package/dist/browser/modules/formula/functions/_date-context.d.ts +4 -0
  89. package/dist/browser/modules/formula/functions/_date-context.js +29 -0
  90. package/dist/browser/modules/formula/functions/_shared.d.ts +121 -0
  91. package/dist/browser/modules/formula/functions/_shared.js +381 -0
  92. package/dist/browser/modules/formula/functions/conditional.d.ts +27 -0
  93. package/dist/browser/modules/formula/functions/conditional.js +343 -0
  94. package/dist/browser/modules/formula/functions/database.d.ts +37 -0
  95. package/dist/browser/modules/formula/functions/database.js +274 -0
  96. package/dist/browser/modules/formula/functions/date.d.ts +61 -0
  97. package/dist/browser/modules/formula/functions/date.js +855 -0
  98. package/dist/browser/modules/formula/functions/dynamic-array.d.ts +23 -0
  99. package/dist/browser/modules/formula/functions/dynamic-array.js +860 -0
  100. package/dist/browser/modules/formula/functions/engineering.d.ts +57 -0
  101. package/dist/browser/modules/formula/functions/engineering.js +1128 -0
  102. package/dist/browser/modules/formula/functions/financial.d.ts +202 -0
  103. package/dist/browser/modules/formula/functions/financial.js +2296 -0
  104. package/dist/browser/modules/formula/functions/lookup.d.ts +18 -0
  105. package/dist/browser/modules/formula/functions/lookup.js +886 -0
  106. package/dist/browser/modules/formula/functions/math.d.ts +114 -0
  107. package/dist/browser/modules/formula/functions/math.js +1406 -0
  108. package/dist/browser/modules/formula/functions/statistical.d.ts +193 -0
  109. package/dist/browser/modules/formula/functions/statistical.js +3390 -0
  110. package/dist/browser/modules/formula/functions/text.d.ts +86 -0
  111. package/dist/browser/modules/formula/functions/text.js +1845 -0
  112. package/dist/browser/modules/formula/host-registry.d.ts +53 -0
  113. package/dist/browser/modules/formula/host-registry.js +69 -0
  114. package/dist/browser/modules/formula/index.d.ts +39 -0
  115. package/dist/browser/modules/formula/index.js +49 -0
  116. package/dist/browser/modules/formula/install.d.ts +62 -0
  117. package/dist/browser/modules/formula/install.js +88 -0
  118. package/dist/browser/modules/formula/integration/apply-writeback-plan.d.ts +26 -0
  119. package/dist/browser/modules/formula/integration/apply-writeback-plan.js +210 -0
  120. package/dist/browser/modules/formula/integration/calculate-formulas-impl.d.ts +30 -0
  121. package/dist/browser/modules/formula/integration/calculate-formulas-impl.js +616 -0
  122. package/dist/browser/modules/formula/integration/calculate-formulas.d.ts +67 -0
  123. package/dist/browser/modules/formula/integration/calculate-formulas.js +68 -0
  124. package/dist/browser/modules/formula/integration/formula-instance.d.ts +64 -0
  125. package/dist/browser/modules/formula/integration/formula-instance.js +79 -0
  126. package/dist/browser/modules/formula/integration/workbook-adapter.d.ts +26 -0
  127. package/dist/browser/modules/formula/integration/workbook-adapter.js +324 -0
  128. package/dist/browser/modules/formula/integration/workbook-snapshot.d.ts +267 -0
  129. package/dist/browser/modules/formula/integration/workbook-snapshot.js +77 -0
  130. package/dist/browser/modules/formula/materialize/build-writeback-plan.d.ts +34 -0
  131. package/dist/browser/modules/formula/materialize/build-writeback-plan.js +473 -0
  132. package/dist/browser/modules/formula/materialize/spill-engine.d.ts +9 -0
  133. package/dist/browser/modules/formula/materialize/spill-engine.js +38 -0
  134. package/dist/browser/modules/formula/materialize/types.d.ts +179 -0
  135. package/dist/browser/modules/formula/materialize/types.js +29 -0
  136. package/dist/browser/modules/formula/materialize/writeback-plan.d.ts +167 -0
  137. package/dist/browser/modules/formula/materialize/writeback-plan.js +27 -0
  138. package/dist/browser/modules/formula/runtime/evaluator.d.ts +151 -0
  139. package/dist/browser/modules/formula/runtime/evaluator.js +2291 -0
  140. package/dist/browser/modules/formula/runtime/function-registry.d.ts +47 -0
  141. package/dist/browser/modules/formula/runtime/function-registry.js +840 -0
  142. package/dist/browser/modules/formula/runtime/values.d.ts +211 -0
  143. package/dist/browser/modules/formula/runtime/values.js +385 -0
  144. package/dist/browser/modules/formula/syntax/ast.d.ts +129 -0
  145. package/dist/browser/modules/formula/syntax/ast.js +28 -0
  146. package/dist/browser/modules/formula/syntax/parser.d.ts +18 -0
  147. package/dist/browser/modules/formula/syntax/parser.js +439 -0
  148. package/dist/browser/modules/formula/syntax/token-types.d.ts +153 -0
  149. package/dist/browser/modules/formula/syntax/token-types.js +59 -0
  150. package/dist/browser/modules/formula/syntax/tokenizer.d.ts +10 -0
  151. package/dist/browser/modules/formula/syntax/tokenizer.js +1074 -0
  152. package/dist/browser/modules/pdf/excel-bridge.js +9 -0
  153. package/dist/cjs/index.js +4 -0
  154. package/dist/cjs/modules/excel/cell.js +170 -22
  155. package/dist/cjs/modules/excel/defined-names.js +411 -21
  156. package/dist/cjs/modules/excel/image.js +24 -1
  157. package/dist/cjs/modules/excel/stream/workbook-reader.browser.js +14 -0
  158. package/dist/cjs/modules/excel/stream/workbook-writer.browser.js +48 -1
  159. package/dist/cjs/modules/excel/stream/worksheet-reader.js +17 -1
  160. package/dist/cjs/modules/excel/stream/worksheet-writer.js +45 -5
  161. package/dist/cjs/modules/excel/table.js +15 -2
  162. package/dist/cjs/modules/excel/utils/col-cache.js +15 -0
  163. package/dist/cjs/modules/excel/utils/drawing-utils.js +4 -0
  164. package/dist/cjs/modules/excel/utils/external-link-formula.js +212 -0
  165. package/dist/cjs/modules/excel/utils/iterate-stream.js +3 -1
  166. package/dist/cjs/modules/excel/utils/ooxml-paths.js +42 -2
  167. package/dist/cjs/modules/excel/utils/shared-strings.js +21 -2
  168. package/dist/cjs/modules/excel/utils/workbook-protection.js +33 -0
  169. package/dist/cjs/modules/excel/workbook.browser.js +318 -34
  170. package/dist/cjs/modules/excel/worksheet.js +20 -1
  171. package/dist/cjs/modules/excel/xlsx/rel-type.js +16 -1
  172. package/dist/cjs/modules/excel/xlsx/xform/book/defined-name-xform.js +21 -86
  173. package/dist/cjs/modules/excel/xlsx/xform/book/external-link-xform.js +333 -0
  174. package/dist/cjs/modules/excel/xlsx/xform/book/external-reference-xform.js +27 -0
  175. package/dist/cjs/modules/excel/xlsx/xform/book/workbook-calc-properties-xform.js +11 -2
  176. package/dist/cjs/modules/excel/xlsx/xform/book/workbook-protection-xform.js +69 -0
  177. package/dist/cjs/modules/excel/xlsx/xform/book/workbook-xform.js +38 -5
  178. package/dist/cjs/modules/excel/xlsx/xform/core/content-types-xform.js +18 -0
  179. package/dist/cjs/modules/excel/xlsx/xform/core/metadata-xform.js +161 -0
  180. package/dist/cjs/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +108 -0
  181. package/dist/cjs/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +3 -0
  182. package/dist/cjs/modules/excel/xlsx/xform/drawing/drawing-xform.js +10 -2
  183. package/dist/cjs/modules/excel/xlsx/xform/sheet/cell-xform.js +166 -8
  184. package/dist/cjs/modules/excel/xlsx/xform/sheet/data-validations-xform.js +1 -1
  185. package/dist/cjs/modules/excel/xlsx/xform/sheet/ignored-errors-xform.js +83 -0
  186. package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +9 -4
  187. package/dist/cjs/modules/excel/xlsx/xform/style/border-xform.js +4 -1
  188. package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +408 -18
  189. package/dist/cjs/modules/excel/xlsx/xlsx.js +4 -5
  190. package/dist/cjs/modules/formula/compile/address-utils.js +89 -0
  191. package/dist/cjs/modules/formula/compile/binder.js +489 -0
  192. package/dist/cjs/modules/formula/compile/bound-ast.js +68 -0
  193. package/dist/cjs/modules/formula/compile/compiled-formula.js +387 -0
  194. package/dist/cjs/modules/formula/compile/dependency-analysis.js +437 -0
  195. package/dist/cjs/modules/formula/compile/structured-ref-utils.js +141 -0
  196. package/dist/cjs/modules/formula/default-syntax-probe.js +87 -0
  197. package/dist/cjs/modules/formula/functions/_date-context.js +33 -0
  198. package/dist/cjs/modules/formula/functions/_shared.js +396 -0
  199. package/dist/cjs/modules/formula/functions/conditional.js +354 -0
  200. package/dist/cjs/modules/formula/functions/database.js +288 -0
  201. package/dist/cjs/modules/formula/functions/date.js +883 -0
  202. package/dist/cjs/modules/formula/functions/dynamic-array.js +881 -0
  203. package/dist/cjs/modules/formula/functions/engineering.js +1183 -0
  204. package/dist/cjs/modules/formula/functions/financial.js +2348 -0
  205. package/dist/cjs/modules/formula/functions/lookup.js +902 -0
  206. package/dist/cjs/modules/formula/functions/math.js +1487 -0
  207. package/dist/cjs/modules/formula/functions/statistical.js +3488 -0
  208. package/dist/cjs/modules/formula/functions/text.js +1889 -0
  209. package/dist/cjs/modules/formula/host-registry.js +75 -0
  210. package/dist/cjs/modules/formula/index.js +58 -0
  211. package/dist/cjs/modules/formula/install.js +93 -0
  212. package/dist/cjs/modules/formula/integration/apply-writeback-plan.js +213 -0
  213. package/dist/cjs/modules/formula/integration/calculate-formulas-impl.js +619 -0
  214. package/dist/cjs/modules/formula/integration/calculate-formulas.js +71 -0
  215. package/dist/cjs/modules/formula/integration/formula-instance.js +82 -0
  216. package/dist/cjs/modules/formula/integration/workbook-adapter.js +327 -0
  217. package/dist/cjs/modules/formula/integration/workbook-snapshot.js +84 -0
  218. package/dist/cjs/modules/formula/materialize/build-writeback-plan.js +475 -0
  219. package/dist/cjs/modules/formula/materialize/spill-engine.js +42 -0
  220. package/dist/cjs/modules/formula/materialize/types.js +32 -0
  221. package/dist/cjs/modules/formula/materialize/writeback-plan.js +28 -0
  222. package/dist/cjs/modules/formula/runtime/evaluator.js +2298 -0
  223. package/dist/cjs/modules/formula/runtime/function-registry.js +846 -0
  224. package/dist/cjs/modules/formula/runtime/values.js +385 -0
  225. package/dist/cjs/modules/formula/syntax/ast.js +8 -0
  226. package/dist/cjs/modules/formula/syntax/parser.js +440 -0
  227. package/dist/cjs/modules/formula/syntax/token-types.js +32 -0
  228. package/dist/cjs/modules/formula/syntax/tokenizer.js +1076 -0
  229. package/dist/cjs/modules/pdf/excel-bridge.js +9 -0
  230. package/dist/esm/index.browser.js +4 -0
  231. package/dist/esm/index.js +4 -0
  232. package/dist/esm/modules/excel/cell.js +170 -22
  233. package/dist/esm/modules/excel/defined-names.js +411 -21
  234. package/dist/esm/modules/excel/image.js +24 -1
  235. package/dist/esm/modules/excel/stream/workbook-reader.browser.js +14 -0
  236. package/dist/esm/modules/excel/stream/workbook-writer.browser.js +48 -1
  237. package/dist/esm/modules/excel/stream/worksheet-reader.js +17 -1
  238. package/dist/esm/modules/excel/stream/worksheet-writer.js +45 -5
  239. package/dist/esm/modules/excel/table.js +15 -2
  240. package/dist/esm/modules/excel/utils/col-cache.js +15 -0
  241. package/dist/esm/modules/excel/utils/drawing-utils.js +4 -0
  242. package/dist/esm/modules/excel/utils/external-link-formula.js +208 -0
  243. package/dist/esm/modules/excel/utils/iterate-stream.js +3 -1
  244. package/dist/esm/modules/excel/utils/ooxml-paths.js +37 -2
  245. package/dist/esm/modules/excel/utils/shared-strings.js +21 -2
  246. package/dist/esm/modules/excel/utils/workbook-protection.js +30 -0
  247. package/dist/esm/modules/excel/workbook.browser.js +318 -34
  248. package/dist/esm/modules/excel/worksheet.js +21 -2
  249. package/dist/esm/modules/excel/xlsx/rel-type.js +16 -1
  250. package/dist/esm/modules/excel/xlsx/xform/book/defined-name-xform.js +21 -86
  251. package/dist/esm/modules/excel/xlsx/xform/book/external-link-xform.js +330 -0
  252. package/dist/esm/modules/excel/xlsx/xform/book/external-reference-xform.js +24 -0
  253. package/dist/esm/modules/excel/xlsx/xform/book/workbook-calc-properties-xform.js +11 -2
  254. package/dist/esm/modules/excel/xlsx/xform/book/workbook-protection-xform.js +66 -0
  255. package/dist/esm/modules/excel/xlsx/xform/book/workbook-xform.js +38 -5
  256. package/dist/esm/modules/excel/xlsx/xform/core/content-types-xform.js +19 -1
  257. package/dist/esm/modules/excel/xlsx/xform/core/metadata-xform.js +158 -0
  258. package/dist/esm/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +105 -0
  259. package/dist/esm/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +3 -0
  260. package/dist/esm/modules/excel/xlsx/xform/drawing/drawing-xform.js +10 -2
  261. package/dist/esm/modules/excel/xlsx/xform/sheet/cell-xform.js +166 -8
  262. package/dist/esm/modules/excel/xlsx/xform/sheet/data-validations-xform.js +1 -1
  263. package/dist/esm/modules/excel/xlsx/xform/sheet/ignored-errors-xform.js +80 -0
  264. package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +9 -4
  265. package/dist/esm/modules/excel/xlsx/xform/style/border-xform.js +4 -1
  266. package/dist/esm/modules/excel/xlsx/xlsx.browser.js +410 -20
  267. package/dist/esm/modules/excel/xlsx/xlsx.js +4 -5
  268. package/dist/esm/modules/formula/compile/address-utils.js +83 -0
  269. package/dist/esm/modules/formula/compile/binder.js +487 -0
  270. package/dist/esm/modules/formula/compile/bound-ast.js +80 -0
  271. package/dist/esm/modules/formula/compile/compiled-formula.js +383 -0
  272. package/dist/esm/modules/formula/compile/dependency-analysis.js +432 -0
  273. package/dist/esm/modules/formula/compile/structured-ref-utils.js +136 -0
  274. package/dist/esm/modules/formula/default-syntax-probe.js +83 -0
  275. package/dist/esm/modules/formula/functions/_date-context.js +29 -0
  276. package/dist/esm/modules/formula/functions/_shared.js +381 -0
  277. package/dist/esm/modules/formula/functions/conditional.js +343 -0
  278. package/dist/esm/modules/formula/functions/database.js +274 -0
  279. package/dist/esm/modules/formula/functions/date.js +855 -0
  280. package/dist/esm/modules/formula/functions/dynamic-array.js +860 -0
  281. package/dist/esm/modules/formula/functions/engineering.js +1128 -0
  282. package/dist/esm/modules/formula/functions/financial.js +2296 -0
  283. package/dist/esm/modules/formula/functions/lookup.js +886 -0
  284. package/dist/esm/modules/formula/functions/math.js +1406 -0
  285. package/dist/esm/modules/formula/functions/statistical.js +3390 -0
  286. package/dist/esm/modules/formula/functions/text.js +1845 -0
  287. package/dist/esm/modules/formula/host-registry.js +69 -0
  288. package/dist/esm/modules/formula/index.js +49 -0
  289. package/dist/esm/modules/formula/install.js +88 -0
  290. package/dist/esm/modules/formula/integration/apply-writeback-plan.js +210 -0
  291. package/dist/esm/modules/formula/integration/calculate-formulas-impl.js +616 -0
  292. package/dist/esm/modules/formula/integration/calculate-formulas.js +68 -0
  293. package/dist/esm/modules/formula/integration/formula-instance.js +79 -0
  294. package/dist/esm/modules/formula/integration/workbook-adapter.js +324 -0
  295. package/dist/esm/modules/formula/integration/workbook-snapshot.js +77 -0
  296. package/dist/esm/modules/formula/materialize/build-writeback-plan.js +473 -0
  297. package/dist/esm/modules/formula/materialize/spill-engine.js +38 -0
  298. package/dist/esm/modules/formula/materialize/types.js +29 -0
  299. package/dist/esm/modules/formula/materialize/writeback-plan.js +27 -0
  300. package/dist/esm/modules/formula/runtime/evaluator.js +2291 -0
  301. package/dist/esm/modules/formula/runtime/function-registry.js +840 -0
  302. package/dist/esm/modules/formula/runtime/values.js +385 -0
  303. package/dist/esm/modules/formula/syntax/ast.js +28 -0
  304. package/dist/esm/modules/formula/syntax/parser.js +439 -0
  305. package/dist/esm/modules/formula/syntax/token-types.js +59 -0
  306. package/dist/esm/modules/formula/syntax/tokenizer.js +1074 -0
  307. package/dist/esm/modules/pdf/excel-bridge.js +9 -0
  308. package/dist/iife/excelts.iife.js +2302 -373
  309. package/dist/iife/excelts.iife.js.map +1 -1
  310. package/dist/iife/excelts.iife.min.js +34 -34
  311. package/dist/types/index.browser.d.ts +1 -1
  312. package/dist/types/index.d.ts +1 -1
  313. package/dist/types/modules/excel/cell.d.ts +17 -3
  314. package/dist/types/modules/excel/defined-names.d.ts +96 -1
  315. package/dist/types/modules/excel/image.d.ts +11 -0
  316. package/dist/types/modules/excel/stream/workbook-reader.browser.d.ts +9 -3
  317. package/dist/types/modules/excel/stream/workbook-reader.d.ts +2 -1
  318. package/dist/types/modules/excel/stream/workbook-writer.browser.d.ts +39 -5
  319. package/dist/types/modules/excel/stream/workbook-writer.d.ts +3 -2
  320. package/dist/types/modules/excel/stream/worksheet-writer.d.ts +39 -6
  321. package/dist/types/modules/excel/types.d.ts +133 -2
  322. package/dist/types/modules/excel/utils/col-cache.d.ts +1 -0
  323. package/dist/types/modules/excel/utils/drawing-utils.d.ts +3 -3
  324. package/dist/types/modules/excel/utils/external-link-formula.d.ts +76 -0
  325. package/dist/types/modules/excel/utils/iterate-stream.d.ts +9 -3
  326. package/dist/types/modules/excel/utils/ooxml-paths.d.ts +19 -0
  327. package/dist/types/modules/excel/utils/shared-strings.d.ts +8 -3
  328. package/dist/types/modules/excel/utils/workbook-protection.d.ts +30 -0
  329. package/dist/types/modules/excel/workbook.browser.d.ts +257 -6
  330. package/dist/types/modules/excel/workbook.d.ts +1 -1
  331. package/dist/types/modules/excel/worksheet.d.ts +3 -1
  332. package/dist/types/modules/excel/xlsx/rel-type.d.ts +15 -0
  333. package/dist/types/modules/excel/xlsx/xform/book/defined-name-xform.d.ts +6 -5
  334. package/dist/types/modules/excel/xlsx/xform/book/external-link-xform.d.ts +84 -0
  335. package/dist/types/modules/excel/xlsx/xform/book/external-reference-xform.d.ts +17 -0
  336. package/dist/types/modules/excel/xlsx/xform/book/workbook-calc-properties-xform.d.ts +3 -0
  337. package/dist/types/modules/excel/xlsx/xform/book/workbook-protection-xform.d.ts +20 -0
  338. package/dist/types/modules/excel/xlsx/xform/core/metadata-xform.d.ts +56 -0
  339. package/dist/types/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.d.ts +26 -0
  340. package/dist/types/modules/excel/xlsx/xform/sheet/cell-xform.d.ts +1 -1
  341. package/dist/types/modules/excel/xlsx/xform/sheet/ignored-errors-xform.d.ts +21 -0
  342. package/dist/types/modules/excel/xlsx/xlsx.browser.d.ts +172 -13
  343. package/dist/types/modules/excel/xlsx/xlsx.d.ts +7 -4
  344. package/dist/types/modules/formula/compile/address-utils.d.ts +62 -0
  345. package/dist/types/modules/formula/compile/binder.d.ts +42 -0
  346. package/dist/types/modules/formula/compile/bound-ast.d.ts +230 -0
  347. package/dist/types/modules/formula/compile/compiled-formula.d.ts +137 -0
  348. package/dist/types/modules/formula/compile/dependency-analysis.d.ts +93 -0
  349. package/dist/types/modules/formula/compile/structured-ref-utils.d.ts +93 -0
  350. package/dist/types/modules/formula/default-syntax-probe.d.ts +79 -0
  351. package/dist/types/modules/formula/functions/_date-context.d.ts +4 -0
  352. package/dist/types/modules/formula/functions/_shared.d.ts +121 -0
  353. package/dist/types/modules/formula/functions/conditional.d.ts +27 -0
  354. package/dist/types/modules/formula/functions/database.d.ts +37 -0
  355. package/dist/types/modules/formula/functions/date.d.ts +61 -0
  356. package/dist/types/modules/formula/functions/dynamic-array.d.ts +23 -0
  357. package/dist/types/modules/formula/functions/engineering.d.ts +57 -0
  358. package/dist/types/modules/formula/functions/financial.d.ts +202 -0
  359. package/dist/types/modules/formula/functions/lookup.d.ts +18 -0
  360. package/dist/types/modules/formula/functions/math.d.ts +114 -0
  361. package/dist/types/modules/formula/functions/statistical.d.ts +193 -0
  362. package/dist/types/modules/formula/functions/text.d.ts +86 -0
  363. package/dist/types/modules/formula/host-registry.d.ts +53 -0
  364. package/dist/types/modules/formula/index.d.ts +39 -0
  365. package/dist/types/modules/formula/install.d.ts +62 -0
  366. package/dist/types/modules/formula/integration/apply-writeback-plan.d.ts +26 -0
  367. package/dist/types/modules/formula/integration/calculate-formulas-impl.d.ts +30 -0
  368. package/dist/types/modules/formula/integration/calculate-formulas.d.ts +67 -0
  369. package/dist/types/modules/formula/integration/formula-instance.d.ts +64 -0
  370. package/dist/types/modules/formula/integration/workbook-adapter.d.ts +26 -0
  371. package/dist/types/modules/formula/integration/workbook-snapshot.d.ts +267 -0
  372. package/dist/types/modules/formula/materialize/build-writeback-plan.d.ts +34 -0
  373. package/dist/types/modules/formula/materialize/spill-engine.d.ts +9 -0
  374. package/dist/types/modules/formula/materialize/types.d.ts +179 -0
  375. package/dist/types/modules/formula/materialize/writeback-plan.d.ts +167 -0
  376. package/dist/types/modules/formula/runtime/evaluator.d.ts +151 -0
  377. package/dist/types/modules/formula/runtime/function-registry.d.ts +47 -0
  378. package/dist/types/modules/formula/runtime/values.d.ts +211 -0
  379. package/dist/types/modules/formula/syntax/ast.d.ts +129 -0
  380. package/dist/types/modules/formula/syntax/parser.d.ts +18 -0
  381. package/dist/types/modules/formula/syntax/token-types.d.ts +153 -0
  382. package/dist/types/modules/formula/syntax/tokenizer.d.ts +10 -0
  383. package/package.json +28 -28
@@ -0,0 +1,439 @@
1
+ /**
2
+ * Formula Parser
3
+ *
4
+ * Converts a token stream into an Abstract Syntax Tree (AST).
5
+ * Implements a Pratt parser (top-down operator precedence) for correct
6
+ * handling of operator precedence and associativity.
7
+ *
8
+ * Excel operator precedence (highest to lowest):
9
+ * 1. Unary + / - / %
10
+ * 2. ^ (exponentiation, right-assoc)
11
+ * 3. * /
12
+ * 4. + -
13
+ * 5. & (concatenation)
14
+ * 6. = <> < > <= >= (comparison)
15
+ */
16
+ import { NodeType } from "./ast.js";
17
+ import { TokenType } from "./token-types.js";
18
+ // ============================================================================
19
+ // Operator Precedence
20
+ // ============================================================================
21
+ function prefixBindingPower(op) {
22
+ switch (op) {
23
+ case "+":
24
+ case "-":
25
+ // Must be lower than ^ (60/61) so that -2^3 parses as -(2^3), not (-2)^3.
26
+ // Excel: -2^2 = -4, not 4.
27
+ return 55;
28
+ default:
29
+ return 0;
30
+ }
31
+ }
32
+ function infixBindingPower(op) {
33
+ // Returns [left bp, right bp]. Higher = tighter binding.
34
+ // Left < Right for left-associative, Left > Right for right-associative.
35
+ switch (op) {
36
+ case "=":
37
+ case "<>":
38
+ case "<":
39
+ case ">":
40
+ case "<=":
41
+ case ">=":
42
+ return [10, 11];
43
+ case "&":
44
+ return [20, 21];
45
+ case "+":
46
+ case "-":
47
+ return [30, 31];
48
+ case "*":
49
+ case "/":
50
+ return [40, 41];
51
+ case "^":
52
+ return [61, 60]; // right-associative
53
+ // Intersection operator — whitespace between two refs. In Excel
54
+ // precedence this sits between `:` (range, already handled at the
55
+ // tokenizer level) and unary +/-. Left-associative, binds tighter
56
+ // than every arithmetic operator.
57
+ case " ":
58
+ return [80, 81];
59
+ default:
60
+ return [0, 0];
61
+ }
62
+ }
63
+ // ============================================================================
64
+ // Parser
65
+ // ============================================================================
66
+ class Parser {
67
+ constructor(tokens) {
68
+ this.MAX_DEPTH = 256;
69
+ this.tokens = tokens;
70
+ this.pos = 0;
71
+ this.depth = 0;
72
+ }
73
+ enter() {
74
+ if (++this.depth > this.MAX_DEPTH) {
75
+ throw new Error(`Formula nested too deep (> ${this.MAX_DEPTH} levels)`);
76
+ }
77
+ }
78
+ leave() {
79
+ this.depth--;
80
+ }
81
+ peek() {
82
+ return this.tokens[this.pos];
83
+ }
84
+ next() {
85
+ return this.tokens[this.pos++];
86
+ }
87
+ expect(type) {
88
+ const t = this.next();
89
+ if (!t || t.type !== type) {
90
+ throw new Error(`Expected token type ${type}, got ${t?.type ?? "EOF"}`);
91
+ }
92
+ return t;
93
+ }
94
+ // Entry point
95
+ parse() {
96
+ const node = this.parseExpr(0);
97
+ // After parsing a complete expression, every token must have been
98
+ // consumed. Otherwise inputs like "A1:B2:C3" or "1+2 3" would silently
99
+ // produce an AST that drops the trailing tokens.
100
+ if (this.pos !== this.tokens.length) {
101
+ const t = this.tokens[this.pos];
102
+ throw new Error(`Unexpected trailing token at position ${this.pos} (type ${t.type})`);
103
+ }
104
+ return node;
105
+ }
106
+ parseExpr(minBp) {
107
+ this.enter();
108
+ try {
109
+ return this.parseExprInner(minBp);
110
+ }
111
+ finally {
112
+ this.leave();
113
+ }
114
+ }
115
+ parseExprInner(minBp) {
116
+ let left = this.parsePrefix();
117
+ while (true) {
118
+ const t = this.peek();
119
+ if (!t) {
120
+ break;
121
+ }
122
+ // Postfix: %
123
+ if (t.type === TokenType.Percent) {
124
+ this.next();
125
+ left = { type: NodeType.Percent, operand: left };
126
+ continue;
127
+ }
128
+ // Infix operators
129
+ if (t.type === TokenType.Operator) {
130
+ const [lbp, rbp] = infixBindingPower(t.value);
131
+ if (lbp === 0 || lbp < minBp) {
132
+ break;
133
+ }
134
+ this.next();
135
+ const right = this.parseExpr(rbp);
136
+ left = { type: NodeType.BinaryOp, op: t.value, left, right };
137
+ continue;
138
+ }
139
+ // Intersection: whitespace separating two refs. Modelled as a binary
140
+ // operation with op=" ". The evaluator resolves both sides to refs
141
+ // and returns their rectangle intersection (or `#NULL!`).
142
+ if (t.type === TokenType.Intersect) {
143
+ const [lbp, rbp] = infixBindingPower(" ");
144
+ if (lbp < minBp) {
145
+ break;
146
+ }
147
+ this.next();
148
+ const right = this.parseExpr(rbp);
149
+ left = { type: NodeType.BinaryOp, op: " ", left, right };
150
+ continue;
151
+ }
152
+ // Range operator `:` — binds tighter than intersection. Normally
153
+ // `A1:B2` is merged into a single Range token by the tokenizer,
154
+ // but patterns like `B11:INDIRECT("B" & ROW()-1)` where one side
155
+ // is a function call leave the colon as a standalone token. The
156
+ // evaluator then coerces both sides to references and constructs
157
+ // the union rectangle.
158
+ if (t.type === TokenType.Colon) {
159
+ // Right-biased binding power to guarantee higher precedence than
160
+ // every other operator in the table above.
161
+ const lbp = 100;
162
+ const rbp = 101;
163
+ if (lbp < minBp) {
164
+ break;
165
+ }
166
+ this.next();
167
+ const right = this.parseExpr(rbp);
168
+ left = { type: NodeType.BinaryOp, op: ":", left, right };
169
+ continue;
170
+ }
171
+ break;
172
+ }
173
+ return left;
174
+ }
175
+ parsePrefix() {
176
+ this.enter();
177
+ try {
178
+ const result = this.parsePrefixInner();
179
+ // If the SheetRef consumer below set pendingSheet but the prefix that
180
+ // followed wasn't a ref (CellRef / Range / ColRange / RowRange), the
181
+ // sheet qualifier would leak into the next parse and silently attach
182
+ // itself to an unrelated node. Detect it here.
183
+ if (this.pendingSheet !== undefined) {
184
+ const sheet = this.pendingSheet;
185
+ this.pendingSheet = undefined;
186
+ this.pendingEndSheet = undefined;
187
+ throw new Error(`Sheet reference '${sheet}' not followed by a cell or range`);
188
+ }
189
+ return result;
190
+ }
191
+ finally {
192
+ this.leave();
193
+ }
194
+ }
195
+ parsePrefixInner() {
196
+ const t = this.peek();
197
+ if (!t) {
198
+ throw new Error("Unexpected end of formula");
199
+ }
200
+ // SheetRef: consume and set pending sheet for next cell/range
201
+ if (t.type === TokenType.SheetRef) {
202
+ this.next();
203
+ this.pendingSheet = t.sheetName;
204
+ this.pendingEndSheet = t.endSheetName;
205
+ return this.parsePrefix();
206
+ }
207
+ // Unary prefix: + -
208
+ if (t.type === TokenType.UnaryPrefix) {
209
+ this.next();
210
+ const bp = prefixBindingPower(t.value);
211
+ const operand = this.parseExpr(bp);
212
+ return { type: NodeType.UnaryOp, op: t.value, operand };
213
+ }
214
+ // @ implicit intersection prefix (Excel 365)
215
+ if (t.type === TokenType.AtSign) {
216
+ this.next();
217
+ const operand = this.parseExpr(55); // same precedence as unary +/-
218
+ return { type: NodeType.UnaryOp, op: "@", operand };
219
+ }
220
+ // Number literal
221
+ if (t.type === TokenType.Number) {
222
+ this.next();
223
+ const n = parseFloat(t.value);
224
+ // Reject non-finite literals at parse time. `1e400` would otherwise
225
+ // become `Infinity` and flow through arithmetic, requiring every
226
+ // downstream consumer to guard. Surfacing the overflow as a #NUM!
227
+ // error node keeps the engine's invariant that numeric values are
228
+ // always finite.
229
+ if (!Number.isFinite(n)) {
230
+ return { type: NodeType.Error, value: "#NUM!" };
231
+ }
232
+ return { type: NodeType.Number, value: n };
233
+ }
234
+ // String literal
235
+ if (t.type === TokenType.String) {
236
+ this.next();
237
+ return { type: NodeType.String, value: t.value };
238
+ }
239
+ // Boolean literal
240
+ if (t.type === TokenType.Boolean) {
241
+ this.next();
242
+ return { type: NodeType.Boolean, value: t.value === "TRUE" };
243
+ }
244
+ // Error literal
245
+ if (t.type === TokenType.Error) {
246
+ this.next();
247
+ return { type: NodeType.Error, value: t.value };
248
+ }
249
+ // Parenthesized expression
250
+ if (t.type === TokenType.OpenParen) {
251
+ this.next();
252
+ const expr = this.parseExpr(0);
253
+ this.expect(TokenType.CloseParen);
254
+ return expr;
255
+ }
256
+ // Array constant: {1,2;3,4}
257
+ if (t.type === TokenType.OpenBrace) {
258
+ return this.parseArrayConstant();
259
+ }
260
+ // Function call: NAME(args)
261
+ if (t.type === TokenType.Function) {
262
+ return this.parseFunctionCall();
263
+ }
264
+ // Cell reference (may become range via tokenizer)
265
+ if (t.type === TokenType.CellRef) {
266
+ this.next();
267
+ const ref = this.parseCellRefFromToken(t);
268
+ const sheet = this.pendingSheet;
269
+ const endSheet = this.pendingEndSheet;
270
+ this.pendingSheet = undefined;
271
+ this.pendingEndSheet = undefined;
272
+ ref.sheet = sheet;
273
+ ref.endSheet = endSheet;
274
+ return ref;
275
+ }
276
+ // Range reference (already parsed by tokenizer as A1:B2)
277
+ if (t.type === TokenType.Range) {
278
+ this.next();
279
+ const sheet = this.pendingSheet;
280
+ const endSheet = this.pendingEndSheet;
281
+ this.pendingSheet = undefined;
282
+ this.pendingEndSheet = undefined;
283
+ return this.parseRangeFromToken(t, sheet, endSheet);
284
+ }
285
+ // Named range / defined name
286
+ if (t.type === TokenType.Name) {
287
+ this.next();
288
+ return { type: NodeType.Name, name: t.value };
289
+ }
290
+ // Whole-column range (e.g. A:B, $C:$D)
291
+ if (t.type === TokenType.ColRange) {
292
+ this.next();
293
+ const sheet = this.pendingSheet;
294
+ const endSheet = this.pendingEndSheet;
295
+ this.pendingSheet = undefined;
296
+ this.pendingEndSheet = undefined;
297
+ const parts = t.value.split(":");
298
+ const startCol = parts[0].replace(/\$/g, "").toUpperCase();
299
+ const endCol = parts[1].replace(/\$/g, "").toUpperCase();
300
+ return { type: NodeType.ColRangeRef, startCol, endCol, sheet, endSheet };
301
+ }
302
+ // Whole-row range (e.g. 1:5, $3:$7)
303
+ if (t.type === TokenType.RowRange) {
304
+ this.next();
305
+ const sheet = this.pendingSheet;
306
+ const endSheet = this.pendingEndSheet;
307
+ this.pendingSheet = undefined;
308
+ this.pendingEndSheet = undefined;
309
+ const parts = t.value.split(":");
310
+ const startRow = parseInt(parts[0].replace(/\$/g, ""), 10);
311
+ const endRow = parseInt(parts[1].replace(/\$/g, ""), 10);
312
+ return { type: NodeType.RowRangeRef, startRow, endRow, sheet, endSheet };
313
+ }
314
+ // Structured reference (e.g. Table1[Column], [@Column])
315
+ if (t.type === TokenType.StructuredRef) {
316
+ this.next();
317
+ return {
318
+ type: NodeType.StructuredRef,
319
+ tableName: t.tableName,
320
+ columns: t.columns,
321
+ specials: t.specials
322
+ };
323
+ }
324
+ throw new Error(`Unexpected token: ${t.type}`);
325
+ }
326
+ parseCellRefFromToken(t) {
327
+ return {
328
+ type: NodeType.CellRef,
329
+ col: t.col,
330
+ row: t.row,
331
+ colAbsolute: t.colAbsolute,
332
+ rowAbsolute: t.rowAbsolute
333
+ };
334
+ }
335
+ parseRangeFromToken(t, sheet, endSheet) {
336
+ // Token value is like "A1:B2" or "$A$1:$B$2"
337
+ const parts = t.value.split(":");
338
+ const startRef = parseCellRefStr(parts[0]);
339
+ const endRef = parseCellRefStr(parts[1]);
340
+ return {
341
+ type: NodeType.RangeRef,
342
+ start: { ...startRef, sheet },
343
+ end: { ...endRef, sheet },
344
+ sheet,
345
+ endSheet
346
+ };
347
+ }
348
+ parseFunctionCall() {
349
+ const nameToken = this.next(); // function name
350
+ this.expect(TokenType.OpenParen);
351
+ const args = [];
352
+ if (this.peek()?.type !== TokenType.CloseParen) {
353
+ // First argument: might be missing if comma is next
354
+ if (this.peek()?.type === TokenType.Comma) {
355
+ args.push({ type: NodeType.Missing });
356
+ }
357
+ else {
358
+ args.push(this.parseExpr(0));
359
+ }
360
+ while (this.peek()?.type === TokenType.Comma) {
361
+ this.next(); // skip comma
362
+ // Next argument: missing if followed by comma or close paren
363
+ if (this.peek()?.type === TokenType.Comma || this.peek()?.type === TokenType.CloseParen) {
364
+ args.push({ type: NodeType.Missing });
365
+ }
366
+ else {
367
+ args.push(this.parseExpr(0));
368
+ }
369
+ }
370
+ }
371
+ this.expect(TokenType.CloseParen);
372
+ return {
373
+ type: NodeType.FunctionCall,
374
+ name: nameToken.name,
375
+ args
376
+ };
377
+ }
378
+ parseArrayConstant() {
379
+ this.next(); // skip {
380
+ const rows = [];
381
+ let currentRow = [];
382
+ if (this.peek()?.type !== TokenType.CloseBrace) {
383
+ currentRow.push(this.parseExpr(0));
384
+ while (this.peek()) {
385
+ const t = this.peek();
386
+ if (t.type === TokenType.Comma) {
387
+ this.next();
388
+ currentRow.push(this.parseExpr(0));
389
+ }
390
+ else if (t.type === TokenType.Semicolon) {
391
+ this.next();
392
+ rows.push(currentRow);
393
+ currentRow = [];
394
+ currentRow.push(this.parseExpr(0));
395
+ }
396
+ else {
397
+ break;
398
+ }
399
+ }
400
+ }
401
+ rows.push(currentRow);
402
+ this.expect(TokenType.CloseBrace);
403
+ return { type: NodeType.Array, rows };
404
+ }
405
+ }
406
+ // Helper to parse a cell reference string like "$A$1" or "B2"
407
+ function parseCellRefStr(s) {
408
+ let i = 0;
409
+ let colAbsolute = false;
410
+ let rowAbsolute = false;
411
+ if (s[i] === "$") {
412
+ colAbsolute = true;
413
+ i++;
414
+ }
415
+ const colStart = i;
416
+ while (i < s.length && ((s[i] >= "A" && s[i] <= "Z") || (s[i] >= "a" && s[i] <= "z"))) {
417
+ i++;
418
+ }
419
+ const col = s.slice(colStart, i).toUpperCase();
420
+ if (i < s.length && s[i] === "$") {
421
+ rowAbsolute = true;
422
+ i++;
423
+ }
424
+ const row = s.slice(i);
425
+ return {
426
+ type: NodeType.CellRef,
427
+ col,
428
+ row,
429
+ colAbsolute,
430
+ rowAbsolute
431
+ };
432
+ }
433
+ // ============================================================================
434
+ // Public API
435
+ // ============================================================================
436
+ export function parse(tokens) {
437
+ const parser = new Parser(tokens);
438
+ return parser.parse();
439
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Token Types for Formula Tokenizer
3
+ *
4
+ * Defines a proper discriminated union of all token types.
5
+ * Each token variant carries only the data relevant to its type.
6
+ */
7
+ // ============================================================================
8
+ // Token Type Enum
9
+ // ============================================================================
10
+ export var TokenType;
11
+ (function (TokenType) {
12
+ TokenType[TokenType["Number"] = 1] = "Number";
13
+ TokenType[TokenType["String"] = 2] = "String";
14
+ TokenType[TokenType["Boolean"] = 3] = "Boolean";
15
+ TokenType[TokenType["Error"] = 4] = "Error";
16
+ TokenType[TokenType["CellRef"] = 5] = "CellRef";
17
+ TokenType[TokenType["Range"] = 6] = "Range";
18
+ TokenType[TokenType["SheetRef"] = 7] = "SheetRef";
19
+ TokenType[TokenType["Function"] = 8] = "Function";
20
+ TokenType[TokenType["Operator"] = 9] = "Operator";
21
+ TokenType[TokenType["OpenParen"] = 10] = "OpenParen";
22
+ TokenType[TokenType["CloseParen"] = 11] = "CloseParen";
23
+ TokenType[TokenType["Comma"] = 12] = "Comma";
24
+ TokenType[TokenType["Colon"] = 13] = "Colon";
25
+ TokenType[TokenType["Percent"] = 14] = "Percent";
26
+ TokenType[TokenType["OpenBrace"] = 15] = "OpenBrace";
27
+ TokenType[TokenType["CloseBrace"] = 16] = "CloseBrace";
28
+ TokenType[TokenType["Semicolon"] = 17] = "Semicolon";
29
+ TokenType[TokenType["UnaryPrefix"] = 18] = "UnaryPrefix";
30
+ TokenType[TokenType["Name"] = 19] = "Name";
31
+ TokenType[TokenType["ColRange"] = 20] = "ColRange";
32
+ TokenType[TokenType["RowRange"] = 21] = "RowRange";
33
+ TokenType[TokenType["StructuredRef"] = 22] = "StructuredRef";
34
+ TokenType[TokenType["AtSign"] = 23] = "AtSign";
35
+ TokenType[TokenType["Intersect"] = 24] = "Intersect"; // space between two refs, e.g. A1:A10 B1:B10 (intersection operator)
36
+ })(TokenType || (TokenType = {}));
37
+ // ============================================================================
38
+ // Discriminated Union
39
+ // ============================================================================
40
+ /**
41
+ * Strip Excel's `_XLFN.` / `_XLFN._XLWS.` function-name prefixes.
42
+ *
43
+ * Excel emits these prefixes for functions introduced after the original
44
+ * XLSX schema was frozen (e.g. `_XLFN.FILTER`, `_XLFN._XLWS.SORT`). The
45
+ * canonical function name is recovered by stripping the prefix.
46
+ *
47
+ * The input may or may not already be uppercased — this helper does not
48
+ * alter case; callers that compare against an uppercase table should
49
+ * uppercase first (or compare case-insensitively).
50
+ */
51
+ export function stripFunctionPrefix(name) {
52
+ if (name.startsWith("_XLFN._XLWS.")) {
53
+ return name.slice(12);
54
+ }
55
+ if (name.startsWith("_XLFN.")) {
56
+ return name.slice(6);
57
+ }
58
+ return name;
59
+ }