read-excel-file 9.3.3 → 9.3.5

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 (255) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +32 -2
  3. package/browser/index.cjs +3 -0
  4. package/browser/index.d.ts +16 -0
  5. package/browser/index.js +4 -1
  6. package/bundle/read-excel-file.min.js +1 -1
  7. package/bundle/read-excel-file.min.js.map +1 -1
  8. package/commonjs/export/convertInputToNodeStream.js +0 -12
  9. package/commonjs/export/convertInputToNodeStream.js.map +1 -1
  10. package/commonjs/export/parseSheet.js +14 -7
  11. package/commonjs/export/parseSheet.js.map +1 -1
  12. package/commonjs/export/readSheetBrowser.js +3 -6
  13. package/commonjs/export/readSheetBrowser.js.map +1 -1
  14. package/commonjs/export/readSheetNode.js +3 -6
  15. package/commonjs/export/readSheetNode.js.map +1 -1
  16. package/commonjs/export/readSheetUniversal.js +2 -2
  17. package/commonjs/export/readSheetUniversal.js.map +1 -1
  18. package/commonjs/export/readSheetWebWorker.js +5 -5
  19. package/commonjs/export/readSheetWebWorker.js.map +1 -1
  20. package/commonjs/export/readXlsxFileBrowser.js +3 -6
  21. package/commonjs/export/readXlsxFileBrowser.js.map +1 -1
  22. package/commonjs/export/readXlsxFileNode.js +3 -6
  23. package/commonjs/export/readXlsxFileNode.js.map +1 -1
  24. package/commonjs/export/readXlsxFileUniversal.js +2 -2
  25. package/commonjs/export/readXlsxFileUniversal.js.map +1 -1
  26. package/commonjs/export/readXlsxFileWebWorker.js +5 -5
  27. package/commonjs/export/readXlsxFileWebWorker.js.map +1 -1
  28. package/commonjs/export/unpackXlsxFileBrowser.js +15 -4
  29. package/commonjs/export/unpackXlsxFileBrowser.js.map +1 -1
  30. package/commonjs/export/unpackXlsxFileBrowser.test.js.map +1 -0
  31. package/commonjs/export/unpackXlsxFileNode.js +32 -5
  32. package/commonjs/export/unpackXlsxFileNode.js.map +1 -1
  33. package/commonjs/export/unpackXlsxFileNode.test.js.map +1 -0
  34. package/commonjs/export/unpackXlsxFileUniversal.js +14 -3
  35. package/commonjs/export/unpackXlsxFileUniversal.js.map +1 -1
  36. package/commonjs/export/unpackXlsxFileUniversal.test.js.map +1 -0
  37. package/commonjs/parseSheetData/parseSheetData.js +9 -6
  38. package/commonjs/parseSheetData/parseSheetData.js.map +1 -1
  39. package/commonjs/saxen/parser.js +1 -1
  40. package/commonjs/saxen/parser.js.map +1 -1
  41. package/commonjs/utility/convertValuesFromUint8ArraysToStrings.js +100 -0
  42. package/commonjs/utility/convertValuesFromUint8ArraysToStrings.js.map +1 -0
  43. package/commonjs/xlsx/InvalidSpreadsheetError.js +55 -0
  44. package/commonjs/xlsx/InvalidSpreadsheetError.js.map +1 -0
  45. package/commonjs/xlsx/SheetNotFoundError.js +55 -0
  46. package/commonjs/xlsx/SheetNotFoundError.js.map +1 -0
  47. package/commonjs/xlsx/file/InputValidationStream.js +101 -0
  48. package/commonjs/xlsx/file/InputValidationStream.js.map +1 -0
  49. package/commonjs/xlsx/file/InputValidationStream.test.js.map +1 -0
  50. package/commonjs/xlsx/file/InvalidInputError.js +105 -0
  51. package/commonjs/xlsx/file/InvalidInputError.js.map +1 -0
  52. package/commonjs/xlsx/file/createFileTypeDetector.js +70 -0
  53. package/commonjs/xlsx/file/createFileTypeDetector.js.map +1 -0
  54. package/commonjs/xlsx/file/createFileTypeDetector.test.js.map +1 -0
  55. package/commonjs/xlsx/file/validateLeadingBytes.js +47 -0
  56. package/commonjs/xlsx/file/validateLeadingBytes.js.map +1 -0
  57. package/commonjs/xlsx/file/validateLeadingBytes.test.js.map +1 -0
  58. package/commonjs/xlsx/isDateFormat.js +32 -27
  59. package/commonjs/xlsx/isDateFormat.js.map +1 -1
  60. package/commonjs/xlsx/isDateFormatStyle.js +19 -21
  61. package/commonjs/xlsx/isDateFormatStyle.js.map +1 -1
  62. package/commonjs/xlsx/parseCell.js +252 -115
  63. package/commonjs/xlsx/parseCell.js.map +1 -1
  64. package/commonjs/xlsx/parseCellAddress.js +22 -18
  65. package/commonjs/xlsx/parseCellAddress.js.map +1 -1
  66. package/commonjs/xlsx/parseExcelDate.js +4 -124
  67. package/commonjs/xlsx/parseExcelDate.js.map +1 -1
  68. package/commonjs/xlsx/parseExcelDate.test.js.map +1 -1
  69. package/commonjs/xlsx/parseExcelTimestamp.js +139 -0
  70. package/commonjs/xlsx/parseExcelTimestamp.js.map +1 -0
  71. package/commonjs/xlsx/parseFilePaths.js +48 -47
  72. package/commonjs/xlsx/parseFilePaths.js.map +1 -1
  73. package/commonjs/xlsx/parseSharedStrings.js +91 -36
  74. package/commonjs/xlsx/parseSharedStrings.js.map +1 -1
  75. package/commonjs/xlsx/parseSheet.js +527 -69
  76. package/commonjs/xlsx/parseSheet.js.map +1 -1
  77. package/commonjs/xlsx/parseSpreadsheetContents.js +154 -83
  78. package/commonjs/xlsx/parseSpreadsheetContents.js.map +1 -1
  79. package/commonjs/xlsx/parseSpreadsheetInfo.js +60 -59
  80. package/commonjs/xlsx/parseSpreadsheetInfo.js.map +1 -1
  81. package/commonjs/xlsx/parseStyles.js +75 -75
  82. package/commonjs/xlsx/parseStyles.js.map +1 -1
  83. package/commonjs/xml/parseXml.js +112 -0
  84. package/commonjs/xml/parseXml.js.map +1 -0
  85. package/commonjs/xml/parseXml.test.js.map +1 -0
  86. package/commonjs/xml/parseXmlStream.js.map +1 -1
  87. package/commonjs/xml/parseXmlStream.sax.js +69 -28
  88. package/commonjs/xml/parseXmlStream.sax.js.map +1 -1
  89. package/commonjs/xml/parseXmlStream.saxen.js +66 -40
  90. package/commonjs/xml/parseXmlStream.saxen.js.map +1 -1
  91. package/commonjs/zip/UnzipError.js +55 -0
  92. package/commonjs/zip/UnzipError.js.map +1 -0
  93. package/commonjs/zip/unzipFromArrayBuffer.js +21 -1
  94. package/commonjs/zip/unzipFromArrayBuffer.js.map +1 -1
  95. package/commonjs/zip/unzipFromArrayBuffer.test.js.map +1 -0
  96. package/commonjs/zip/unzipFromStream.fflate.js +43 -35
  97. package/commonjs/zip/unzipFromStream.fflate.js.map +1 -1
  98. package/commonjs/zip/unzipFromStream.js +188 -6
  99. package/commonjs/zip/unzipFromStream.js.map +1 -1
  100. package/commonjs/zip/unzipFromStream.unzipper.js +19 -34
  101. package/commonjs/zip/unzipFromStream.unzipper.js.map +1 -1
  102. package/modules/export/convertInputToNodeStream.js +0 -12
  103. package/modules/export/convertInputToNodeStream.js.map +1 -1
  104. package/modules/export/parseSheet.js +13 -6
  105. package/modules/export/parseSheet.js.map +1 -1
  106. package/modules/export/readSheetBrowser.js +3 -5
  107. package/modules/export/readSheetBrowser.js.map +1 -1
  108. package/modules/export/readSheetNode.js +3 -5
  109. package/modules/export/readSheetNode.js.map +1 -1
  110. package/modules/export/readSheetUniversal.js +2 -2
  111. package/modules/export/readSheetUniversal.js.map +1 -1
  112. package/modules/export/readSheetWebWorker.js +7 -8
  113. package/modules/export/readSheetWebWorker.js.map +1 -1
  114. package/modules/export/readXlsxFileBrowser.js +3 -5
  115. package/modules/export/readXlsxFileBrowser.js.map +1 -1
  116. package/modules/export/readXlsxFileNode.js +3 -5
  117. package/modules/export/readXlsxFileNode.js.map +1 -1
  118. package/modules/export/readXlsxFileUniversal.js +2 -2
  119. package/modules/export/readXlsxFileUniversal.js.map +1 -1
  120. package/modules/export/readXlsxFileWebWorker.js +7 -8
  121. package/modules/export/readXlsxFileWebWorker.js.map +1 -1
  122. package/modules/export/unpackXlsxFileBrowser.js +15 -4
  123. package/modules/export/unpackXlsxFileBrowser.js.map +1 -1
  124. package/modules/export/unpackXlsxFileBrowser.test.js.map +1 -0
  125. package/modules/export/unpackXlsxFileNode.js +32 -5
  126. package/modules/export/unpackXlsxFileNode.js.map +1 -1
  127. package/modules/export/unpackXlsxFileNode.test.js.map +1 -0
  128. package/modules/export/unpackXlsxFileUniversal.js +14 -3
  129. package/modules/export/unpackXlsxFileUniversal.js.map +1 -1
  130. package/modules/export/unpackXlsxFileUniversal.test.js.map +1 -0
  131. package/modules/parseSheetData/parseSheetData.js +9 -6
  132. package/modules/parseSheetData/parseSheetData.js.map +1 -1
  133. package/modules/saxen/parser.js +1 -1
  134. package/modules/saxen/parser.js.map +1 -1
  135. package/modules/utility/convertValuesFromUint8ArraysToStrings.js +92 -0
  136. package/modules/utility/convertValuesFromUint8ArraysToStrings.js.map +1 -0
  137. package/modules/xlsx/InvalidSpreadsheetError.js +50 -0
  138. package/modules/xlsx/InvalidSpreadsheetError.js.map +1 -0
  139. package/modules/xlsx/SheetNotFoundError.js +50 -0
  140. package/modules/xlsx/SheetNotFoundError.js.map +1 -0
  141. package/modules/xlsx/file/InputValidationStream.js +96 -0
  142. package/modules/xlsx/file/InputValidationStream.js.map +1 -0
  143. package/modules/xlsx/file/InputValidationStream.test.js.map +1 -0
  144. package/modules/xlsx/file/InvalidInputError.js +100 -0
  145. package/modules/xlsx/file/InvalidInputError.js.map +1 -0
  146. package/modules/xlsx/file/createFileTypeDetector.js +63 -0
  147. package/modules/xlsx/file/createFileTypeDetector.js.map +1 -0
  148. package/modules/xlsx/file/createFileTypeDetector.test.js.map +1 -0
  149. package/modules/xlsx/file/validateLeadingBytes.js +37 -0
  150. package/modules/xlsx/file/validateLeadingBytes.js.map +1 -0
  151. package/modules/xlsx/file/validateLeadingBytes.test.js.map +1 -0
  152. package/modules/xlsx/isDateFormat.js +31 -27
  153. package/modules/xlsx/isDateFormat.js.map +1 -1
  154. package/modules/xlsx/isDateFormatStyle.js +18 -21
  155. package/modules/xlsx/isDateFormatStyle.js.map +1 -1
  156. package/modules/xlsx/parseCell.js +251 -111
  157. package/modules/xlsx/parseCell.js.map +1 -1
  158. package/modules/xlsx/parseCellAddress.js +21 -18
  159. package/modules/xlsx/parseCellAddress.js.map +1 -1
  160. package/modules/xlsx/parseExcelDate.js +4 -124
  161. package/modules/xlsx/parseExcelDate.js.map +1 -1
  162. package/modules/xlsx/parseExcelDate.test.js.map +1 -1
  163. package/modules/xlsx/parseExcelTimestamp.js +133 -0
  164. package/modules/xlsx/parseExcelTimestamp.js.map +1 -0
  165. package/modules/xlsx/parseFilePaths.js +48 -47
  166. package/modules/xlsx/parseFilePaths.js.map +1 -1
  167. package/modules/xlsx/parseSharedStrings.js +91 -37
  168. package/modules/xlsx/parseSharedStrings.js.map +1 -1
  169. package/modules/xlsx/parseSheet.js +526 -68
  170. package/modules/xlsx/parseSheet.js.map +1 -1
  171. package/modules/xlsx/parseSpreadsheetContents.js +153 -81
  172. package/modules/xlsx/parseSpreadsheetContents.js.map +1 -1
  173. package/modules/xlsx/parseSpreadsheetInfo.js +60 -59
  174. package/modules/xlsx/parseSpreadsheetInfo.js.map +1 -1
  175. package/modules/xlsx/parseStyles.js +75 -75
  176. package/modules/xlsx/parseStyles.js.map +1 -1
  177. package/modules/xml/parseXml.js +106 -0
  178. package/modules/xml/parseXml.js.map +1 -0
  179. package/modules/xml/parseXml.test.js.map +1 -0
  180. package/modules/xml/parseXmlStream.js +2 -0
  181. package/modules/xml/parseXmlStream.js.map +1 -1
  182. package/modules/xml/parseXmlStream.sax.js +69 -28
  183. package/modules/xml/parseXmlStream.sax.js.map +1 -1
  184. package/modules/xml/parseXmlStream.saxen.js +67 -40
  185. package/modules/xml/parseXmlStream.saxen.js.map +1 -1
  186. package/modules/zip/UnzipError.js +49 -0
  187. package/modules/zip/UnzipError.js.map +1 -0
  188. package/modules/zip/unzipFromArrayBuffer.js +21 -1
  189. package/modules/zip/unzipFromArrayBuffer.js.map +1 -1
  190. package/modules/zip/unzipFromArrayBuffer.test.js.map +1 -0
  191. package/modules/zip/unzipFromStream.fflate.js +41 -35
  192. package/modules/zip/unzipFromStream.fflate.js.map +1 -1
  193. package/modules/zip/unzipFromStream.js +124 -1
  194. package/modules/zip/unzipFromStream.js.map +1 -1
  195. package/modules/zip/unzipFromStream.unzipper.js +19 -35
  196. package/modules/zip/unzipFromStream.unzipper.js.map +1 -1
  197. package/node/index.cjs +3 -0
  198. package/node/index.d.ts +16 -0
  199. package/node/index.js +3 -0
  200. package/package.json +5 -3
  201. package/types/InvalidInputError.d.ts +16 -0
  202. package/types/InvalidSpreadsheetError.d.ts +4 -0
  203. package/types/SheetNotFoundError.d.ts +4 -0
  204. package/universal/index.cjs +3 -0
  205. package/universal/index.d.ts +16 -0
  206. package/universal/index.js +3 -0
  207. package/web-worker/index.cjs +3 -0
  208. package/web-worker/index.d.ts +16 -0
  209. package/web-worker/index.js +3 -0
  210. package/commonjs/export/convertValuesFromUint8ArraysToStrings.js +0 -23
  211. package/commonjs/export/convertValuesFromUint8ArraysToStrings.js.map +0 -1
  212. package/commonjs/xlsx/convertCellsToData2dArray.js +0 -84
  213. package/commonjs/xlsx/convertCellsToData2dArray.js.map +0 -1
  214. package/commonjs/xlsx/dropEmptyColumns.js +0 -40
  215. package/commonjs/xlsx/dropEmptyColumns.js.map +0 -1
  216. package/commonjs/xlsx/dropEmptyColumns.test.js.map +0 -1
  217. package/commonjs/xlsx/dropEmptyRows.js +0 -43
  218. package/commonjs/xlsx/dropEmptyRows.js.map +0 -1
  219. package/commonjs/xlsx/dropEmptyRows.test.js.map +0 -1
  220. package/commonjs/xlsx/parseCellValue.js +0 -186
  221. package/commonjs/xlsx/parseCellValue.js.map +0 -1
  222. package/commonjs/xlsx/parseNumber.js +0 -20
  223. package/commonjs/xlsx/parseNumber.js.map +0 -1
  224. package/commonjs/xlsx/parseSharedString.js +0 -64
  225. package/commonjs/xlsx/parseSharedString.js.map +0 -1
  226. package/commonjs/xlsx/parseSheetData.js +0 -68
  227. package/commonjs/xlsx/parseSheetData.js.map +0 -1
  228. package/commonjs/xlsx/reconstructSheetDimensionsFromSheetCells.js +0 -29
  229. package/commonjs/xlsx/reconstructSheetDimensionsFromSheetCells.js.map +0 -1
  230. package/commonjs/xml/parseXmlStream.saxen.code.js +0 -953
  231. package/commonjs/xml/parseXmlStream.saxen.code.js.map +0 -1
  232. package/commonjs/xml/parseXmlStream.test.js.map +0 -1
  233. package/modules/export/convertValuesFromUint8ArraysToStrings.js +0 -17
  234. package/modules/export/convertValuesFromUint8ArraysToStrings.js.map +0 -1
  235. package/modules/xlsx/convertCellsToData2dArray.js +0 -77
  236. package/modules/xlsx/convertCellsToData2dArray.js.map +0 -1
  237. package/modules/xlsx/dropEmptyColumns.js +0 -34
  238. package/modules/xlsx/dropEmptyColumns.js.map +0 -1
  239. package/modules/xlsx/dropEmptyColumns.test.js.map +0 -1
  240. package/modules/xlsx/dropEmptyRows.js +0 -37
  241. package/modules/xlsx/dropEmptyRows.js.map +0 -1
  242. package/modules/xlsx/dropEmptyRows.test.js.map +0 -1
  243. package/modules/xlsx/parseCellValue.js +0 -180
  244. package/modules/xlsx/parseCellValue.js.map +0 -1
  245. package/modules/xlsx/parseNumber.js +0 -14
  246. package/modules/xlsx/parseNumber.js.map +0 -1
  247. package/modules/xlsx/parseSharedString.js +0 -55
  248. package/modules/xlsx/parseSharedString.js.map +0 -1
  249. package/modules/xlsx/parseSheetData.js +0 -55
  250. package/modules/xlsx/parseSheetData.js.map +0 -1
  251. package/modules/xlsx/reconstructSheetDimensionsFromSheetCells.js +0 -23
  252. package/modules/xlsx/reconstructSheetDimensionsFromSheetCells.js.map +0 -1
  253. package/modules/xml/parseXmlStream.saxen.code.js +0 -947
  254. package/modules/xml/parseXmlStream.saxen.code.js.map +0 -1
  255. package/modules/xml/parseXmlStream.test.js.map +0 -1
