read-excel-file 9.2.0 → 9.3.1

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 (205) hide show
  1. package/.gitlab-ci.yml +1 -1
  2. package/CHANGELOG.md +5 -0
  3. package/README.md +153 -50
  4. package/bundle/read-excel-file.min.js +1 -1
  5. package/bundle/read-excel-file.min.js.map +1 -1
  6. package/bundle/read-excel-file.min.old.js +2 -0
  7. package/bundle/read-excel-file.min.old.js.map +1 -0
  8. package/commonjs/export/convertValuesFromUint8ArraysToStrings.js +3 -0
  9. package/commonjs/export/convertValuesFromUint8ArraysToStrings.js.map +1 -1
  10. package/commonjs/export/parseSheet.js +12 -9
  11. package/commonjs/export/parseSheet.js.map +1 -1
  12. package/commonjs/export/readSheetBrowser.js +6 -2
  13. package/commonjs/export/readSheetBrowser.js.map +1 -1
  14. package/commonjs/export/readSheetNode.js +6 -2
  15. package/commonjs/export/readSheetNode.js.map +1 -1
  16. package/commonjs/export/readSheetUniversal.js +14 -2
  17. package/commonjs/export/readSheetUniversal.js.map +1 -1
  18. package/commonjs/export/readSheetWebWorker.js +12 -2
  19. package/commonjs/export/readSheetWebWorker.js.map +1 -1
  20. package/commonjs/export/readXlsxFileBrowser.js +6 -2
  21. package/commonjs/export/readXlsxFileBrowser.js.map +1 -1
  22. package/commonjs/export/readXlsxFileNode.js +6 -2
  23. package/commonjs/export/readXlsxFileNode.js.map +1 -1
  24. package/commonjs/export/readXlsxFileUniversal.js +14 -2
  25. package/commonjs/export/readXlsxFileUniversal.js.map +1 -1
  26. package/commonjs/export/readXlsxFileWebWorker.js +12 -2
  27. package/commonjs/export/readXlsxFileWebWorker.js.map +1 -1
  28. package/commonjs/export/unpackXlsxFileBrowser.js +29 -6
  29. package/commonjs/export/unpackXlsxFileBrowser.js.map +1 -1
  30. package/commonjs/export/unpackXlsxFileNode.js +6 -0
  31. package/commonjs/export/unpackXlsxFileNode.js.map +1 -1
  32. package/commonjs/export/unpackXlsxFileUniversal.js +6 -0
  33. package/commonjs/export/unpackXlsxFileUniversal.js.map +1 -1
  34. package/commonjs/export/unpackXlsxFileWebWorker.js +14 -0
  35. package/commonjs/export/unpackXlsxFileWebWorker.js.map +1 -0
  36. package/commonjs/parseSheetData/parseSheetData.js +6 -6
  37. package/commonjs/parseSheetData/parseSheetData.js.map +1 -1
  38. package/commonjs/utility/checkpoint.js +33 -0
  39. package/commonjs/utility/checkpoint.js.map +1 -0
  40. package/commonjs/utility/isObject.js +15 -0
  41. package/commonjs/utility/isObject.js.map +1 -0
  42. package/commonjs/utility/isPromise.js +18 -0
  43. package/commonjs/utility/isPromise.js.map +1 -0
  44. package/commonjs/xlsx/convertCellsToData2dArray.js +0 -3
  45. package/commonjs/xlsx/convertCellsToData2dArray.js.map +1 -1
  46. package/commonjs/xlsx/isDateFormatStyle.js +2 -2
  47. package/commonjs/xlsx/isDateFormatStyle.js.map +1 -1
  48. package/commonjs/xlsx/parseCell.js +89 -24
  49. package/commonjs/xlsx/parseCell.js.map +1 -1
  50. package/{modules/xlsx/parseCellCoordinates.js → commonjs/xlsx/parseCellAddress.js} +18 -7
  51. package/commonjs/xlsx/parseCellAddress.js.map +1 -0
  52. package/commonjs/xlsx/parseCellValue.js +7 -23
  53. package/commonjs/xlsx/parseCellValue.js.map +1 -1
  54. package/commonjs/xlsx/parseFilePaths.js +31 -32
  55. package/commonjs/xlsx/parseFilePaths.js.map +1 -1
  56. package/commonjs/xlsx/parseNumber.js +20 -0
  57. package/commonjs/xlsx/parseNumber.js.map +1 -0
  58. package/commonjs/xlsx/parseSharedString.js +64 -0
  59. package/commonjs/xlsx/parseSharedString.js.map +1 -0
  60. package/commonjs/xlsx/parseSharedStrings.js +45 -5
  61. package/commonjs/xlsx/parseSharedStrings.js.map +1 -1
  62. package/commonjs/xlsx/parseSheet.js +93 -9
  63. package/commonjs/xlsx/parseSheet.js.map +1 -1
  64. package/commonjs/xlsx/parseSheetData.js +68 -0
  65. package/commonjs/xlsx/parseSheetData.js.map +1 -0
  66. package/commonjs/xlsx/parseSpreadsheetContents.js +244 -43
  67. package/commonjs/xlsx/parseSpreadsheetContents.js.map +1 -1
  68. package/commonjs/xlsx/parseSpreadsheetInfo.js +67 -36
  69. package/commonjs/xlsx/parseSpreadsheetInfo.js.map +1 -1
  70. package/commonjs/xlsx/parseStyles.js +89 -36
  71. package/commonjs/xlsx/parseStyles.js.map +1 -1
  72. package/commonjs/xml/dom.js +2 -1
  73. package/commonjs/xml/dom.js.map +1 -1
  74. package/commonjs/xml/parseXmlStream.js +14 -0
  75. package/commonjs/xml/parseXmlStream.js.map +1 -0
  76. package/commonjs/xml/parseXmlStream.sax.js +109 -0
  77. package/commonjs/xml/parseXmlStream.sax.js.map +1 -0
  78. package/commonjs/xml/parseXmlStream.saxen.code.js +953 -0
  79. package/commonjs/xml/parseXmlStream.saxen.code.js.map +1 -0
  80. package/commonjs/xml/parseXmlStream.saxen.js +85 -0
  81. package/commonjs/xml/parseXmlStream.saxen.js.map +1 -0
  82. package/commonjs/xml/xlsx.js +75 -40
  83. package/commonjs/xml/xlsx.js.map +1 -1
  84. package/commonjs/zip/unzipFromArrayBuffer.js +5 -14
  85. package/commonjs/zip/unzipFromArrayBuffer.js.map +1 -1
  86. package/commonjs/zip/unzipFromStream.fflate.js +154 -25
  87. package/commonjs/zip/unzipFromStream.fflate.js.map +1 -1
  88. package/commonjs/zip/unzipFromStream.js.map +1 -1
  89. package/commonjs/zip/unzipFromStream.unzipper.js +37 -26
  90. package/commonjs/zip/unzipFromStream.unzipper.js.map +1 -1
  91. package/modules/export/convertValuesFromUint8ArraysToStrings.js +2 -0
  92. package/modules/export/convertValuesFromUint8ArraysToStrings.js.map +1 -1
  93. package/modules/export/parseSheet.js +12 -9
  94. package/modules/export/parseSheet.js.map +1 -1
  95. package/modules/export/readSheetBrowser.js +5 -2
  96. package/modules/export/readSheetBrowser.js.map +1 -1
  97. package/modules/export/readSheetNode.js +5 -2
  98. package/modules/export/readSheetNode.js.map +1 -1
  99. package/modules/export/readSheetUniversal.js +14 -2
  100. package/modules/export/readSheetUniversal.js.map +1 -1
  101. package/modules/export/readSheetWebWorker.js +12 -2
  102. package/modules/export/readSheetWebWorker.js.map +1 -1
  103. package/modules/export/readXlsxFileBrowser.js +5 -2
  104. package/modules/export/readXlsxFileBrowser.js.map +1 -1
  105. package/modules/export/readXlsxFileNode.js +5 -2
  106. package/modules/export/readXlsxFileNode.js.map +1 -1
  107. package/modules/export/readXlsxFileUniversal.js +14 -2
  108. package/modules/export/readXlsxFileUniversal.js.map +1 -1
  109. package/modules/export/readXlsxFileWebWorker.js +12 -2
  110. package/modules/export/readXlsxFileWebWorker.js.map +1 -1
  111. package/modules/export/unpackXlsxFileBrowser.js +26 -6
  112. package/modules/export/unpackXlsxFileBrowser.js.map +1 -1
  113. package/modules/export/unpackXlsxFileNode.js +3 -0
  114. package/modules/export/unpackXlsxFileNode.js.map +1 -1
  115. package/modules/export/unpackXlsxFileUniversal.js +3 -0
  116. package/modules/export/unpackXlsxFileUniversal.js.map +1 -1
  117. package/modules/export/unpackXlsxFileWebWorker.js +6 -0
  118. package/modules/export/unpackXlsxFileWebWorker.js.map +1 -0
  119. package/modules/parseSheetData/parseSheetData.js +4 -4
  120. package/modules/parseSheetData/parseSheetData.js.map +1 -1
  121. package/modules/utility/checkpoint.js +25 -0
  122. package/modules/utility/checkpoint.js.map +1 -0
  123. package/modules/utility/isObject.js +9 -0
  124. package/modules/utility/isObject.js.map +1 -0
  125. package/modules/utility/isPromise.js +12 -0
  126. package/modules/utility/isPromise.js.map +1 -0
  127. package/modules/xlsx/convertCellsToData2dArray.js +0 -3
  128. package/modules/xlsx/convertCellsToData2dArray.js.map +1 -1
  129. package/modules/xlsx/isDateFormatStyle.js +2 -2
  130. package/modules/xlsx/isDateFormatStyle.js.map +1 -1
  131. package/modules/xlsx/parseCell.js +85 -24
  132. package/modules/xlsx/parseCell.js.map +1 -1
  133. package/{commonjs/xlsx/parseCellCoordinates.js → modules/xlsx/parseCellAddress.js} +12 -13
  134. package/modules/xlsx/parseCellAddress.js.map +1 -0
  135. package/modules/xlsx/parseCellValue.js +7 -23
  136. package/modules/xlsx/parseCellValue.js.map +1 -1
  137. package/modules/xlsx/parseFilePaths.js +31 -33
  138. package/modules/xlsx/parseFilePaths.js.map +1 -1
  139. package/modules/xlsx/parseNumber.js +14 -0
  140. package/modules/xlsx/parseNumber.js.map +1 -0
  141. package/modules/xlsx/parseSharedString.js +55 -0
  142. package/modules/xlsx/parseSharedString.js.map +1 -0
  143. package/modules/xlsx/parseSharedStrings.js +46 -5
  144. package/modules/xlsx/parseSharedStrings.js.map +1 -1
  145. package/modules/xlsx/parseSheet.js +91 -9
  146. package/modules/xlsx/parseSheet.js.map +1 -1
  147. package/modules/xlsx/parseSheetData.js +55 -0
  148. package/modules/xlsx/parseSheetData.js.map +1 -0
  149. package/modules/xlsx/parseSpreadsheetContents.js +242 -43
  150. package/modules/xlsx/parseSpreadsheetContents.js.map +1 -1
  151. package/modules/xlsx/parseSpreadsheetInfo.js +67 -37
  152. package/modules/xlsx/parseSpreadsheetInfo.js.map +1 -1
  153. package/modules/xlsx/parseStyles.js +88 -36
  154. package/modules/xlsx/parseStyles.js.map +1 -1
  155. package/modules/xml/dom.js +2 -1
  156. package/modules/xml/dom.js.map +1 -1
  157. package/modules/xml/parseXmlStream.js +18 -0
  158. package/modules/xml/parseXmlStream.js.map +1 -0
  159. package/modules/xml/parseXmlStream.sax.js +103 -0
  160. package/modules/xml/parseXmlStream.sax.js.map +1 -0
  161. package/modules/xml/parseXmlStream.saxen.code.js +947 -0
  162. package/modules/xml/parseXmlStream.saxen.code.js.map +1 -0
  163. package/modules/xml/parseXmlStream.saxen.js +79 -0
  164. package/modules/xml/parseXmlStream.saxen.js.map +1 -0
  165. package/modules/xml/xlsx.js +72 -36
  166. package/modules/xml/xlsx.js.map +1 -1
  167. package/modules/zip/unzipFromArrayBuffer.js +5 -14
  168. package/modules/zip/unzipFromArrayBuffer.js.map +1 -1
  169. package/modules/zip/unzipFromStream.fflate.js +157 -24
  170. package/modules/zip/unzipFromStream.fflate.js.map +1 -1
  171. package/modules/zip/unzipFromStream.js +56 -2
  172. package/modules/zip/unzipFromStream.js.map +1 -1
  173. package/modules/zip/unzipFromStream.unzipper.js +38 -26
  174. package/modules/zip/unzipFromStream.unzipper.js.map +1 -1
  175. package/package.json +4 -6
  176. package/commonjs/xlsx/parseCellCoordinates.js.map +0 -1
  177. package/commonjs/xlsx/parseCells.js +0 -34
  178. package/commonjs/xlsx/parseCells.js.map +0 -1
  179. package/commonjs/xlsx/parseSheetDimensions.js +0 -43
  180. package/commonjs/xlsx/parseSheetDimensions.js.map +0 -1
  181. package/commonjs/xml/xml.js +0 -13
  182. package/commonjs/xml/xml.js.map +0 -1
  183. package/commonjs/xml/xmlBrowser.js +0 -17
  184. package/commonjs/xml/xmlBrowser.js.map +0 -1
  185. package/commonjs/xml/xpath/xlsx-xpath.js +0 -92
  186. package/commonjs/xml/xpath/xlsx-xpath.js.map +0 -1
  187. package/commonjs/xml/xpath/xpathBrowser.js +0 -33
  188. package/commonjs/xml/xpath/xpathBrowser.js.map +0 -1
  189. package/commonjs/xml/xpath/xpathNode.js +0 -16
  190. package/commonjs/xml/xpath/xpathNode.js.map +0 -1
  191. package/modules/xlsx/parseCellCoordinates.js.map +0 -1
  192. package/modules/xlsx/parseCells.js +0 -27
  193. package/modules/xlsx/parseCells.js.map +0 -1
  194. package/modules/xlsx/parseSheetDimensions.js +0 -37
  195. package/modules/xlsx/parseSheetDimensions.js.map +0 -1
  196. package/modules/xml/xml.js +0 -7
  197. package/modules/xml/xml.js.map +0 -1
  198. package/modules/xml/xmlBrowser.js +0 -11
  199. package/modules/xml/xmlBrowser.js.map +0 -1
  200. package/modules/xml/xpath/xlsx-xpath.js +0 -73
  201. package/modules/xml/xpath/xlsx-xpath.js.map +0 -1
  202. package/modules/xml/xpath/xpathBrowser.js +0 -27
  203. package/modules/xml/xpath/xpathBrowser.js.map +0 -1
  204. package/modules/xml/xpath/xpathNode.js +0 -9
  205. package/modules/xml/xpath/xpathNode.js.map +0 -1
@@ -3,12 +3,20 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.createInitialStateInCell = createInitialStateInCell;
6
7
  exports["default"] = parseCell;
8
+ exports.onCloseTagInCell = onCloseTagInCell;
9
+ exports.onOpenTagInCell = onOpenTagInCell;
10
+ exports.onTextInCell = onTextInCell;
7
11
  var _parseCellValue = _interopRequireDefault(require("./parseCellValue.js"));
8
- var _parseCellCoordinates = _interopRequireDefault(require("./parseCellCoordinates.js"));
9
- var _xlsx = require("../xml/xlsx.js");
10
- var _dom = require("../xml/dom.js");
12
+ var _parseCellAddress3 = _interopRequireDefault(require("./parseCellAddress.js"));
11
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
15
+ 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."); }
16
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
17
+ 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
+ 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
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
20
  // Example of a `<c/>`ell element:
13
21
  //
14
22
  // <c>
@@ -34,29 +42,19 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
34
42
  // </extLst>
35
43
  // </c>
36
44
  //
37
- function parseCell(element, sheetDocument, sharedStrings, styles, epoch1904, options) {
38
- var coordinates = (0, _parseCellCoordinates["default"])(element.getAttribute('r'));
39
- var valueElement = (0, _xlsx.getCellValueElement)(sheetDocument, element);
40
-
41
- // When the value element doesn't exist, it would be returned as `undefined`
42
- // when using `xpath` and as `null` when using `DOMParser`.
43
- // So here it uses `value && ...` syntax instead of `if (value !== undefined) { ... }`
44
- // for compatibility with both `xpath` and `DOMParser`.
45
- var value = valueElement && valueElement.textContent;
46
- var type = element.getAttribute('t');
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;
47
52
  return {
48
- row: coordinates[0],
49
- column: coordinates[1],
53
+ row: row,
54
+ column: column,
50
55
  value: (0, _parseCellValue["default"])(value, type, {
51
- getInlineStringValue: function getInlineStringValue() {
52
- return (0, _xlsx.getCellInlineStringValue)(sheetDocument, element);
53
- },
54
- getInlineStringXml: function getInlineStringXml() {
55
- return (0, _dom.getOuterXml)(element);
56
- },
57
- getStyleId: function getStyleId() {
58
- return element.getAttribute('s');
59
- },
56
+ inlineString: inlineString,
57
+ styleId: styleId,
60
58
  styles: styles,
61
59
  sharedStrings: sharedStrings,
62
60
  epoch1904: epoch1904,
@@ -64,4 +62,71 @@ function parseCell(element, sheetDocument, sharedStrings, styles, epoch1904, opt
64
62
  })
65
63
  };
66
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;
128
+ }
129
+ }
130
+ }
131
+ }
67
132
  //# sourceMappingURL=parseCell.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseCell.js","names":["_parseCellValue","_interopRequireDefault","require","_parseCellCoordinates","_xlsx","_dom","obj","__esModule","parseCell","element","sheetDocument","sharedStrings","styles","epoch1904","options","coordinates","parseCellCoordinates","getAttribute","valueElement","getCellValueElement","value","textContent","type","row","column","parseCellValue","getInlineStringValue","getCellInlineStringValue","getInlineStringXml","getOuterXml","getStyleId"],"sources":["../../source/xlsx/parseCell.js"],"sourcesContent":["import parseCellValue from './parseCellValue.js'\r\nimport parseCellCoordinates from './parseCellCoordinates.js'\r\n\r\nimport {\r\n getCellValueElement,\r\n getCellInlineStringValue\r\n} from '../xml/xlsx.js'\r\n\r\nimport {\r\n getOuterXml\r\n} from '../xml/dom.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(element, sheetDocument, sharedStrings, styles, epoch1904, options) {\r\n const coordinates = parseCellCoordinates(element.getAttribute('r'))\r\n const valueElement = getCellValueElement(sheetDocument, element)\r\n\r\n // When the value element doesn't exist, it would be returned as `undefined`\r\n // when using `xpath` and as `null` when using `DOMParser`.\r\n // So here it uses `value && ...` syntax instead of `if (value !== undefined) { ... }`\r\n // for compatibility with both `xpath` and `DOMParser`.\r\n const value = valueElement && valueElement.textContent\r\n const type = element.getAttribute('t')\r\n\r\n return {\r\n row: coordinates[0],\r\n column: coordinates[1],\r\n value: parseCellValue(value, type, {\r\n getInlineStringValue: () => getCellInlineStringValue(sheetDocument, element),\r\n getInlineStringXml: () => getOuterXml(element),\r\n getStyleId: () => element.getAttribute('s'),\r\n styles,\r\n sharedStrings,\r\n epoch1904,\r\n options\r\n })\r\n }\r\n}"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,IAAA,GAAAH,OAAA;AAEsB,SAAAD,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,SAASA,CAACC,OAAO,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,EAAEC,SAAS,EAAEC,OAAO,EAAE;EACnG,IAAMC,WAAW,GAAG,IAAAC,gCAAoB,EAACP,OAAO,CAACQ,YAAY,CAAC,GAAG,CAAC,CAAC;EACnE,IAAMC,YAAY,GAAG,IAAAC,yBAAmB,EAACT,aAAa,EAAED,OAAO,CAAC;;EAEhE;EACA;EACA;EACA;EACA,IAAMW,KAAK,GAAGF,YAAY,IAAIA,YAAY,CAACG,WAAW;EACtD,IAAMC,IAAI,GAAGb,OAAO,CAACQ,YAAY,CAAC,GAAG,CAAC;EAEtC,OAAO;IACLM,GAAG,EAAER,WAAW,CAAC,CAAC,CAAC;IACnBS,MAAM,EAAET,WAAW,CAAC,CAAC,CAAC;IACtBK,KAAK,EAAE,IAAAK,0BAAc,EAACL,KAAK,EAAEE,IAAI,EAAE;MACjCI,oBAAoB,EAAE,SAAAA,qBAAA;QAAA,OAAM,IAAAC,8BAAwB,EAACjB,aAAa,EAAED,OAAO,CAAC;MAAA;MAC5EmB,kBAAkB,EAAE,SAAAA,mBAAA;QAAA,OAAM,IAAAC,gBAAW,EAACpB,OAAO,CAAC;MAAA;MAC9CqB,UAAU,EAAE,SAAAA,WAAA;QAAA,OAAMrB,OAAO,CAACQ,YAAY,CAAC,GAAG,CAAC;MAAA;MAC3CL,MAAM,EAANA,MAAM;MACND,aAAa,EAAbA,aAAa;MACbE,SAAS,EAATA,SAAS;MACTC,OAAO,EAAPA;IACF,CAAC;EACH,CAAC;AACH"}
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,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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,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,26 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = parseCellAddress;
1
7
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
8
  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."); }