@@ -3,13 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.createInitialStateInCell = createInitialStateInCell;
6
+ exports.EMPTY_CELL = void 0;
7
7
  exports["default"] = parseCell;
8
- exports.onCloseTagInCell = onCloseTagInCell;
9
- exports.onOpenTagInCell = onOpenTagInCell;
10
- exports.onTextInCell = onTextInCell;
11
- var _parseCellValue = _interopRequireDefault(require("./parseCellValue.js"));
12
- var _parseCellAddress3 = _interopRequireDefault(require("./parseCellAddress.js"));
8
+ var _parseExcelTimestamp = _interopRequireDefault(require("./parseExcelTimestamp.js"));
9
+ var _isDateFormatStyle = _interopRequireDefault(require("./isDateFormatStyle.js"));
13
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
11
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
15
12
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -17,116 +14,256 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
17
14
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
18
15
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
19
16
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
- // Example of a `<c/>`ell element:
21
- //
22
- // <c>
23
- // <f>string</f> formula.
24
- // <v>string</v> formula pre-computed value.
25
- // <is>
26
- // <t>string</t> — an `inlineStr` string (rather than a "common string" from a dictionary).
27
- // <r>
28
- // <rPr>
29
- // ...
30
- // </rPr>
31
- // <t>string</t>
32
- // </r>
33
- // <rPh sb="1" eb="1">
34
- // <t>string</t>
35
- // </rPh>
36
- // <phoneticPr fontId="1"/>
37
- // </is>
38
- // <extLst>
39
- // <ext>
40
- // <!--any element-->
41
- // </ext>
42
- // </extLst>
43
- // </c>
44
- //
45
- function parseCell(attributes, value, inlineString, sharedStrings, styles, epoch1904, options) {
46
- var _parseCellAddress = (0, _parseCellAddress3["default"])(attributes.r),
47
- _parseCellAddress2 = _slicedToArray(_parseCellAddress, 2),
48
- row = _parseCellAddress2[0],
49
- column = _parseCellAddress2[1];
50
- var type = attributes.t;
51
- var styleId = attributes.s ? Number(attributes.s) : undefined;
52
- return {
53
- row: row,
54
- column: column,
55
- value: (0, _parseCellValue["default"])(value, type, {
56
- inlineString: inlineString,
57
- styleId: styleId,
58
- styles: styles,
59
- sharedStrings: sharedStrings,
60
- epoch1904: epoch1904,
61
- options: options
62
- })
63
- };
64
- }
65
- function createInitialStateInCell() {
66
- return {
67
- v: false,
68
- is: false,
69
- t: false,
70
- r: false,
71
- rPh: false,
72
- value: undefined,
73
- inlineString: undefined,
74
- attributes: undefined
75
- };
76
- }
77
- function onOpenTagInCell(tagName, attributes, state) {
78
- if (tagName === 'v') {
79
- state.v = true;
80
- } else if (tagName === 'is') {
81
- // The possible children of <is> are:
82
- // * <t> (Text): The standard child to hold plain, simple text.
83
- // * <r> (Rich Text Run): Used for applying different formatting styles (like bold or italic) to specific segments of text within a single cell.
84
- // * <rPh> (Phonetic Run): Used primarily for East Asian languages to provide phonetic reading/pronunciation data (e.g., furigana in Japanese). It associates a phonetic pronunciation run right alongside the base string text tag <t>.
85
- // * <phoneticPr> (Phonetic Properties): Defines formatting and settings for the phonetic text.
86
- state.is = true;
87
- state.inlineString = '';
88
- } else if (tagName === 't') {
89
- state.t = true;
90
- } else if (tagName === 'r') {
91
- // The possible children of <r/> are:
92
- // * <rPr> (Run Properties): The formatting properties for the text (font, size, color, bold, italic, etc.).
93
- // * <t> (Text): The actual text payload.
94
- // * <rPh> (Phonetic Run): Phonetic pronunciation guidance (used for East Asian languages like Japanese). It associates a phonetic pronunciation run right alongside the base string text tag <t>.
95
- state.r = true;
96
- } else if (tagName === 'rPh') {
97
- // The possible children of <rPh/> are:
98
- // * <t> (Text): Contains the actual phonetic text or reading (usually in Katakana for Japanese) that corresponds to the associated character string.
99
- state.rPh = true;
100
- }
101
- }
102
- function onCloseTagInCell(tagName, state) {
103
- if (tagName === 'v') {
104
- state.v = false;
105
- } else if (tagName === 'is') {
106
- state.is = false;
107
- } else if (tagName === 't') {
108
- state.t = false;
109
- } else if (tagName === 'r') {
110
- state.r = false;
111
- } else if (tagName === 'rPh') {
112
- state.rPh = false;
113
- }
114
- }
115
- function onTextInCell(text, state) {
116
- if (state.v) {
117
- state.value = text;
118
- } else if (state.is) {
119
- if (state.rPh) {
120
- // Ignore anything inside `<rPh/>` tags
121
- } else if (state.t) {
122
- if (state.r) {
123
- // An `<r/>` element could contain multiple `<t/>` elements,
124
- // the text content from all of which should be concatenated.
125
- state.inlineString += text;
126
- } else {
127
- state.inlineString = text;
17
+ // An empty cell has `null` value.
18
+ var EMPTY_CELL_VALUE = null;
19
+
20
+ // This variable represents a cell with a `null` value.
21
+ // It is exported only to be specified as a dependency when using `worker-f`.
22
+ var EMPTY_CELL = exports.EMPTY_CELL = [null, EMPTY_CELL_VALUE];
23
+
24
+ /**
25
+ * Parses a cell from the info extracted from XML.
26
+ * @param {string} [t] — `<c t/>` attribute value (cell type). One of: b (Boolean), e (Error), n (Number), d (Date), s (String).
27
+ * @param {string} [s] — `<c s/>` attribute value (formatting style ID). When present, should be a stringified zero-based index of the formatting style for a numberic cell.
28
+ * @param {string} [v] — `<v/>` element text content (value). Will be `undefined` if the `<v/>` element absent. Will be an empty string `""` if the `<v/>` element is present but is empty.
29
+ * @param {string} [inlineString] — Inline string value.
30
+ * @param {any[]} parameters
31
+ * @returns {[string|null,string|number|boolean|null] | string} Either `[type, value]` or `error`, where `value` is the cell value, `type` depends on the type of `value` and could be one of: 's' (string), 'b' (boolean), 'n' (number string), 'd' (date timestamp), 'e' (formula cell error), `null` (null); `error` is an error message: `VALUE_MISSING`, `VALUE_INVALID`, `FORMAT_INVALID`, `TYPE_INVALID`.
32
+ */
33
+ function parseCell(t, s, v, inlineString, _ref) {
34
+ var _ref2 = _slicedToArray(_ref, 6),
35
+ sharedStrings = _ref2[0],
36
+ styles = _ref2[1],
37
+ epoch1904 = _ref2[2],
38
+ defaultDateFormat = _ref2[3],
39
+ dateTemplateParser = _ref2[4],
40
+ parseNumberCustom = _ref2[5];
41
+ // Available Excel cell types:
42
+ // https://github.com/SheetJS/sheetjs/blob/19620da30be2a7d7b9801938a0b9b1fd3c4c4b00/docbits/52_datatype.md
43
+ //
44
+ // Some other document (seems to be old):
45
+ // http://webapp.docx4java.org/OnlineDemo/ecma376/SpreadsheetML/ST_CellType.html
46
+ //
47
+ // The default cell type is "n" (numeric), according to XLSX specification.
48
+ //
49
+ switch (t || 'n') {
50
+ // `t="str"` means that the cell value is calculated using a formula.
51
+ // The formula is defined as the text of a child `<f/>` element.
52
+ //
53
+ // It could optionally include a `<v/>` element whose text is the cached result
54
+ // of the calculation from the last time the file was saved in a spreadsheet editor application.
55
+ //
56
+ // An optional `<v/>` element holds a pre-computed result of the formula defined by `<f/>`.
57
+ //
58
+ // Example:
59
+ //
60
+ // <c r="B3" t="str">
61
+ // <f>CONCATENATE(C1,D1)</f>
62
+ // <v>C1ValueD1Value</v>
63
+ // </c>
64
+ //
65
+ // Here's a guide on formulas in XLSX files:
66
+ // https://github.com/MiniMax-AI/skills/blob/main/skills/minimax-xlsx/references/validate.md
67
+ //
68
+ case 'str':
69
+ // The `<v/>` element could be absent because it's not required to be pre-computed by the spec.
70
+ // In such case, `v` argument value would be `undefined`.
71
+ // Because this package can't include the whole formula calculation engine,
72
+ // it has to interpret this situation as an error.
73
+ if (v === undefined) {
74
+ return 'VALUE_MISSING';
75
+ }
76
+ // The `<v/>` element could be present but its text content could be empty
77
+ // because the formula returns an empty string.
78
+ // For example, a valid case of `v` argument value being an empty string `""` is when
79
+ // a formula in cell `A1` is `=CONCATENATE(B1,C1)` and both `B1` and `C1` cells are empty.
80
+ if (!v) {
81
+ return EMPTY_CELL;
82
+ }
83
+ return ['s', v];
84
+
85
+ // `t="inlineStr"` means that `<is/>` holds the string value.
86
+ //
87
+ // Inside a `<c t="inlineStr"/>`, the specification requires there to exist an `<is/>` element,
88
+ // and within that `<is/>` element it requires to exist a `<t/>` element.
89
+ //
90
+ // Example:
91
+ //
92
+ // <c r="A1" s="1" t="inlineStr">
93
+ // <is>
94
+ // <t>
95
+ // Test 123
96
+ // </t>
97
+ // </is>
98
+ // </c>
99
+ //
100
+ case 'inlineStr':
101
+ if (inlineString === undefined) {
102
+ return 'VALUE_MISSING';
103
+ }
104
+ return ['s', inlineString];
105
+
106
+ // `type="s"` means that the string value is stored in the Shared Strings Table.
107
+ // This way it attempts to compress the `.xlsx` file by reusing all string values
108
+ // in case they repeat throughout the spreadsheet.
109
+ //
110
+ // This optimization can't be used when writing an `.xlsx` file in a "streaming"
111
+ // fashion, i.e. when the entire spreadsheet data is not known in adavance
112
+ // at the start of writing the file.
113
+ // But it can be used in all other situations. And hence, it is used.
114
+ // So this is the most common cell type, actually.
115
+ //
116
+ // Example:
117
+ //
118
+ // <c r="A3" t="s">
119
+ // <v>3</v>
120
+ // </c>
121
+ //
122
+ case 's':
123
+ // If a cell has no value then there's no `<c/>` element for it.
124
+ // If a `<c/>` element exists then it's not empty.
125
+ // The `<v/>` element's text is a zero-based index in the "shared strings" dictionary.
126
+ if (!v) {
127
+ return 'VALUE_MISSING';
128
+ }
129
+ var sharedStringIndex = Number(v);
130
+ // The shared string index value could be:
131
+ // * not a number
132
+ // * a number but a fractional one
133
+ // * an integer that is out of bounds of the shared strings array
134
+ if (isNaN(sharedStringIndex) || sharedStrings[sharedStringIndex] === undefined) {
135
+ return 'VALUE_INVALID';
136
+ }
137
+ return ['s', sharedStrings[sharedStringIndex]];
138
+
139
+ // Boolean (TRUE/FALSE) values are stored as either "1" or "0" in cells of type "b".
140
+ //
141
+ // Example:
142
+ //
143
+ // <c r="A1" t="b">
144
+ // <v>1</v>
145
+ // </c>
146
+ //
147
+ case 'b':
148
+ if (!v) {
149
+ return 'VALUE_MISSING';
150
+ }
151
+ if (v === '1') {
152
+ return ['b', true];
153
+ }
154
+ if (v === '0') {
155
+ return ['b', false];
156
+ }
157
+ return 'VALUE_INVALID';
158
+
159
+ // If cell type is "e", the `<v/>` element's text is an error code string (required).
160
+ //
161
+ // Example:
162
+ //
163
+ // <c r="A1" t="e">
164
+ // <f>1/0</f>
165
+ // <v>#DIV/0!</v>
166
+ // </c>
167
+ //
168
+ case 'e':
169
+ // Examples of error codes:
170
+ //
171
+ // '#NULL!'
172
+ // '#DIV/0!'
173
+ // '#VALUE!'
174
+ // '#REF!'
175
+ // '#NAME!'
176
+ // '#NUM!'
177
+ // '#N/A'
178
+ // '#SPILL!'
179
+ //
180
+ // The description of each error could be read in the formulas guide:
181
+ // https://github.com/MiniMax-AI/skills/blob/main/skills/minimax-xlsx/references/validate.md
182
+ //
183
+ if (!v) {
184
+ return 'VALUE_MISSING';
185
+ }
186
+ return ['e', v];
187
+
188
+ // XLSX supports date cells of type "d", though it seems like it (almost?) never
189
+ // uses type "d" for storing dates, preferring type "n" and numeric timestamp instead.
190
+ // The value of a "d" cell is supposedly a string in "ISO 8601" format.
191
+ // I haven't seen an `.xlsx` file having such cells.
192
+ //
193
+ // Example:
194
+ //
195
+ // <c r="A1" s="1" t="d">
196
+ // <v>
197
+ // 2021-06-10T00:47:45.700Z
198
+ // </v>
199
+ // </c>
200
+ //
201
+ case 'd':
202
+ if (!v) {
203
+ return EMPTY_CELL;
204
+ }
205
+ var parsedDate = new Date(v);
206
+ if (isNaN(parsedDate.valueOf())) {
207
+ return 'VALUE_INVALID';
208
+ }
209
+ return ['d', parsedDate.getTime()];
210
+
211
+ // type "n" is used for numeric cells.
212
+ //
213
+ // An optional `s` attribute defines how this number should be formatted — 
214
+ // it should be a zero-based index of the style (XF record) in `styles.xml`.
215
+ //
216
+ // Example:
217
+ //
218
+ // <c r="A1" s="1" t="n">
219
+ // <v>123.45</v>
220
+ // </c>
221
+ //
222
+ case 'n':
223
+ // Numeric cell value is allowed to be missing in the XLSX specification
224
+ // because "n" is the default type of a cell, so it ends up representing empty cells too.
225
+ if (!v) {
226
+ return EMPTY_CELL;
227
+ }
228
+ // XLSX does support `type: "d"` cells for storing dates, but it's not commonly used.
229
+ // Instead, it prefers using `type: "n"` cells for storing dates as timestamps
230
+ // with a corresponding `s` formatting style.
231
+ if (s) {
232
+ var styleId = Number(s);
233
+ // The style ID value could be:
234
+ // * not a number
235
+ // * a number but a fractional one
236
+ // * an integer that is out of bounds of the styles array
237
+ if (isNaN(styleId) || styles[styleId] === undefined) {
238
+ return 'FORMAT_INVALID';
239
+ }
240
+ // Whether it's a date cell or just a numeric cell could only be determined
241
+ // by looking at the formatting style.
242
+ if ((0, _isDateFormatStyle["default"])(styles[styleId], defaultDateFormat, dateTemplateParser)) {
243
+ var timestamp = Number(v);
244
+ if (isNaN(timestamp)) {
245
+ return 'VALUE_INVALID';
246
+ }
247
+ // First, parse the "serial date" number from string.
248
+ // Then convert the "serial date" number to a date timestamp.
249
+ return ['d', (0, _parseExcelTimestamp["default"])(timestamp, epoch1904)];
250
+ }
251
+ }
252
+ // Return the cell value as a number,
253
+ // unless custom `parseNumber()` function was passed,
254
+ // in which case return the number as an unparsed string.
255
+ // Some people prefer passing a custom `parseNumber()` function
256
+ // to parse "big integers" without losing any precision.
257
+ if (parseNumberCustom) {
258
+ return ['n', v];
259
+ }
260
+ var number = Number(v);
261
+ if (isNaN(number)) {
262
+ return 'VALUE_INVALID';
128
263
  }
129
- }
264
+ return ['n', number];
265
+ default:
266
+ return 'TYPE_INVALID';
130
267
  }
131
268
  }
132
269
  //# sourceMappingURL=parseCell.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseCell.js","names":["_parseCellValue","_interopRequireDefault","require","_parseCellAddress3","obj","__esModule","_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","o","minLen","_arrayLikeToArray","n","Object","prototype","toString","call","slice","constructor","name","Array","from","test","len","length","arr2","r","l","t","Symbol","iterator","e","u","a","f","next","done","push","value","isArray","parseCell","attributes","inlineString","sharedStrings","styles","epoch1904","options","_parseCellAddress","parseCellAddress","_parseCellAddress2","row","column","type","styleId","s","Number","undefined","parseCellValue","createInitialStateInCell","v","is","rPh","onOpenTagInCell","tagName","state","onCloseTagInCell","onTextInCell","text"],"sources":["../../source/xlsx/parseCell.js"],"sourcesContent":["import parseCellValue from './parseCellValue.js'\r\nimport parseCellAddress from './parseCellAddress.js'\r\n\r\n// Example of a `<c/>`ell element:\r\n//\r\n// <c>\r\n// <f>string</f> — formula.\r\n// <v>string</v> — formula pre-computed value.\r\n// <is>\r\n// <t>string</t> — an `inlineStr` string (rather than a \"common string\" from a dictionary).\r\n// <r>\r\n// <rPr>\r\n// ...\r\n// </rPr>\r\n// <t>string</t>\r\n// </r>\r\n// <rPh sb=\"1\" eb=\"1\">\r\n// <t>string</t>\r\n// </rPh>\r\n// <phoneticPr fontId=\"1\"/>\r\n// </is>\r\n// <extLst>\r\n// <ext>\r\n// <!--any element-->\r\n// </ext>\r\n// </extLst>\r\n// </c>\r\n//\r\nexport default function parseCell(\r\n attributes,\r\n value,\r\n inlineString,\r\n sharedStrings,\r\n styles,\r\n epoch1904,\r\n options\r\n) {\r\n const [row, column] = parseCellAddress(attributes.r)\r\n const type = attributes.t\r\n const styleId = attributes.s ? Number(attributes.s) : undefined\r\n\r\n return {\r\n row,\r\n column,\r\n value: parseCellValue(value, type, {\r\n inlineString,\r\n styleId,\r\n styles,\r\n sharedStrings,\r\n epoch1904,\r\n options\r\n })\r\n }\r\n}\r\n\r\nexport function createInitialStateInCell() {\r\n return {\r\n v: false,\r\n is: false,\r\n t: false,\r\n r: false,\r\n rPh: false,\r\n value: undefined,\r\n inlineString: undefined,\r\n attributes: undefined\r\n }\r\n}\r\n\r\nexport function onOpenTagInCell(tagName, attributes, state) {\r\n if (tagName === 'v') {\r\n state.v = true\r\n } else if (tagName === 'is') {\r\n // The possible children of <is> are:\r\n // * <t> (Text): The standard child to hold plain, simple text.\r\n // * <r> (Rich Text Run): Used for applying different formatting styles (like bold or italic) to specific segments of text within a single cell.\r\n // * <rPh> (Phonetic Run): Used primarily for East Asian languages to provide phonetic reading/pronunciation data (e.g., furigana in Japanese). It associates a phonetic pronunciation run right alongside the base string text tag <t>.\r\n // * <phoneticPr> (Phonetic Properties): Defines formatting and settings for the phonetic text.\r\n state.is = true\r\n state.inlineString = ''\r\n } else if (tagName === 't') {\r\n state.t = true\r\n } else if (tagName === 'r') {\r\n // The possible children of <r/> are:\r\n // * <rPr> (Run Properties): The formatting properties for the text (font, size, color, bold, italic, etc.).\r\n // * <t> (Text): The actual text payload.\r\n // * <rPh> (Phonetic Run): Phonetic pronunciation guidance (used for East Asian languages like Japanese). It associates a phonetic pronunciation run right alongside the base string text tag <t>.\r\n state.r = true\r\n } else if (tagName === 'rPh') {\r\n // The possible children of <rPh/> are:\r\n // * <t> (Text): Contains the actual phonetic text or reading (usually in Katakana for Japanese) that corresponds to the associated character string.\r\n state.rPh = true\r\n }\r\n}\r\n\r\nexport function onCloseTagInCell(tagName, state) {\r\n if (tagName === 'v') {\r\n state.v = false\r\n } else if (tagName === 'is') {\r\n state.is = false\r\n } else if (tagName === 't') {\r\n state.t = false\r\n } else if (tagName === 'r') {\r\n state.r = false\r\n } else if (tagName === 'rPh') {\r\n state.rPh = false\r\n }\r\n}\r\n\r\nexport function onTextInCell(text, state) {\r\n if (state.v) {\r\n state.value = text\r\n } else if (state.is) {\r\n if (state.rPh) {\r\n // Ignore anything inside `<rPh/>` tags\r\n } else if (state.t) {\r\n if (state.r) {\r\n // An `<r/>` element could contain multiple `<t/>` elements,\r\n // the text content from all of which should be concatenated.\r\n state.inlineString += text\r\n } else {\r\n state.inlineString = text\r\n }\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAoD,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,I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G,KAAK;EACjB,CAAC,MAAM,IAAII,OAAO,KAAK,IAAI,EAAE;IAC3BC,KAAK,CAACJ,EAAE,GAAG,KAAK;EAClB,CAAC,MAAM,IAAIG,OAAO,KAAK,GAAG,EAAE;IAC1BC,KAAK,CAACpC,CAAC,GAAG,KAAK;EACjB,CAAC,MAAM,IAAImC,OAAO,KAAK,GAAG,EAAE;IAC1BC,KAAK,CAACtC,CAAC,GAAG,KAAK;EACjB,CAAC,MAAM,IAAIqC,OAAO,KAAK,KAAK,EAAE;IAC5BC,KAAK,CAACH,GAAG,GAAG,KAAK;EACnB;AACF;AAEO,SAASK,YAAYA,CAACC,IAAI,EAAEH,KAAK,EAAE;EACxC,IAAIA,KAAK,CAACL,CAAC,EAAE;IACXK,KAAK,CAAC1B,KAAK,GAAG6B,IAAI;EACpB,CAAC,MAAM,IAAIH,KAAK,CAACJ,EAAE,EAAE;IACnB,IAAII,KAAK,CAACH,GAAG,EAAE;MACb;IAAA,CACD,MAAM,IAAIG,KAAK,CAACpC,CAAC,EAAE;MAClB,IAAIoC,KAAK,CAACtC,CAAC,EAAE;QACX;QACA;QACAsC,KAAK,CAACtB,YAAY,IAAIyB,IAAI;MAC5B,CAAC,MAAM;QACLH,KAAK,CAACtB,YAAY,GAAGyB,IAAI;MAC3B;IACF;EACF;AACF"}
1
+ {"version":3,"file":"parseCell.js","names":["_parseExcelTimestamp","_interopRequireDefault","require","_isDateFormatStyle","obj","__esModule","_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","o","minLen","_arrayLikeToArray","n","Object","prototype","toString","call","slice","constructor","name","Array","from","test","len","length","arr2","r","l","t","Symbol","iterator","e","u","a","f","next","done","push","value","isArray","EMPTY_CELL_VALUE","EMPTY_CELL","exports","parseCell","s","v","inlineString","_ref","_ref2","sharedStrings","styles","epoch1904","defaultDateFormat","dateTemplateParser","parseNumberCustom","undefined","sharedStringIndex","Number","isNaN","parsedDate","Date","valueOf","getTime","styleId","isDateFormatStyle","timestamp","parseExcelTimestamp","number"],"sources":["../../source/xlsx/parseCell.js"],"sourcesContent":["import parseExcelTimestamp from './parseExcelTimestamp.js'\r\nimport isDateFormatStyle from './isDateFormatStyle.js'\r\n\r\n// An empty cell has `null` value.\r\nconst EMPTY_CELL_VALUE = null\r\n\r\n// This variable represents a cell with a `null` value.\r\n// It is exported only to be specified as a dependency when using `worker-f`.\r\nexport const EMPTY_CELL = [null, EMPTY_CELL_VALUE]\r\n\r\n/**\r\n * Parses a cell from the info extracted from XML.\r\n * @param {string} [t] — `<c t/>` attribute value (cell type). One of: b (Boolean), e (Error), n (Number), d (Date), s (String).\r\n * @param {string} [s] — `<c s/>` attribute value (formatting style ID). When present, should be a stringified zero-based index of the formatting style for a numberic cell.\r\n * @param {string} [v] — `<v/>` element text content (value). Will be `undefined` if the `<v/>` element absent. Will be an empty string `\"\"` if the `<v/>` element is present but is empty.\r\n * @param {string} [inlineString] — Inline string value.\r\n * @param {any[]} parameters\r\n * @returns {[string|null,string|number|boolean|null] | string} Either `[type, value]` or `error`, where `value` is the cell value, `type` depends on the type of `value` and could be one of: 's' (string), 'b' (boolean), 'n' (number string), 'd' (date timestamp), 'e' (formula cell error), `null` (null); `error` is an error message: `VALUE_MISSING`, `VALUE_INVALID`, `FORMAT_INVALID`, `TYPE_INVALID`.\r\n */\r\nexport default function parseCell(\r\n t,\r\n s,\r\n v,\r\n inlineString,\r\n [\r\n sharedStrings,\r\n styles,\r\n epoch1904,\r\n defaultDateFormat,\r\n dateTemplateParser,\r\n parseNumberCustom\r\n ]\r\n) {\r\n // Available Excel cell types:\r\n // https://github.com/SheetJS/sheetjs/blob/19620da30be2a7d7b9801938a0b9b1fd3c4c4b00/docbits/52_datatype.md\r\n //\r\n // Some other document (seems to be old):\r\n // http://webapp.docx4java.org/OnlineDemo/ecma376/SpreadsheetML/ST_CellType.html\r\n //\r\n // The default cell type is \"n\" (numeric), according to XLSX specification.\r\n //\r\n switch (t || 'n') {\r\n // `t=\"str\"` means that the cell value is calculated using a formula.\r\n // The formula is defined as the text of a child `<f/>` element.\r\n //\r\n // It could optionally include a `<v/>` element whose text is the cached result\r\n // of the calculation from the last time the file was saved in a spreadsheet editor application.\r\n //\r\n // An optional `<v/>` element holds a pre-computed result of the formula defined by `<f/>`.\r\n //\r\n // Example:\r\n //\r\n // <c r=\"B3\" t=\"str\">\r\n // \t<f>CONCATENATE(C1,D1)</f>\r\n // \t<v>C1ValueD1Value</v>\r\n // </c>\r\n //\r\n // Here's a guide on formulas in XLSX files:\r\n // https://github.com/MiniMax-AI/skills/blob/main/skills/minimax-xlsx/references/validate.md\r\n //\r\n case 'str':\r\n // The `<v/>` element could be absent because it's not required to be pre-computed by the spec.\r\n // In such case, `v` argument value would be `undefined`.\r\n // Because this package can't include the whole formula calculation engine,\r\n // it has to interpret this situation as an error.\r\n if (v === undefined) {\r\n return 'VALUE_MISSING'\r\n }\r\n // The `<v/>` element could be present but its text content could be empty\r\n // because the formula returns an empty string.\r\n // For example, a valid case of `v` argument value being an empty string `\"\"` is when\r\n // a formula in cell `A1` is `=CONCATENATE(B1,C1)` and both `B1` and `C1` cells are empty.\r\n if (!v) {\r\n return EMPTY_CELL\r\n }\r\n return ['s', v]\r\n\r\n // `t=\"inlineStr\"` means that `<is/>` holds the string value.\r\n //\r\n // Inside a `<c t=\"inlineStr\"/>`, the specification requires there to exist an `<is/>` element,\r\n // and within that `<is/>` element it requires to exist a `<t/>` element.\r\n //\r\n // Example:\r\n //\r\n // <c r=\"A1\" s=\"1\" t=\"inlineStr\">\r\n // <is>\r\n // <t>\r\n // Test 123\r\n // </t>\r\n // </is>\r\n // </c>\r\n //\r\n case 'inlineStr':\r\n if (inlineString === undefined) {\r\n return 'VALUE_MISSING'\r\n }\r\n return ['s', inlineString]\r\n\r\n // `type=\"s\"` means that the string value is stored in the Shared Strings Table.\r\n // This way it attempts to compress the `.xlsx` file by reusing all string values\r\n // in case they repeat throughout the spreadsheet.\r\n //\r\n // This optimization can't be used when writing an `.xlsx` file in a \"streaming\"\r\n // fashion, i.e. when the entire spreadsheet data is not known in adavance\r\n // at the start of writing the file.\r\n // But it can be used in all other situations. And hence, it is used.\r\n // So this is the most common cell type, actually.\r\n //\r\n // Example:\r\n //\r\n // <c r=\"A3\" t=\"s\">\r\n // <v>3</v>\r\n // </c>\r\n //\r\n case 's':\r\n // If a cell has no value then there's no `<c/>` element for it.\r\n // If a `<c/>` element exists then it's not empty.\r\n // The `<v/>` element's text is a zero-based index in the \"shared strings\" dictionary.\r\n if (!v) {\r\n return 'VALUE_MISSING'\r\n }\r\n const sharedStringIndex = Number(v)\r\n // The shared string index value could be:\r\n // * not a number\r\n // * a number but a fractional one\r\n // * an integer that is out of bounds of the shared strings array\r\n if (isNaN(sharedStringIndex) || sharedStrings[sharedStringIndex] === undefined) {\r\n return 'VALUE_INVALID'\r\n }\r\n return ['s', sharedStrings[sharedStringIndex]]\r\n\r\n // Boolean (TRUE/FALSE) values are stored as either \"1\" or \"0\" in cells of type \"b\".\r\n //\r\n // Example:\r\n //\r\n // <c r=\"A1\" t=\"b\">\r\n // <v>1</v>\r\n // </c>\r\n //\r\n case 'b':\r\n if (!v) {\r\n return 'VALUE_MISSING'\r\n }\r\n if (v === '1') {\r\n return ['b', true]\r\n }\r\n if (v === '0') {\r\n return ['b', false]\r\n }\r\n return 'VALUE_INVALID'\r\n\r\n // If cell type is \"e\", the `<v/>` element's text is an error code string (required).\r\n //\r\n // Example:\r\n //\r\n // <c r=\"A1\" t=\"e\">\r\n // <f>1/0</f>\r\n // <v>#DIV/0!</v>\r\n // </c>\r\n //\r\n case 'e':\r\n // Examples of error codes:\r\n //\r\n // '#NULL!'\r\n // '#DIV/0!'\r\n // '#VALUE!'\r\n // '#REF!'\r\n // '#NAME!'\r\n // '#NUM!'\r\n // '#N/A'\r\n // '#SPILL!'\r\n //\r\n // The description of each error could be read in the formulas guide:\r\n // https://github.com/MiniMax-AI/skills/blob/main/skills/minimax-xlsx/references/validate.md\r\n //\r\n if (!v) {\r\n return 'VALUE_MISSING'\r\n }\r\n return ['e', v]\r\n\r\n // XLSX supports date cells of type \"d\", though it seems like it (almost?) never\r\n // uses type \"d\" for storing dates, preferring type \"n\" and numeric timestamp instead.\r\n // The value of a \"d\" cell is supposedly a string in \"ISO 8601\" format.\r\n // I haven't seen an `.xlsx` file having such cells.\r\n //\r\n // Example:\r\n //\r\n // <c r=\"A1\" s=\"1\" t=\"d\">\r\n // <v>\r\n // 2021-06-10T00:47:45.700Z\r\n // </v>\r\n // </c>\r\n //\r\n case 'd':\r\n if (!v) {\r\n return EMPTY_CELL\r\n }\r\n const parsedDate = new Date(v)\r\n if (isNaN(parsedDate.valueOf())) {\r\n return 'VALUE_INVALID'\r\n }\r\n return ['d', parsedDate.getTime()]\r\n\r\n // type \"n\" is used for numeric cells.\r\n //\r\n // An optional `s` attribute defines how this number should be formatted — \r\n // it should be a zero-based index of the style (XF record) in `styles.xml`.\r\n //\r\n // Example:\r\n //\r\n // <c r=\"A1\" s=\"1\" t=\"n\">\r\n // <v>123.45</v>\r\n // </c>\r\n //\r\n case 'n':\r\n // Numeric cell value is allowed to be missing in the XLSX specification\r\n // because \"n\" is the default type of a cell, so it ends up representing empty cells too.\r\n if (!v) {\r\n return EMPTY_CELL\r\n }\r\n // XLSX does support `type: \"d\"` cells for storing dates, but it's not commonly used.\r\n // Instead, it prefers using `type: \"n\"` cells for storing dates as timestamps\r\n // with a corresponding `s` formatting style.\r\n if (s) {\r\n const styleId = Number(s)\r\n // The style ID value could be:\r\n // * not a number\r\n // * a number but a fractional one\r\n // * an integer that is out of bounds of the styles array\r\n if (isNaN(styleId) || styles[styleId] === undefined) {\r\n return 'FORMAT_INVALID'\r\n }\r\n // Whether it's a date cell or just a numeric cell could only be determined\r\n // by looking at the formatting style.\r\n if (isDateFormatStyle(styles[styleId], defaultDateFormat, dateTemplateParser)) {\r\n const timestamp = Number(v)\r\n if (isNaN(timestamp)) {\r\n return 'VALUE_INVALID'\r\n }\r\n // First, parse the \"serial date\" number from string.\r\n // Then convert the \"serial date\" number to a date timestamp.\r\n return ['d', parseExcelTimestamp(timestamp, epoch1904)]\r\n }\r\n }\r\n // Return the cell value as a number,\r\n // unless custom `parseNumber()` function was passed,\r\n // in which case return the number as an unparsed string.\r\n // Some people prefer passing a custom `parseNumber()` function\r\n // to parse \"big integers\" without losing any precision.\r\n if (parseNumberCustom) {\r\n return ['n', v]\r\n }\r\n const number = Number(v)\r\n if (isNaN(number)) {\r\n return 'VALUE_INVALID'\r\n }\r\n return ['n', number]\r\n\r\n default:\r\n return 'TYPE_INVALID'\r\n }\r\n}"],"mappings":";;;;;;;AAAA,IAAAA,oBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAsD,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAAA,SAAAE,eAAAC,GAAA,EAAAC,CAAA,WAAAC,eAAA,CAAAF,GAAA,KAAAG,qBAAA,CAAAH,GAAA,EAAAC,CAAA,KAAAG,2BAAA,CAAAJ,GAAA,EAAAC,CAAA,KAAAI,gBAAA;AAAA,SAAAA,iBAAA,cAAAC,SAAA;AAAA,SAAAF,4BAAAG,CAAA,EAAAC,MAAA,SAAAD,CAAA,qBAAAA,CAAA,sBAAAE,iBAAA,CAAAF,CAAA,EAAAC,MAAA,OAAAE,CAAA,GAAAC,MAAA,CAAAC,SAAA,CAAAC,QAAA,CAAAC,IAAA,CAAAP,CAAA,EAAAQ,KAAA,aAAAL,CAAA,iBAAAH,CAAA,CAAAS,WAAA,EAAAN,CAAA,GAAAH,CAAA,CAAAS,WAAA,CAAAC,IAAA,MAAAP,CAAA,cAAAA,CAAA,mBAAAQ,KAAA,CAAAC,IAAA,CAAAZ,CAAA,OAAAG,CAAA,+DAAAU,IAAA,CAAAV,CAAA,UAAAD,iBAAA,CAAAF,C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7B;AACA;AACO,IAAMC,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,CAAC,IAAI,EAAED,gBAAgB,CAAC;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASG,SAASA,CAC/Bf,CAAC,EACDgB,CAAC,EACDC,CAAC,EACDC,YAAY,EAAAC,IAAA,EASZ;EAAA,IAAAC,KAAA,GAAA/C,cAAA,CAAA8C,IAAA;IAPEE,aAAa,GAAAD,KAAA;IACbE,MAAM,GAAAF,KAAA;IACNG,SAAS,GAAAH,KAAA;IACTI,iBAAiB,GAAAJ,KAAA;IACjBK,kBAAkB,GAAAL,KAAA;IAClBM,iBAAiB,GAAAN,KAAA;EAGnB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,QAAQpB,CAAC,IAAI,GAAG;IACd;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAK,KAAK;MACR;MACA;MACA;MACA;MACA,IAAIiB,CAAC,KAAKU,SAAS,EAAE;QACnB,OAAO,eAAe;MACxB;MACA;MACA;MACA;MACA;MACA,IAAI,CAACV,CAAC,EAAE;QACN,OAAOJ,UAAU;MACnB;MACA,OAAO,CAAC,GAAG,EAAEI,CAAC,CAAC;;IAEjB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAK,WAAW;MACd,IAAIC,YAAY,KAAKS,SAAS,EAAE;QAC9B,OAAO,eAAe;MACxB;MACA,OAAO,CAAC,GAAG,EAAET,YAAY,CAAC;;IAE5B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAK,GAAG;MACN;MACA;MACA;MACA,IAAI,CAACD,CAAC,EAAE;QACN,OAAO,eAAe;MACxB;MACA,IAAMW,iBAAiB,GAAGC,MAAM,CAACZ,CAAC,CAAC;MACnC;MAC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,EAAE;QACL,IAAMmB,OAAO,GAAGN,MAAM,CAACb,CAAC,CAAC;QACzB;QACA;QACA;QACA;QACA,IAAIc,KAAK,CAACK,OAAO,CAAC,IAAIb,MAAM,CAACa,OAAO,CAAC,KAAKR,SAAS,EAAE;UACnD,OAAO,gBAAgB;QACzB;QACA;QACA;QACA,IAAI,IAAAS,6BAAiB,EAACd,MAAM,CAACa,OAAO,CAAC,EAAEX,iBAAiB,EAAEC,kBAAkB,CAAC,EAAE;UAC7E,IAAMY,SAAS,GAAGR,MAAM,CAACZ,CAAC,CAAC;UAC3B,IAAIa,KAAK,CAACO,SAAS,CAAC,EAAE;YACpB,OAAO,eAAe;UACxB;UACA;UACA;UACA,OAAO,CAAC,GAAG,EAAE,IAAAC,+BAAmB,EAACD,SAAS,EAAEd,SAAS,CAAC,CAAC;QACzD;MACF;MACA;MACA;MACA;MACA;MACA;MACA,IAAIG,iBAAiB,EAAE;QACrB,OAAO,CAAC,GAAG,EAAET,CAAC,CAAC;MACjB;MACA,IAAMsB,MAAM,GAAGV,MAAM,CAACZ,CAAC,CAAC;MACxB,IAAIa,KAAK,CAACS,MAAM,CAAC,EAAE;QACjB,OAAO,eAAe;MACxB;MACA,OAAO,CAAC,GAAG,EAAEA,MAAM,CAAC;IAEtB;MACE,OAAO,cAAc;EACzB;AACF"}
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.LETTERS = void 0;
6
7
  exports["default"] = parseCellAddress;
7
8
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
9
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -19,24 +20,15 @@ function parseCellAddress(coordinatesString) {
19
20
  // Coordinate examples: "AA2091", "R988", "B1".
20
21
  var _coordinatesString$sp = coordinatesString.split(/(\d+)/),
21
22
  _coordinatesString$sp2 = _slicedToArray(_coordinatesString$sp, 2),
22
- column = _coordinatesString$sp2[0],
23
- row = _coordinatesString$sp2[1];
24
- return [
25
- // Row number (starting at `1`).
26
- Number(row),
27
- // Column number (starting at `1`).
28
- // It's not clear if the `column` part could ever be non-trimmed,
29
- // but this `.trim()` call was already here when I copied this code from somewhere.
30
- getColumnNumberFromColumnLetters(column.trim())];
31
- }
32
-
33
- // Maps "A1"-like coordinates to `{ row, column }` numeric coordinates.
34
- var LETTERS = ['', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
23
+ columnLetters = _coordinatesString$sp2[0],
24
+ rowNumberString = _coordinatesString$sp2[1];
35
25
 
36
- // Converts a letter coordinate to a digit coordinate.
37
- // Examples: "A" -> 1, "B" -> 2, "Z" -> 26, "AA" -> 27, etc.
38
- function getColumnNumberFromColumnLetters(columnLetters) {
39
- // `for ... of ...` would require Babel polyfill for iterating a string.
26
+ // Converts a letter coordinate to a digit coordinate.
27
+ // Examples: "A" -> 1, "B" -> 2, "Z" -> 26, "AA" -> 27, etc.
28
+ //
29
+ // This function is inlined only to avoid passing it in `worker-f` dependencies.
30
+ // Otherwise, it would throw: "getColumnNumberFromColumnLetters is not defined".
31
+ //
40
32
  var n = 0;
41
33
  var i = 0;
42
34
  while (i < columnLetters.length) {
@@ -44,6 +36,18 @@ function getColumnNumberFromColumnLetters(columnLetters) {
44
36
  n += LETTERS.indexOf(columnLetters[i]);
45
37
  i++;
46
38
  }
47
- return n;
39
+ var columnNumberFromColumnLetters = n;
40
+ return [
41
+ // Row number (starting at `1`).
42
+ Number(rowNumberString),
43
+ // Column number (starting at `1`).
44
+ columnNumberFromColumnLetters];
48
45
  }
46
+
47
+ // Maps "A1"-like coordinates to `{ row, column }` numeric coordinates.
48
+ //
49
+ // This is `export`ed only to be passed in `worker-f` dependencies.
50
+ // Otherwise, it would throw: "LETTERS is not defined".
51
+ //
52
+ var LETTERS = exports.LETTERS = ['', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
49
53
  //# sourceMappingURL=parseCellAddress.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseCellAddress.js","names":["parseCellAddress","coordinatesString","_coordinatesString$sp","split","_coordinatesString$sp2","_slicedToArray","column","row","Number","getColumnNumberFromColumnLetters","trim","LETTERS","columnLetters","n","i","length","indexOf"],"sources":["../../source/xlsx/parseCellAddress.js"],"sourcesContent":["/**\r\n * Parses XLSX cell address into a row number and a column number.\r\n * @param {string} coordinatesString\r\n * @returns {number[]} Returns `[rowNumber, columnNumber]`\r\n */\r\nexport default function parseCellAddress(coordinatesString) {\r\n // Coordinate examples: \"AA2091\", \"R988\", \"B1\".\r\n const [column, row] = coordinatesString.split(/(\\d+)/)\r\n return [\r\n // Row number (starting at `1`).\r\n Number(row),\r\n // Column number (starting at `1`).\r\n\t\t// It's not clear if the `column` part could ever be non-trimmed,\r\n\t\t// but this `.trim()` call was already here when I copied this code from somewhere.\r\n getColumnNumberFromColumnLetters(column.trim())\r\n ]\r\n}\r\n\r\n// Maps \"A1\"-like coordinates to `{ row, column }` numeric coordinates.\r\nconst LETTERS = ['', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']\r\n\r\n// Converts a letter coordinate to a digit coordinate.\r\n// Examples: \"A\" -> 1, \"B\" -> 2, \"Z\" -> 26, \"AA\" -> 27, etc.\r\nfunction getColumnNumberFromColumnLetters(columnLetters) {\r\n // `for ... of ...` would require Babel polyfill for iterating a string.\r\n let n = 0\r\n let i = 0\r\n while (i < columnLetters.length) {\r\n n *= 26\r\n n += LETTERS.indexOf(columnLetters[i])\r\n i++\r\n }\r\n return n\r\n}\r\n"],"mappings":";;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACe,SAASA,gBAAgBA,CAACC,iBAAiB,EAAE;EAC1D;EACA,IAAAC,qBAAA,GAAsBD,iBAAiB,CAACE,KAAK,CAAC,OAAO,CAAC;IAAAC,sBAAA,GAAAC,cAAA,CAAAH,qBAAA;IAA/CI,MAAM,GAAAF,sBAAA;IAAEG,GAAG,GAAAH,sBAAA;EAClB,OAAO;EACL;EACAI,MAAM,CAACD,GAAG,CAAC;EACX;EACF;EACA;EACEE,gCAAgC,CAACH,MAAM,CAACI,IAAI,CAAC,CAAC,CAAC,CAChD;AACH;;AAEA;AACA,IAAMC,OAAO,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;;AAEtJ;AACA;AACA,SAASF,gCAAgCA,CAACG,aAAa,EAAE;EACvD;EACA,IAAIC,CAAC,GAAG,CAAC;EACT,IAAIC,CAAC,GAAG,CAAC;EACT,OAAOA,CAAC,GAAGF,aAAa,CAACG,MAAM,EAAE;IAC/BF,CAAC,IAAI,EAAE;IACPA,CAAC,IAAIF,OAAO,CAACK,OAAO,CAACJ,aAAa,CAACE,CAAC,CAAC,CAAC;IACtCA,CAAC,EAAE;EACL;EACA,OAAOD,CAAC;AACV"}
1
+ {"version":3,"file":"parseCellAddress.js","names":["parseCellAddress","coordinatesString","_coordinatesString$sp","split","_coordinatesString$sp2","_slicedToArray","columnLetters","rowNumberString","n","i","length","LETTERS","indexOf","columnNumberFromColumnLetters","Number","exports"],"sources":["../../source/xlsx/parseCellAddress.js"],"sourcesContent":["/**\r\n * Parses XLSX cell address into a row number and a column number.\r\n * @param {string} coordinatesString\r\n * @returns {number[]} Returns `[rowNumber, columnNumber]`\r\n */\r\nexport default function parseCellAddress(coordinatesString) {\r\n // Coordinate examples: \"AA2091\", \"R988\", \"B1\".\r\n const [columnLetters, rowNumberString] = coordinatesString.split(/(\\d+)/)\r\n\r\n // Converts a letter coordinate to a digit coordinate.\r\n // Examples: \"A\" -> 1, \"B\" -> 2, \"Z\" -> 26, \"AA\" -> 27, etc.\r\n //\r\n // This function is inlined only to avoid passing it in `worker-f` dependencies.\r\n // Otherwise, it would throw: \"getColumnNumberFromColumnLetters is not defined\".\r\n //\r\n let n = 0\r\n let i = 0\r\n while (i < columnLetters.length) {\r\n n *= 26\r\n n += LETTERS.indexOf(columnLetters[i])\r\n i++\r\n }\r\n const columnNumberFromColumnLetters = n\r\n\r\n return [\r\n // Row number (starting at `1`).\r\n Number(rowNumberString),\r\n // Column number (starting at `1`).\r\n columnNumberFromColumnLetters\r\n ]\r\n}\r\n\r\n// Maps \"A1\"-like coordinates to `{ row, column }` numeric coordinates.\r\n//\r\n// This is `export`ed only to be passed in `worker-f` dependencies.\r\n// Otherwise, it would throw: \"LETTERS is not defined\".\r\n//\r\nexport const LETTERS = ['', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']\r\n"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACe,SAASA,gBAAgBA,CAACC,iBAAiB,EAAE;EAC1D;EACA,IAAAC,qBAAA,GAAyCD,iBAAiB,CAACE,KAAK,CAAC,OAAO,CAAC;IAAAC,sBAAA,GAAAC,cAAA,CAAAH,qBAAA;IAAlEI,aAAa,GAAAF,sBAAA;IAAEG,eAAe,GAAAH,sBAAA;;EAErC;EACA;EACA;EACA;EACA;EACA;EACA,IAAII,CAAC,GAAG,CAAC;EACT,IAAIC,CAAC,GAAG,CAAC;EACT,OAAOA,CAAC,GAAGH,aAAa,CAACI,MAAM,EAAE;IAC/BF,CAAC,IAAI,EAAE;IACPA,CAAC,IAAIG,OAAO,CAACC,OAAO,CAACN,aAAa,CAACG,CAAC,CAAC,CAAC;IACtCA,CAAC,EAAE;EACL;EACA,IAAMI,6BAA6B,GAAGL,CAAC;EAEvC,OAAO;EACL;EACAM,MAAM,CAACP,eAAe,CAAC;EACvB;EACAM,6BAA6B,CAC9B;AACH;;AAEA;AACA;AACA;AACA;AACA;AACO,IAAMF,OAAO,GAAAI,OAAA,CAAAJ,OAAA,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC"}