3
9
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
10
  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; }
5
11
  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; } }
6
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- export default function parseCellCoordinates(coordinatesString) {
13
+ /**
14
+ * Parses XLSX cell address into a row number and a column number.
15
+ * @param {string} coordinatesString
16
+ * @returns {number[]} Returns `[rowNumber, columnNumber]`
17
+ */
18
+ function parseCellAddress(coordinatesString) {
8
19
  // Coordinate examples: "AA2091", "R988", "B1".
9
20
  var _coordinatesString$sp = coordinatesString.split(/(\d+)/),
10
21
  _coordinatesString$sp2 = _slicedToArray(_coordinatesString$sp, 2),
11
22
  column = _coordinatesString$sp2[0],
12
23
  row = _coordinatesString$sp2[1];
13
24
  return [
14
- // Row.
25
+ // Row number (starting at `1`).
15
26
  Number(row),
16
- // Column.
17
- // It's not clear why would `column` ever be non-trimmed,
18
- // but if it was added here then perhaps it could hypothetically happen, or smth.
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.
19
30
  getColumnNumberFromColumnLetters(column.trim())];
20
31
  }
21
32
 
22
33
  // Maps "A1"-like coordinates to `{ row, column }` numeric coordinates.
23
- 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"];
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'];
24
35
 
25
36
  // Converts a letter coordinate to a digit coordinate.
26
37
  // Examples: "A" -> 1, "B" -> 2, "Z" -> 26, "AA" -> 27, etc.
@@ -35,4 +46,4 @@ function getColumnNumberFromColumnLetters(columnLetters) {
35
46
  }
36
47
  return n;
37
48
  }
38
- //# sourceMappingURL=parseCellCoordinates.js.map
49
+ //# sourceMappingURL=parseCellAddress.js.map
@@ -0,0 +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"}
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = parseCellValue;
7
7
  var _parseExcelDate = _interopRequireDefault(require("./parseExcelDate.js"));
8
+ var _parseNumber = _interopRequireDefault(require("./parseNumber.js"));
8
9
  var _isDateFormatStyle = _interopRequireDefault(require("./isDateFormatStyle.js"));
9
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
11
  // Parses a string `value` of a cell.
11
12
  function parseCellValue(value, type, _ref) {
12
- var getInlineStringValue = _ref.getInlineStringValue,
13
- getInlineStringXml = _ref.getInlineStringXml,
14
- getStyleId = _ref.getStyleId,
13
+ var inlineString = _ref.inlineString,
14
+ styleId = _ref.styleId,
15
15
  styles = _ref.styles,
16
16
  sharedStrings = _ref.sharedStrings,
17
17
  epoch1904 = _ref.epoch1904,
@@ -41,9 +41,9 @@ function parseCellValue(value, type, _ref) {
41
41
  // Perhaps the specification doesn't force it to use one or another.
42
42
  // Example: `<sheetData><row r="1"><c r="A1" s="1" t="inlineStr"><is><t>Test 123</t></is></c></row></sheetData>`.
43
43
  case 'inlineStr':
44
- value = getInlineStringValue();
44
+ value = inlineString;
45
45
  if (value === undefined) {
46
- throw new Error("Unsupported \"inline string\" cell value structure: ".concat(getInlineStringXml()));
46
+ throw new Error('Couldn\'t read "inline string" cell value');
47
47
  }
48
48
  value = parseString(value, options);
49
49
  break;
@@ -118,10 +118,9 @@ function parseCellValue(value, type, _ref) {
118
118
  }
119
119
  // XLSX does have "d" type for dates, but it's not commonly used.
120
120
  // Instead, it prefers using "n" type for storing dates as timestamps.
121
- var styleId = getStyleId();
122
121
  if (styleId && (0, _isDateFormatStyle["default"])(styleId, styles, options)) {
123
122
  // Parse the number from string.
124
- value = parseNumberDefault(value);
123
+ value = (0, _parseNumber["default"])(value);
125
124
  // Parse the number as a date timestamp.
126
125
  value = (0, _parseExcelDate["default"])(value, {
127
126
  epoch1904: epoch1904
@@ -130,8 +129,7 @@ function parseCellValue(value, type, _ref) {
130
129
  // Parse the number from string.
131
130
  // Supports custom parsing function to work around javascript number encoding precision issues.
132
131
  // https://gitlab.com/catamphetamine/read-excel-file/-/issues/85
133
- var parseNumber = options.parseNumber || parseNumberDefault;
134
- value = parseNumber(value);
132
+ value = (options.parseNumber || _parseNumber["default"])(value);
135
133
  }
136
134
  break;
137
135
  default:
@@ -185,18 +183,4 @@ function parseString(value, options) {
185
183
  }
186
184
  return value;
187
185
  }
188
-
189
- // Parses a number from string.
190
- // Throws an error if the number couldn't be parsed.
191
- // When parsing floating-point number, is affected by
192
- // the javascript number encoding precision issues:
193
- // https://www.youtube.com/watch?v=2gIxbTn7GSc
194
- // https://www.avioconsulting.com/blog/overcoming-javascript-numeric-precision-issues
195
- function parseNumberDefault(stringifiedNumber) {
196
- var parsedNumber = Number(stringifiedNumber);
197
- if (isNaN(parsedNumber)) {
198
- throw new Error("Invalid \"numeric\" cell value: ".concat(stringifiedNumber));
199
- }
200
- return parsedNumber;
201
- }
202
186
  //# sourceMappingURL=parseCellValue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseCellValue.js","names":["_parseExcelDate","_interopRequireDefault","require","_isDateFormatStyle","obj","__esModule","parseCellValue","value","type","_ref","getInlineStringValue","getInlineStringXml","getStyleId","styles","sharedStrings","epoch1904","options","parseString","undefined","Error","concat","sharedStringIndex","Number","isNaN","length","decodeError","parsedDate","Date","valueOf","styleId","isDateFormatStyle","parseNumberDefault","parseExcelDate","parseNumber","TypeError","errorCode","trim","stringifiedNumber","parsedNumber"],"sources":["../../source/xlsx/parseCellValue.js"],"sourcesContent":["import parseExcelDate from './parseExcelDate.js'\r\nimport isDateFormatStyle from './isDateFormatStyle.js'\r\n\r\n// Parses a string `value` of a cell.\r\nexport default function parseCellValue(value, type, {\r\n getInlineStringValue,\r\n getInlineStringXml,\r\n getStyleId,\r\n styles,\r\n sharedStrings,\r\n epoch1904,\r\n options\r\n}) {\r\n if (!type) {\r\n // Default cell type is \"n\" (numeric).\r\n // http://www.datypic.com/sc/ooxml/t-ssml_CT_Cell.html\r\n type = 'n'\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 switch (type) {\r\n // XLSX tends to store all strings as \"shared\" (indexed) ones\r\n // using \"s\" cell type (for saving on strage space).\r\n // \"str\" cell type is then generally only used for storing\r\n // formula-pre-calculated cell values.\r\n case 'str':\r\n value = parseString(value, options)\r\n break\r\n\r\n // Sometimes, XLSX stores strings as \"inline\" strings rather than \"shared\" (indexed) ones.\r\n // Perhaps the specification doesn't force it to use one or another.\r\n // Example: `<sheetData><row r=\"1\"><c r=\"A1\" s=\"1\" t=\"inlineStr\"><is><t>Test 123</t></is></c></row></sheetData>`.\r\n case 'inlineStr':\r\n value = getInlineStringValue()\r\n if (value === undefined) {\r\n throw new Error(`Unsupported \"inline string\" cell value structure: ${getInlineStringXml()}`)\r\n }\r\n value = parseString(value, options)\r\n break\r\n\r\n // XLSX tends to store string values as \"shared\" (indexed) ones.\r\n // \"Shared\" strings is a way for an Excel editor to reduce\r\n // the file size by storing \"commonly used\" strings in a dictionary\r\n // and then referring to such strings by their index in that dictionary.\r\n // Example: `<sheetData><row r=\"1\"><c r=\"A1\" s=\"1\" t=\"s\"><v>0</v></c></row></sheetData>`.\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/>`alue is a key in the \"shared strings\" dictionary of the\r\n // XLSX file, so look it up in the `sharedStrings` dictionary by the numeric key.\r\n const sharedStringIndex = Number(value)\r\n if (isNaN(sharedStringIndex)) {\r\n throw new Error(`Invalid \"shared\" string index: ${value}`)\r\n }\r\n if (sharedStringIndex >= sharedStrings.length) {\r\n throw new Error(`An out-of-bounds \"shared\" string index: ${value}`)\r\n }\r\n value = sharedStrings[sharedStringIndex]\r\n value = parseString(value, options)\r\n break\r\n\r\n // Boolean (TRUE/FALSE) values are stored as either \"1\" or \"0\"\r\n // in cells of type \"b\".\r\n case 'b':\r\n if (value === '1') {\r\n value = true\r\n } else if (value === '0') {\r\n value = false\r\n } else {\r\n throw new Error(`Unsupported \"boolean\" cell value: ${value}`)\r\n }\r\n break\r\n\r\n // XLSX specification seems to support cells of type \"z\":\r\n // blank \"stub\" cells that should be ignored by data processing utilities.\r\n case 'z':\r\n value = undefined\r\n break\r\n\r\n // XLSX specification also defines cells of type \"e\" containing a numeric \"error\" code.\r\n // It's not clear what that means though.\r\n // They also wrote: \"and `w` property stores its common name\".\r\n // It's unclear what they meant by that.\r\n case 'e':\r\n value = decodeError(value)\r\n break\r\n\r\n // XLSX supports date cells of type \"d\", though seems like it (almost?) never\r\n // uses it for storing dates, preferring \"n\" numeric timestamp cells 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 // Example: `<sheetData><row r=\"1\"><c r=\"A1\" s=\"1\" t=\"d\"><v>2021-06-10T00:47:45.700Z</v></c></row></sheetData>`.\r\n case 'd':\r\n if (value === undefined) {\r\n break\r\n }\r\n const parsedDate = new Date(value)\r\n if (isNaN(parsedDate.valueOf())) {\r\n throw new Error(`Unsupported \"date\" cell value: ${value}`)\r\n }\r\n value = parsedDate\r\n break\r\n\r\n // Numeric cells have type \"n\".\r\n case 'n':\r\n if (value === undefined) {\r\n break\r\n }\r\n // XLSX does have \"d\" type for dates, but it's not commonly used.\r\n // Instead, it prefers using \"n\" type for storing dates as timestamps.\r\n const styleId = getStyleId()\r\n if (styleId && isDateFormatStyle(styleId, styles, options)) {\r\n // Parse the number from string.\r\n value = parseNumberDefault(value)\r\n // Parse the number as a date timestamp.\r\n value = parseExcelDate(value, { epoch1904 })\r\n } else {\r\n // Parse the number from string.\r\n // Supports custom parsing function to work around javascript number encoding precision issues.\r\n // https://gitlab.com/catamphetamine/read-excel-file/-/issues/85\r\n const parseNumber = options.parseNumber || parseNumberDefault\r\n value = parseNumber(value)\r\n }\r\n break\r\n\r\n default:\r\n throw new TypeError(`Cell type not supported: ${type}`)\r\n }\r\n\r\n // Convert empty values to `null`.\r\n if (value === undefined) {\r\n value = null\r\n }\r\n\r\n return value\r\n}\r\n\r\n// Decodes numeric error code to a string code.\r\n// https://github.com/SheetJS/sheetjs/blob/19620da30be2a7d7b9801938a0b9b1fd3c4c4b00/docbits/52_datatype.md\r\nfunction decodeError(errorCode) {\r\n // While the error values are determined by the application,\r\n // the following are some example error values that could be used:\r\n switch (errorCode) {\r\n case 0x00:\r\n return '#NULL!'\r\n case 0x07:\r\n return '#DIV/0!'\r\n case 0x0F:\r\n return '#VALUE!'\r\n case 0x17:\r\n return '#REF!'\r\n case 0x1D:\r\n return '#NAME?'\r\n case 0x24:\r\n return '#NUM!'\r\n case 0x2A:\r\n return '#N/A'\r\n case 0x2B:\r\n return '#GETTING_DATA'\r\n default:\r\n // Such error code doesn't exist. I made it up.\r\n return `#ERROR_${errorCode}`\r\n }\r\n}\r\n\r\nfunction parseString(value, options) {\r\n // In some weird cases, a developer might want to disable\r\n // the automatic trimming of all strings.\r\n // For example, leading spaces might express a tree-like hierarchy.\r\n // https://github.com/catamphetamine/read-excel-file/pull/106#issuecomment-1136062917\r\n if (options.trim !== false) {\r\n value = value.trim()\r\n }\r\n if (value === '') {\r\n value = undefined\r\n }\r\n return value\r\n}\r\n\r\n// Parses a number from string.\r\n// Throws an error if the number couldn't be parsed.\r\n// When parsing floating-point number, is affected by\r\n// the javascript number encoding precision issues:\r\n// https://www.youtube.com/watch?v=2gIxbTn7GSc\r\n// https://www.avioconsulting.com/blog/overcoming-javascript-numeric-precision-issues\r\nfunction parseNumberDefault(stringifiedNumber) {\r\n const parsedNumber = Number(stringifiedNumber)\r\n if (isNaN(parsedNumber)) {\r\n throw new Error(`Invalid \"numeric\" cell value: ${stringifiedNumber}`)\r\n }\r\n return parsedNumber\r\n}"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,I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,iBAAiB,CAAC;EAC9C,IAAId,KAAK,CAACe,YAAY,CAAC,EAAE;IACvB,MAAM,IAAInB,KAAK,oCAAAC,MAAA,CAAkCiB,iBAAiB,CAAE,CAAC;EACvE;EACA,OAAOC,YAAY;AACrB"}
1
+ {"version":3,"file":"parseCellValue.js","names":["_parseExcelDate","_interopRequireDefault","require","_parseNumber","_isDateFormatStyle","obj","__esModule","parseCellValue","value","type","_ref","inlineString","styleId","styles","sharedStrings","epoch1904","options","parseString","undefined","Error","sharedStringIndex","Number","isNaN","concat","length","decodeError","parsedDate","Date","valueOf","isDateFormatStyle","parseNumber","parseExcelDate","TypeError","errorCode","trim"],"sources":["../../source/xlsx/parseCellValue.js"],"sourcesContent":["import parseExcelDate from './parseExcelDate.js'\r\nimport parseNumber from './parseNumber.js'\r\nimport isDateFormatStyle from './isDateFormatStyle.js'\r\n\r\n// Parses a string `value` of a cell.\r\nexport default function 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 if (!type) {\r\n // Default cell type is \"n\" (numeric).\r\n // http://www.datypic.com/sc/ooxml/t-ssml_CT_Cell.html\r\n type = 'n'\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 switch (type) {\r\n // XLSX tends to store all strings as \"shared\" (indexed) ones\r\n // using \"s\" cell type (for saving on strage space).\r\n // \"str\" cell type is then generally only used for storing\r\n // formula-pre-calculated cell values.\r\n case 'str':\r\n value = parseString(value, options)\r\n break\r\n\r\n // Sometimes, XLSX stores strings as \"inline\" strings rather than \"shared\" (indexed) ones.\r\n // Perhaps the specification doesn't force it to use one or another.\r\n // Example: `<sheetData><row r=\"1\"><c r=\"A1\" s=\"1\" t=\"inlineStr\"><is><t>Test 123</t></is></c></row></sheetData>`.\r\n case 'inlineStr':\r\n value = inlineString\r\n if (value === undefined) {\r\n throw new Error('Couldn\\'t read \"inline string\" cell value')\r\n }\r\n value = parseString(value, options)\r\n break\r\n\r\n // XLSX tends to store string values as \"shared\" (indexed) ones.\r\n // \"Shared\" strings is a way for an Excel editor to reduce\r\n // the file size by storing \"commonly used\" strings in a dictionary\r\n // and then referring to such strings by their index in that dictionary.\r\n // Example: `<sheetData><row r=\"1\"><c r=\"A1\" s=\"1\" t=\"s\"><v>0</v></c></row></sheetData>`.\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/>`alue is a key in the \"shared strings\" dictionary of the\r\n // XLSX file, so look it up in the `sharedStrings` dictionary by the numeric key.\r\n const sharedStringIndex = Number(value)\r\n if (isNaN(sharedStringIndex)) {\r\n throw new Error(`Invalid \"shared\" string index: ${value}`)\r\n }\r\n if (sharedStringIndex >= sharedStrings.length) {\r\n throw new Error(`An out-of-bounds \"shared\" string index: ${value}`)\r\n }\r\n value = sharedStrings[sharedStringIndex]\r\n value = parseString(value, options)\r\n break\r\n\r\n // Boolean (TRUE/FALSE) values are stored as either \"1\" or \"0\"\r\n // in cells of type \"b\".\r\n case 'b':\r\n if (value === '1') {\r\n value = true\r\n } else if (value === '0') {\r\n value = false\r\n } else {\r\n throw new Error(`Unsupported \"boolean\" cell value: ${value}`)\r\n }\r\n break\r\n\r\n // XLSX specification seems to support cells of type \"z\":\r\n // blank \"stub\" cells that should be ignored by data processing utilities.\r\n case 'z':\r\n value = undefined\r\n break\r\n\r\n // XLSX specification also defines cells of type \"e\" containing a numeric \"error\" code.\r\n // It's not clear what that means though.\r\n // They also wrote: \"and `w` property stores its common name\".\r\n // It's unclear what they meant by that.\r\n case 'e':\r\n value = decodeError(value)\r\n break\r\n\r\n // XLSX supports date cells of type \"d\", though seems like it (almost?) never\r\n // uses it for storing dates, preferring \"n\" numeric timestamp cells 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 // Example: `<sheetData><row r=\"1\"><c r=\"A1\" s=\"1\" t=\"d\"><v>2021-06-10T00:47:45.700Z</v></c></row></sheetData>`.\r\n case 'd':\r\n if (value === undefined) {\r\n break\r\n }\r\n const parsedDate = new Date(value)\r\n if (isNaN(parsedDate.valueOf())) {\r\n throw new Error(`Unsupported \"date\" cell value: ${value}`)\r\n }\r\n value = parsedDate\r\n break\r\n\r\n // Numeric cells have type \"n\".\r\n case 'n':\r\n if (value === undefined) {\r\n break\r\n }\r\n // XLSX does have \"d\" type for dates, but it's not commonly used.\r\n // Instead, it prefers using \"n\" type for storing dates as timestamps.\r\n if (styleId && isDateFormatStyle(styleId, styles, options)) {\r\n // Parse the number from string.\r\n value = parseNumber(value)\r\n // Parse the number as a date timestamp.\r\n value = parseExcelDate(value, { epoch1904 })\r\n } else {\r\n // Parse the number from string.\r\n // Supports custom parsing function to work around javascript number encoding precision issues.\r\n // https://gitlab.com/catamphetamine/read-excel-file/-/issues/85\r\n value = (options.parseNumber || parseNumber)(value)\r\n }\r\n break\r\n\r\n default:\r\n throw new TypeError(`Cell type not supported: ${type}`)\r\n }\r\n\r\n // Convert empty values to `null`.\r\n if (value === undefined) {\r\n value = null\r\n }\r\n\r\n return value\r\n}\r\n\r\n// Decodes numeric error code to a string code.\r\n// https://github.com/SheetJS/sheetjs/blob/19620da30be2a7d7b9801938a0b9b1fd3c4c4b00/docbits/52_datatype.md\r\nfunction decodeError(errorCode) {\r\n // While the error values are determined by the application,\r\n // the following are some example error values that could be used:\r\n switch (errorCode) {\r\n case 0x00:\r\n return '#NULL!'\r\n case 0x07:\r\n return '#DIV/0!'\r\n case 0x0F:\r\n return '#VALUE!'\r\n case 0x17:\r\n return '#REF!'\r\n case 0x1D:\r\n return '#NAME?'\r\n case 0x24:\r\n return '#NUM!'\r\n case 0x2A:\r\n return '#N/A'\r\n case 0x2B:\r\n return '#GETTING_DATA'\r\n default:\r\n // Such error code doesn't exist. I made it up.\r\n return `#ERROR_${errorCode}`\r\n }\r\n}\r\n\r\nfunction parseString(value, options) {\r\n // In some weird cases, a developer might want to disable\r\n // the automatic trimming of all strings.\r\n // For example, leading spaces might express a tree-like hierarchy.\r\n // https://github.com/catamphetamine/read-excel-file/pull/106#issuecomment-1136062917\r\n if (options.trim !== false) {\r\n value = value.trim()\r\n }\r\n if (value === '') {\r\n value = undefined\r\n }\r\n return value\r\n}"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,kBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAAsD,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAEtD;AACe,SAASE,cAAcA,CAACC,KAAK,EAAEC,IAAI,EAAAC,IAAA,EAO/C;EAAA,IANDC,YAAY,GAAAD,IAAA,CAAZC,YAAY;IACZC,OAAO,GAAAF,IAAA,CAAPE,OAAO;IACPC,MAAM,GAAAH,IAAA,CAANG,MAAM;IACNC,aAAa,GAAAJ,IAAA,CAAbI,aAAa;IACbC,SAAS,GAAAL,IAAA,CAATK,SAAS;IACTC,OAAO,GAAAN,IAAA,CAAPM,OAAO;EAEP,IAAI,CAACP,IAAI,EAAE;IACT;IACA;IACAA,IAAI,GAAG,GAAG;EACZ;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA,QAAQA,IAAI;IACV;IACA;IACA;IACA;IACA,KAAK,KAAK;MACRD,KAAK,GAAGS,WAAW,CAACT,KAAK,EAAEQ,OAAO,CAAC;MACnC;;IAEF;IACA;IACA;IACA,KAAK,WAAW;MACdR,KAAK,GAAGG,YAAY;MACpB,IAAIH,KAAK,KAAKU,SAAS,EAAE;QACvB,MAAM,IAAIC,KAA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,EAAE;IAC1B1B,KAAK,GAAGA,KAAK,CAAC0B,IAAI,CAAC,CAAC;EACtB;EACA,IAAI1B,KAAK,KAAK,EAAE,EAAE;IAChBA,KAAK,GAAGU,SAAS;EACnB;EACA,OAAOV,KAAK;AACd"}
@@ -4,17 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = parseFilePaths;
7
- var _xlsx = require("../xml/xlsx.js");
8
7
  /**
9
8
  * Returns sheet file paths.
10
9
  * Seems that the correct place to look for the `sheetId` -> `filename` mapping
11
10
  * is `xl/_rels/workbook.xml.rels` file.
12
11
  * https://github.com/tidyverse/readxl/issues/104
13
12
  * @param {string} content — `xl/_rels/workbook.xml.rels` file contents.
14
- * @param {object} xml
15
- * @return {object}
13
+ * @param {function} parseXmlStream — SAX XML parser.
14
+ * @return {object} — An object of shape `{ sheets: Record<string, string>, sharedStrings: string?, styles: string? }`
16
15
  */
17
- function parseFilePaths(content, xml) {
16
+ function parseFilePaths(content, parseXmlStream) {
18
17
  // Example:
19
18
  // <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
20
19
  // ...
@@ -23,39 +22,39 @@ function parseFilePaths(content, xml) {
23
22
  // Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"
24
23
  // Target="worksheets/sheet1.xml"/>
25
24
  // </Relationships>
26
- var document = xml.createDocument(content);
27
- var filePaths = {
25
+ return parseXmlStream(content, {
26
+ createInitialState: createInitialStateInWorkbookRelationships,
27
+ onOpenTag: onOpenTagInWorkbookRelationships
28
+ }).then(function (state) {
29
+ return state;
30
+ });
31
+ }
32
+ function createInitialStateInWorkbookRelationships() {
33
+ return {
28
34
  sheets: {},
29
35
  sharedStrings: undefined,
30
36
  styles: undefined
31
37
  };
32
- var addFilePathInfo = function addFilePathInfo(relationship) {
33
- var filePath = relationship.getAttribute('Target');
34
- var fileType = relationship.getAttribute('Type');
35
- switch (fileType) {
36
- case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles':
37
- filePaths.styles = getFilePath(filePath);
38
- break;
39
- case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings':
40
- filePaths.sharedStrings = getFilePath(filePath);
41
- break;
42
- case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet':
43
- filePaths.sheets[relationship.getAttribute('Id')] = getFilePath(filePath);
44
- break;
45
- }
46
- };
47
- (0, _xlsx.getRelationships)(document).forEach(addFilePathInfo);
48
-
49
- // Seems like "sharedStrings.xml" is not required to exist.
50
- // For example, when the spreadsheet doesn't contain any strings.
51
- // https://github.com/catamphetamine/read-excel-file/issues/85
52
- // if (!filePaths.sharedStrings) {
53
- // throw new Error('"sharedStrings.xml" file not found in the *.xlsx file')
54
- // }
55
-
56
- return filePaths;
57
38
  }
58
- function getFilePath(path) {
39
+ function onOpenTagInWorkbookRelationships(tagName, attributes, state) {
40
+ if (tagName === 'Relationship') {
41
+ addFilePathForRelation(state, attributes.Id, attributes.Type, attributes.Target);
42
+ }
43
+ }
44
+ function addFilePathForRelation(state, id, type, target) {
45
+ switch (type) {
46
+ case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles':
47
+ state.styles = getFilePathFromRelationTarget(target);
48
+ break;
49
+ case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings':
50
+ state.sharedStrings = getFilePathFromRelationTarget(target);
51
+ break;
52
+ case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet':
53
+ state.sheets[id] = getFilePathFromRelationTarget(target);
54
+ break;
55
+ }
56
+ }
57
+ function getFilePathFromRelationTarget(path) {
59
58
  // Normally, `path` is a relative path inside the ZIP archive,
60
59
  // like "worksheets/sheet1.xml", or "sharedStrings.xml", or "styles.xml".
61
60
  // There has been one weird case when file path was an absolute path,
@@ -1 +1 @@
1
- {"version":3,"file":"parseFilePaths.js","names":["_xlsx","require","parseFilePaths","content","xml","document","createDocument","filePaths","sheets","sharedStrings","undefined","styles","addFilePathInfo","relationship","filePath","getAttribute","fileType","getFilePath","getRelationships","forEach","path","slice","length"],"sources":["../../source/xlsx/parseFilePaths.js"],"sourcesContent":["import {\r\n getRelationships\r\n} from '../xml/xlsx.js'\r\n\r\n/**\r\n * Returns sheet file paths.\r\n * Seems that the correct place to look for the `sheetId` -> `filename` mapping\r\n * is `xl/_rels/workbook.xml.rels` file.\r\n * https://github.com/tidyverse/readxl/issues/104\r\n * @param {string} content — `xl/_rels/workbook.xml.rels` file contents.\r\n * @param {object} xml\r\n * @return {object}\r\n */\r\nexport default function parseFilePaths(content, xml) {\r\n // Example:\r\n // <Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\r\n // ...\r\n // <Relationship\r\n // Id=\"rId3\"\r\n // Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet\"\r\n // Target=\"worksheets/sheet1.xml\"/>\r\n // </Relationships>\r\n const document = xml.createDocument(content)\r\n\r\n const filePaths = {\r\n sheets: {},\r\n sharedStrings: undefined,\r\n styles: undefined\r\n }\r\n\r\n const addFilePathInfo = (relationship) => {\r\n const filePath = relationship.getAttribute('Target')\r\n const fileType = relationship.getAttribute('Type')\r\n switch (fileType) {\r\n case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles':\r\n filePaths.styles = getFilePath(filePath)\r\n break\r\n case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings':\r\n filePaths.sharedStrings = getFilePath(filePath)\r\n break\r\n case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet':\r\n filePaths.sheets[relationship.getAttribute('Id')] = getFilePath(filePath)\r\n break\r\n }\r\n }\r\n\r\n getRelationships(document).forEach(addFilePathInfo)\r\n\r\n // Seems like \"sharedStrings.xml\" is not required to exist.\r\n // For example, when the spreadsheet doesn't contain any strings.\r\n // https://github.com/catamphetamine/read-excel-file/issues/85\r\n // if (!filePaths.sharedStrings) {\r\n // throw new Error('\"sharedStrings.xml\" file not found in the *.xlsx file')\r\n // }\r\n\r\n return filePaths\r\n}\r\n\r\nfunction getFilePath(path) {\r\n // Normally, `path` is a relative path inside the ZIP archive,\r\n // like \"worksheets/sheet1.xml\", or \"sharedStrings.xml\", or \"styles.xml\".\r\n // There has been one weird case when file path was an absolute path,\r\n // like \"/xl/worksheets/sheet1.xml\" (specifically for sheets):\r\n // https://github.com/catamphetamine/read-excel-file/pull/95\r\n // Other libraries (like `xlsx`) and software (like Google Docs)\r\n // seem to support such absolute file paths, so this library does too.\r\n if (path[0] === '/') {\r\n return path.slice('/'.length)\r\n }\r\n // // Seems like a path could also be a URL.\r\n // // http://officeopenxml.com/anatomyofOOXML-xlsx.php\r\n // if (/^[a-z]+\\:\\/\\//.test(path)) {\r\n // return path\r\n // }\r\n return 'xl/' + path\r\n}"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,cAAcA,CAACC,OAAO,EAAEC,GAAG,EAAE;EACnD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,IAAMC,QAAQ,GAAGD,GAAG,CAACE,cAAc,CAACH,OAAO,CAAC;EAE5C,IAAMI,SAAS,GAAG;IAChBC,MAAM,EAAE,CAAC,CAAC;IACVC,aAAa,EAAEC,SAAS;IACxBC,MAAM,EAAED;EACV,CAAC;EAED,IAAME,eAAe,GAAG,SAAlBA,eAAeA,CAAIC,YAAY,EAAK;IACxC,IAAMC,QAAQ,GAAGD,YAAY,CAACE,YAAY,CAAC,QAAQ,CAAC;IACpD,IAAMC,QAAQ,GAAGH,YAAY,CAACE,YAAY,CAAC,MAAM,CAAC;IAClD,QAAQC,QAAQ;MACd,KAAK,4EAA4E;QAC/ET,SAAS,CAACI,MAAM,GAAGM,WAAW,CAACH,QAAQ,CAAC;QACxC;MACF,KAAK,mFAAmF;QACtFP,SAAS,CAACE,aAAa,GAAGQ,WAAW,CAACH,QAAQ,CAAC;QAC/C;MACF,KAAK,+EAA+E;QAClFP,SAAS,CAACC,MAAM,CAACK,YAAY,CAACE,YAAY,CAAC,IAAI,CAAC,CAAC,GAAGE,WAAW,CAACH,QAAQ,CAAC;QACzE;IACJ;EACF,CAAC;EAED,IAAAI,sBAAgB,EAACb,QAAQ,CAAC,CAACc,OAAO,CAACP,eAAe,CAAC;;EAEnD;EACA;EACA;EACA;EACA;EACA;;EAEA,OAAOL,SAAS;AAClB;AAEA,SAASU,WAAWA,CAACG,IAAI,EAAE;EACzB;EACA;EACA;EACA;EACA;EACA;EACA;EACA,IAAIA,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;IACnB,OAAOA,IAAI,CAACC,KAAK,CAAC,GAAG,CAACC,MAAM,CAAC;EAC/B;EACA;EACA;EACA;EACA;EACA;EACA,OAAO,KAAK,GAAGF,IAAI;AACrB"}
1
+ {"version":3,"file":"parseFilePaths.js","names":["parseFilePaths","content","parseXmlStream","createInitialState","createInitialStateInWorkbookRelationships","onOpenTag","onOpenTagInWorkbookRelationships","then","state","sheets","sharedStrings","undefined","styles","tagName","attributes","addFilePathForRelation","Id","Type","Target","id","type","target","getFilePathFromRelationTarget","path","slice","length"],"sources":["../../source/xlsx/parseFilePaths.js"],"sourcesContent":["/**\r\n * Returns sheet file paths.\r\n * Seems that the correct place to look for the `sheetId` -> `filename` mapping\r\n * is `xl/_rels/workbook.xml.rels` file.\r\n * https://github.com/tidyverse/readxl/issues/104\r\n * @param {string} content — `xl/_rels/workbook.xml.rels` file contents.\r\n * @param {function} parseXmlStream — SAX XML parser.\r\n * @return {object} — An object of shape `{ sheets: Record<string, string>, sharedStrings: string?, styles: string? }`\r\n */\r\nexport default function parseFilePaths(content, parseXmlStream) {\r\n // Example:\r\n // <Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\r\n // ...\r\n // <Relationship\r\n // Id=\"rId3\"\r\n // Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet\"\r\n // Target=\"worksheets/sheet1.xml\"/>\r\n // </Relationships>\r\n return parseXmlStream(content, {\r\n createInitialState: createInitialStateInWorkbookRelationships,\r\n onOpenTag: onOpenTagInWorkbookRelationships\r\n }).then((state) => {\r\n return state\r\n })\r\n}\r\n\r\nfunction createInitialStateInWorkbookRelationships() {\r\n return {\r\n sheets: {},\r\n sharedStrings: undefined,\r\n styles: undefined\r\n }\r\n}\r\n\r\nfunction onOpenTagInWorkbookRelationships(tagName, attributes, state) {\r\n if (tagName === 'Relationship') {\r\n addFilePathForRelation(state, attributes.Id, attributes.Type, attributes.Target)\r\n }\r\n}\r\n\r\nfunction addFilePathForRelation(state, id, type, target) {\r\n switch (type) {\r\n case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles':\r\n state.styles = getFilePathFromRelationTarget(target)\r\n break\r\n case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings':\r\n state.sharedStrings = getFilePathFromRelationTarget(target)\r\n break\r\n case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet':\r\n state.sheets[id] = getFilePathFromRelationTarget(target)\r\n break\r\n }\r\n}\r\n\r\nfunction getFilePathFromRelationTarget(path) {\r\n // Normally, `path` is a relative path inside the ZIP archive,\r\n // like \"worksheets/sheet1.xml\", or \"sharedStrings.xml\", or \"styles.xml\".\r\n // There has been one weird case when file path was an absolute path,\r\n // like \"/xl/worksheets/sheet1.xml\" (specifically for sheets):\r\n // https://github.com/catamphetamine/read-excel-file/pull/95\r\n // Other libraries (like `xlsx`) and software (like Google Docs)\r\n // seem to support such absolute file paths, so this library does too.\r\n if (path[0] === '/') {\r\n return path.slice('/'.length)\r\n }\r\n // // Seems like a path could also be a URL.\r\n // // http://officeopenxml.com/anatomyofOOXML-xlsx.php\r\n // if (/^[a-z]+\\:\\/\\//.test(path)) {\r\n // return path\r\n // }\r\n return 'xl/' + path\r\n}\r\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAcA,CA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O,KAAK,GAAGF,IAAI;AACrB"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = parseNumber;
7
+ // Parses a number from string.
8
+ // Throws an error if the number couldn't be parsed.
9
+ // When parsing floating-point number, is affected by
10
+ // the javascript number encoding precision issues:
11
+ // https://www.youtube.com/watch?v=2gIxbTn7GSc
12
+ // https://www.avioconsulting.com/blog/overcoming-javascript-numeric-precision-issues
13
+ function parseNumber(stringifiedNumber) {
14
+ var parsedNumber = Number(stringifiedNumber);
15
+ if (isNaN(parsedNumber)) {
16
+ throw new Error("Couldn't parse number: ".concat(stringifiedNumber));
17
+ }
18
+ return parsedNumber;
19
+ }
20
+ //# sourceMappingURL=parseNumber.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseNumber.js","names":["parseNumber","stringifiedNumber","parsedNumber","Number","isNaN","Error","concat"],"sources":["../../source/xlsx/parseNumber.js"],"sourcesContent":["// Parses a number from string.\r\n// Throws an error if the number couldn't be parsed.\r\n// When parsing floating-point number, is affected by\r\n// the javascript number encoding precision issues:\r\n// https://www.youtube.com/watch?v=2gIxbTn7GSc\r\n// https://www.avioconsulting.com/blog/overcoming-javascript-numeric-precision-issues\r\nexport default function parseNumber(stringifiedNumber) {\r\n const parsedNumber = Number(stringifiedNumber)\r\n if (isNaN(parsedNumber)) {\r\n throw new Error(`Couldn't parse number: ${stringifiedNumber}`)\r\n }\r\n return parsedNumber\r\n}"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,WAAWA,CAACC,iBAAiB,EAAE;EACrD,IAAMC,YAAY,GAAGC,MAAM,CAACF,iBAAiB,CAAC;EAC9C,IAAIG,KAAK,CAACF,YAAY,CAAC,EAAE;IACvB,MAAM,IAAIG,KAAK,2BAAAC,MAAA,CAA2BL,iBAAiB,CAAE,CAAC;EAChE;EACA,OAAOC,YAAY;AACrB"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createInitialStateInSharedString = createInitialStateInSharedString;
7
+ exports.onCloseTagInSharedString = onCloseTagInSharedString;
8
+ exports.onOpenTagInSharedString = onOpenTagInSharedString;
9
+ exports.onTextInSharedString = onTextInSharedString;
10
+ function createInitialStateInSharedString() {
11
+ return {
12
+ t: false,
13
+ r: false,
14
+ rPh: false,
15
+ string: ''
16
+ };
17
+ }
18
+
19
+ // In an XLSX `sharedStrings.xml` file, a <si/> (string item) element can have
20
+ // either a single child <t/> element (meaning that "rich formatting" is not used)
21
+ // or multiple child <r/> elements (meaning that "rich formatting" is used).
22
+ function onOpenTagInSharedString(tagName, attributes, state) {
23
+ // The possible children of <si> are:
24
+ // * <t>: Represents a simple text string. For plain text, this is the only child.
25
+ // * <r>: Represents a rich text run. When a cell contains text where only some words are bolded, colored, or styled differently, multiple <r> elements are used to break the text into formatted segments.
26
+ // * <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>.
27
+ // * <phoneticPr>: Defines the phonetic properties used for East Asian languages, specifically mapping how strings should be read for sorting and pronunciation.
28
+ if (tagName === 't') {
29
+ state.t = true;
30
+ } else if (tagName === 'r') {
31
+ // The possible children of <r/> are:
32
+ // * <rPr> (Run Properties): The formatting properties for the text (font, size, color, bold, italic, etc.).
33
+ // * <t> (Text): The actual text payload.
34
+ // * <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>.
35
+ state.r = true;
36
+ } else if (tagName === 'rPh') {
37
+ // The possible children of <rPh/> are:
38
+ // * <t> (Text): Contains the actual phonetic text or reading (usually in Katakana for Japanese) that corresponds to the associated character string.
39
+ state.rPh = true;
40
+ }
41
+ }
42
+ function onCloseTagInSharedString(tagName, state) {
43
+ if (tagName === 't') {
44
+ state.t = false;
45
+ } else if (tagName === 'r') {
46
+ state.r = false;
47
+ } else if (tagName === 'rPh') {
48
+ state.rPh = false;
49
+ }
50
+ }
51
+ function onTextInSharedString(text, state) {
52
+ if (state.rPh) {
53
+ // Ignore anything inside `<rPh/>` tags
54
+ } else if (state.t) {
55
+ if (state.r) {
56
+ // An `<r/>` element could contain multiple `<t/>` elements,
57
+ // the text content from all of which should be concatenated.
58
+ state.string += text;
59
+ } else {
60
+ state.string = text;
61
+ }
62
+ }
63
+ }
64
+ //# sourceMappingURL=parseSharedString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseSharedString.js","names":["createInitialStateInSharedString","t","r","rPh","string","onOpenTagInSharedString","tagName","attributes","state","onCloseTagInSharedString","onTextInSharedString","text"],"sources":["../../source/xlsx/parseSharedString.js"],"sourcesContent":["export function createInitialStateInSharedString() {\r\n\treturn {\r\n\t\tt: false,\r\n\t\tr: false,\r\n\t\trPh: false,\r\n\t\tstring: ''\r\n\t}\r\n}\r\n\r\n// In an XLSX `sharedStrings.xml` file, a <si/> (string item) element can have\r\n// either a single child <t/> element (meaning that \"rich formatting\" is not used)\r\n// or multiple child <r/> elements (meaning that \"rich formatting\" is used).\r\nexport function onOpenTagInSharedString(tagName, attributes, state) {\r\n\t// The possible children of <si> are:\r\n\t// * <t>: Represents a simple text string. For plain text, this is the only child.\r\n\t// * <r>: Represents a rich text run. When a cell contains text where only some words are bolded, colored, or styled differently, multiple <r> elements are used to break the text into formatted segments.\r\n\t// * <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\t// * <phoneticPr>: Defines the phonetic properties used for East Asian languages, specifically mapping how strings should be read for sorting and pronunciation.\r\n\tif (tagName === 't') {\r\n\t\tstate.t = true\r\n\t} else if (tagName === 'r') {\r\n\t\t// The possible children of <r/> are:\r\n\t\t// * <rPr> (Run Properties): The formatting properties for the text (font, size, color, bold, italic, etc.).\r\n\t\t// * <t> (Text): The actual text payload.\r\n\t\t// * <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\t\tstate.r = true\r\n\t} else if (tagName === 'rPh') {\r\n\t\t// The possible children of <rPh/> are:\r\n\t\t// * <t> (Text): Contains the actual phonetic text or reading (usually in Katakana for Japanese) that corresponds to the associated character string.\r\n\t\tstate.rPh = true\r\n\t}\r\n}\r\n\r\nexport function onCloseTagInSharedString(tagName, state) {\r\n\tif (tagName === 't') {\r\n\t\tstate.t = false\r\n\t} else if (tagName === 'r') {\r\n\t\tstate.r = false\r\n\t} else if (tagName === 'rPh') {\r\n\t\tstate.rPh = false\r\n\t}\r\n}\r\n\r\nexport function onTextInSharedString(text, state) {\r\n\tif (state.rPh) {\r\n\t\t// Ignore anything inside `<rPh/>` tags\r\n\t} else if (state.t) {\r\n\t\tif (state.r) {\r\n\t\t\t// An `<r/>` element could contain multiple `<t/>` elements,\r\n\t\t\t// the text content from all of which should be concatenated.\r\n\t\t\tstate.string += text\r\n\t\t} else {\r\n\t\t\tstate.string = text\r\n\t\t}\r\n\t}\r\n}"],"mappings":";;;;;;;;;AAAO,SAASA,gCAAgCA,CAAA,EAAG;EAClD,OAAO;IACNC,CAAC,EAAE,KAAK;IACRC,CAAC,EAAE,KAAK;IACRC,GAAG,EAAE,KAAK;IACVC,MAAM,EAAE;EACT,CAAC;AACF;;AAEA;AACA;AACA;AACO,SAASC,uBAAuBA,CAACC,OAAO,EAAEC,UAAU,EAAEC,KAAK,EAAE;EACnE;EACA;EACA;EACA;EACA;EACA,IAAIF,OAAO,KAAK,GAAG,EAAE;IACpBE,KAAK,CAACP,CAAC,GAAG,IAAI;EACf,CAAC,MAAM,IAAIK,OAAO,KAAK,GAAG,EAAE;IAC3B;IACA;IACA;IACA;IACAE,KAAK,CAACN,CAAC,GAAG,IAAI;EACf,CAAC,MAAM,IAAII,OAA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