read-excel-file 5.7.1 → 5.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +45 -19
  3. package/bundle/read-excel-file.min.js +1 -1
  4. package/bundle/read-excel-file.min.js.map +1 -1
  5. package/commonjs/read/coordinates.js +7 -10
  6. package/commonjs/read/coordinates.js.map +1 -1
  7. package/commonjs/read/dropEmptyColumns.js +6 -18
  8. package/commonjs/read/dropEmptyColumns.js.map +1 -1
  9. package/commonjs/read/dropEmptyColumns.test.js.map +1 -1
  10. package/commonjs/read/dropEmptyRows.js +11 -23
  11. package/commonjs/read/dropEmptyRows.js.map +1 -1
  12. package/commonjs/read/dropEmptyRows.test.js.map +1 -1
  13. package/commonjs/read/getData.js +31 -43
  14. package/commonjs/read/getData.js.map +1 -1
  15. package/commonjs/read/isDateTimestamp.js +51 -40
  16. package/commonjs/read/isDateTimestamp.js.map +1 -1
  17. package/commonjs/read/parseCell.js +3 -10
  18. package/commonjs/read/parseCell.js.map +1 -1
  19. package/commonjs/read/parseCellValue.js +28 -59
  20. package/commonjs/read/parseCellValue.js.map +1 -1
  21. package/commonjs/read/parseCells.js +3 -7
  22. package/commonjs/read/parseCells.js.map +1 -1
  23. package/commonjs/read/parseDate.js +5 -5
  24. package/commonjs/read/parseDate.js.map +1 -1
  25. package/commonjs/read/parseDate.test.js.map +1 -1
  26. package/commonjs/read/parseDimensions.js +6 -18
  27. package/commonjs/read/parseDimensions.js.map +1 -1
  28. package/commonjs/read/parseFilePaths.js +4 -11
  29. package/commonjs/read/parseFilePaths.js.map +1 -1
  30. package/commonjs/read/parseProperties.js +6 -8
  31. package/commonjs/read/parseProperties.js.map +1 -1
  32. package/commonjs/read/parseSharedStrings.js +0 -3
  33. package/commonjs/read/parseSharedStrings.js.map +1 -1
  34. package/commonjs/read/parseSheet.js +3 -7
  35. package/commonjs/read/parseSheet.js.map +1 -1
  36. package/commonjs/read/parseStyles.js +13 -21
  37. package/commonjs/read/parseStyles.js.map +1 -1
  38. package/commonjs/read/readSheetNamesBrowser.js +0 -3
  39. package/commonjs/read/readSheetNamesBrowser.js.map +1 -1
  40. package/commonjs/read/readSheetNamesNode.js +0 -3
  41. package/commonjs/read/readSheetNamesNode.js.map +1 -1
  42. package/commonjs/read/readSheetNamesNode.test.js.map +1 -1
  43. package/commonjs/read/readSheetNamesWebWorker.js +0 -3
  44. package/commonjs/read/readSheetNamesWebWorker.js.map +1 -1
  45. package/commonjs/read/readXlsx.js +34 -42
  46. package/commonjs/read/readXlsx.js.map +1 -1
  47. package/commonjs/read/readXlsxFileBrowser.js +0 -5
  48. package/commonjs/read/readXlsxFileBrowser.js.map +1 -1
  49. package/commonjs/read/readXlsxFileContents.js +12 -22
  50. package/commonjs/read/readXlsxFileContents.js.map +1 -1
  51. package/commonjs/read/readXlsxFileNode.js +0 -5
  52. package/commonjs/read/readXlsxFileNode.js.map +1 -1
  53. package/commonjs/read/readXlsxFileNode.test.js.map +1 -1
  54. package/commonjs/read/readXlsxFileWebWorker.js +0 -5
  55. package/commonjs/read/readXlsxFileWebWorker.js.map +1 -1
  56. package/commonjs/read/schema/convertMapToSchema.js +1 -8
  57. package/commonjs/read/schema/convertMapToSchema.js.map +1 -1
  58. package/commonjs/read/schema/convertMapToSchema.test.js.map +1 -1
  59. package/commonjs/read/schema/convertToJson.js +143 -142
  60. package/commonjs/read/schema/convertToJson.js.map +1 -1
  61. package/commonjs/read/schema/convertToJson.legacy.js +60 -0
  62. package/commonjs/read/schema/convertToJson.legacy.js.map +1 -0
  63. package/commonjs/read/schema/convertToJson.legacy.test.js.map +1 -0
  64. package/commonjs/read/schema/convertToJson.spreadsheet.js +25 -0
  65. package/commonjs/read/schema/convertToJson.spreadsheet.js.map +1 -0
  66. package/commonjs/read/schema/convertToJson.spreadsheet.test.js.map +1 -0
  67. package/commonjs/read/schema/convertToJson.test.js.map +1 -1
  68. package/commonjs/read/unpackXlsxFileBrowser.js +3 -9
  69. package/commonjs/read/unpackXlsxFileBrowser.js.map +1 -1
  70. package/commonjs/read/unpackXlsxFileNode.js +9 -15
  71. package/commonjs/read/unpackXlsxFileNode.js.map +1 -1
  72. package/commonjs/types/Boolean.js +0 -4
  73. package/commonjs/types/Boolean.js.map +1 -1
  74. package/commonjs/types/Date.js +0 -12
  75. package/commonjs/types/Date.js.map +1 -1
  76. package/commonjs/types/Email.js +0 -7
  77. package/commonjs/types/Email.js.map +1 -1
  78. package/commonjs/types/Email.test.js.map +1 -1
  79. package/commonjs/types/Integer.js +0 -7
  80. package/commonjs/types/Integer.js.map +1 -1
  81. package/commonjs/types/Integer.test.js.map +1 -1
  82. package/commonjs/types/InvalidError.js +8 -28
  83. package/commonjs/types/InvalidError.js.map +1 -1
  84. package/commonjs/types/Number.js +2 -10
  85. package/commonjs/types/Number.js.map +1 -1
  86. package/commonjs/types/String.js +4 -11
  87. package/commonjs/types/String.js.map +1 -1
  88. package/commonjs/types/URL.js +5 -8
  89. package/commonjs/types/URL.js.map +1 -1
  90. package/commonjs/types/URL.test.js.map +1 -1
  91. package/commonjs/xml/dom.js +6 -25
  92. package/commonjs/xml/dom.js.map +1 -1
  93. package/commonjs/xml/xlsx.js +1 -24
  94. package/commonjs/xml/xlsx.js.map +1 -1
  95. package/commonjs/xml/xml.js +1 -4
  96. package/commonjs/xml/xml.js.map +1 -1
  97. package/commonjs/xml/xmlBrowser.js +1 -2
  98. package/commonjs/xml/xmlBrowser.js.map +1 -1
  99. package/commonjs/xml/xpath/xlsx-xpath.js +3 -16
  100. package/commonjs/xml/xpath/xlsx-xpath.js.map +1 -1
  101. package/commonjs/xml/xpath/xpathBrowser.js +3 -5
  102. package/commonjs/xml/xpath/xpathBrowser.js.map +1 -1
  103. package/commonjs/xml/xpath/xpathNode.js +1 -5
  104. package/commonjs/xml/xpath/xpathNode.js.map +1 -1
  105. package/map/index.cjs +2 -0
  106. package/map/index.cjs.js +7 -0
  107. package/map/index.d.ts +11 -0
  108. package/map/index.js +1 -0
  109. package/map/package.json +17 -0
  110. package/modules/read/coordinates.js +7 -8
  111. package/modules/read/coordinates.js.map +1 -1
  112. package/modules/read/dropEmptyColumns.js +6 -17
  113. package/modules/read/dropEmptyColumns.js.map +1 -1
  114. package/modules/read/dropEmptyColumns.test.js.map +1 -1
  115. package/modules/read/dropEmptyRows.js +11 -22
  116. package/modules/read/dropEmptyRows.js.map +1 -1
  117. package/modules/read/dropEmptyRows.test.js.map +1 -1
  118. package/modules/read/getData.js +31 -39
  119. package/modules/read/getData.js.map +1 -1
  120. package/modules/read/isDateTimestamp.js +52 -39
  121. package/modules/read/isDateTimestamp.js.map +1 -1
  122. package/modules/read/parseCell.js +6 -6
  123. package/modules/read/parseCell.js.map +1 -1
  124. package/modules/read/parseCellValue.js +30 -55
  125. package/modules/read/parseCellValue.js.map +1 -1
  126. package/modules/read/parseCells.js +3 -3
  127. package/modules/read/parseCells.js.map +1 -1
  128. package/modules/read/parseDate.js +5 -4
  129. package/modules/read/parseDate.js.map +1 -1
  130. package/modules/read/parseDate.test.js.map +1 -1
  131. package/modules/read/parseDimensions.js +9 -17
  132. package/modules/read/parseDimensions.js.map +1 -1
  133. package/modules/read/parseFilePaths.js +5 -10
  134. package/modules/read/parseFilePaths.js.map +1 -1
  135. package/modules/read/parseProperties.js +8 -7
  136. package/modules/read/parseProperties.js.map +1 -1
  137. package/modules/read/parseSharedStrings.js +0 -1
  138. package/modules/read/parseSharedStrings.js.map +1 -1
  139. package/modules/read/parseSheet.js +3 -2
  140. package/modules/read/parseSheet.js.map +1 -1
  141. package/modules/read/parseStyles.js +16 -21
  142. package/modules/read/parseStyles.js.map +1 -1
  143. package/modules/read/readSheetNamesBrowser.js +1 -1
  144. package/modules/read/readSheetNamesBrowser.js.map +1 -1
  145. package/modules/read/readSheetNamesNode.js +1 -1
  146. package/modules/read/readSheetNamesNode.js.map +1 -1
  147. package/modules/read/readSheetNamesNode.test.js.map +1 -1
  148. package/modules/read/readSheetNamesWebWorker.js +1 -1
  149. package/modules/read/readSheetNamesWebWorker.js.map +1 -1
  150. package/modules/read/readXlsx.js +37 -35
  151. package/modules/read/readXlsx.js.map +1 -1
  152. package/modules/read/readXlsxFileBrowser.js +1 -1
  153. package/modules/read/readXlsxFileBrowser.js.map +1 -1
  154. package/modules/read/readXlsxFileContents.js +12 -17
  155. package/modules/read/readXlsxFileContents.js.map +1 -1
  156. package/modules/read/readXlsxFileNode.js +1 -1
  157. package/modules/read/readXlsxFileNode.js.map +1 -1
  158. package/modules/read/readXlsxFileNode.test.js.map +1 -1
  159. package/modules/read/readXlsxFileWebWorker.js +1 -1
  160. package/modules/read/readXlsxFileWebWorker.js.map +1 -1
  161. package/modules/read/schema/convertMapToSchema.js +1 -7
  162. package/modules/read/schema/convertMapToSchema.js.map +1 -1
  163. package/modules/read/schema/convertMapToSchema.test.js.map +1 -1
  164. package/modules/read/schema/convertToJson.js +143 -133
  165. package/modules/read/schema/convertToJson.js.map +1 -1
  166. package/modules/read/schema/convertToJson.legacy.js +53 -0
  167. package/modules/read/schema/convertToJson.legacy.js.map +1 -0
  168. package/modules/read/schema/convertToJson.legacy.test.js.map +1 -0
  169. package/modules/read/schema/convertToJson.spreadsheet.js +19 -0
  170. package/modules/read/schema/convertToJson.spreadsheet.js.map +1 -0
  171. package/modules/read/schema/convertToJson.spreadsheet.test.js.map +1 -0
  172. package/modules/read/schema/convertToJson.test.js.map +1 -1
  173. package/modules/read/unpackXlsxFileBrowser.js +4 -7
  174. package/modules/read/unpackXlsxFileBrowser.js.map +1 -1
  175. package/modules/read/unpackXlsxFileNode.js +9 -7
  176. package/modules/read/unpackXlsxFileNode.js.map +1 -1
  177. package/modules/types/Boolean.js +0 -1
  178. package/modules/types/Boolean.js.map +1 -1
  179. package/modules/types/Date.js +0 -8
  180. package/modules/types/Date.js.map +1 -1
  181. package/modules/types/Email.js +0 -2
  182. package/modules/types/Email.js.map +1 -1
  183. package/modules/types/Email.test.js.map +1 -1
  184. package/modules/types/Integer.js +0 -2
  185. package/modules/types/Integer.js.map +1 -1
  186. package/modules/types/Integer.test.js.map +1 -1
  187. package/modules/types/InvalidError.js +7 -25
  188. package/modules/types/InvalidError.js.map +1 -1
  189. package/modules/types/Number.js +2 -7
  190. package/modules/types/Number.js.map +1 -1
  191. package/modules/types/String.js +4 -8
  192. package/modules/types/String.js.map +1 -1
  193. package/modules/types/URL.js +5 -4
  194. package/modules/types/URL.js.map +1 -1
  195. package/modules/types/URL.test.js.map +1 -1
  196. package/modules/xml/dom.js +6 -18
  197. package/modules/xml/dom.js.map +1 -1
  198. package/modules/xml/xlsx.js +4 -13
  199. package/modules/xml/xlsx.js.map +1 -1
  200. package/modules/xml/xml.js.map +1 -1
  201. package/modules/xml/xmlBrowser.js.map +1 -1
  202. package/modules/xml/xpath/xlsx-xpath.js +2 -1
  203. package/modules/xml/xpath/xlsx-xpath.js.map +1 -1
  204. package/modules/xml/xpath/xpathBrowser.js +3 -4
  205. package/modules/xml/xpath/xpathBrowser.js.map +1 -1
  206. package/modules/xml/xpath/xpathNode.js +1 -0
  207. package/modules/xml/xpath/xpathNode.js.map +1 -1
  208. package/package.json +6 -1
  209. package/schema/index.cjs +2 -2
  210. package/schema/index.cjs.js +2 -2
  211. package/schema/index.d.ts +7 -2
  212. package/schema/index.js +1 -1
  213. package/types.d.ts +25 -2
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = isDateTimestamp;
7
-
8
7
  function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
-
10
8
  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); }
11
-
12
- 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; }
13
-
9
+ 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; }
14
10
  // XLSX does have "d" type for dates, but it's not commonly used.
15
11
  // Instead, it prefers using "n" type for storing dates as timestamps.
16
12
  //
@@ -24,28 +20,30 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
24
20
  function isDateTimestamp(styleId, styles, options) {
25
21
  if (styleId) {
26
22
  var style = styles[styleId];
27
-
28
23
  if (!style) {
29
24
  throw new Error("Cell style not found: ".concat(styleId));
30
25
  }
31
-
32
26
  if (!style.numberFormat) {
33
27
  return false;
34
28
  }
35
-
36
- if ( // Whether it's a "number format" that's conventionally used for storing date timestamps.
37
- BUILT_IN_DATE_NUMBER_FORMAT_IDS.indexOf(Number(style.numberFormat.id)) >= 0 || // Whether it's a "number format" that uses a "formatting template"
29
+ if (
30
+ // Whether it's a "number format" that's conventionally used for storing date timestamps.
31
+ BUILT_IN_DATE_NUMBER_FORMAT_IDS.indexOf(Number(style.numberFormat.id)) >= 0 ||
32
+ // Whether it's a "number format" that uses a "formatting template"
38
33
  // that the developer is certain is a date formatting template.
39
- options.dateFormat && style.numberFormat.template === options.dateFormat || // Whether the "smart formatting template" feature is not disabled
34
+ options.dateFormat && style.numberFormat.template === options.dateFormat ||
35
+ // Whether the "smart formatting template" feature is not disabled
40
36
  // and it has detected that it's a date formatting template by looking at it.
41
37
  options.smartDateParser !== false && style.numberFormat.template && isDateTemplate(style.numberFormat.template)) {
42
38
  return true;
43
39
  }
44
40
  }
45
- } // https://hexdocs.pm/xlsxir/number_styles.html
41
+ }
46
42
 
43
+ // https://hexdocs.pm/xlsxir/number_styles.html
44
+ var BUILT_IN_DATE_NUMBER_FORMAT_IDS = [14, 15, 16, 17, 18, 19, 20, 21, 22, 27, 30, 36, 45, 46, 47, 50, 57];
47
45
 
48
- var BUILT_IN_DATE_NUMBER_FORMAT_IDS = [14, 15, 16, 17, 18, 19, 20, 21, 22, 27, 30, 36, 45, 46, 47, 50, 57]; // On some date formats, there's an "[$-414]" prefix.
46
+ // On some date formats, there's an "[$-414]" prefix.
49
47
  // I don't have any idea what that is.
50
48
  //
51
49
  // https://stackoverflow.com/questions/4730152/what-indicates-an-office-open-xml-cell-contains-a-date-time-value
@@ -55,58 +53,71 @@ var BUILT_IN_DATE_NUMBER_FORMAT_IDS = [14, 15, 16, 17, 18, 19, 20, 21, 22, 27, 3
55
53
  // * 27 (built-in format) "[$-404]e/m/d"
56
54
  // * 164 (custom format) "[$-414]mmmm\ yyyy;@"
57
55
  //
56
+ var DATE_FORMAT_WEIRD_PREFIX = /^\[\$-414\]/;
58
57
 
59
- var DATE_FORMAT_WEIRD_PREFIX = /^\[\$-414\]/; // On some date formats, there's an ";@" postfix.
58
+ // On some date formats, there's an ";@" postfix.
60
59
  // I don't have any idea what that is.
61
60
  // Examples:
62
61
  //
63
62
  // * 164 (custom format) "m/d/yyyy;@"
64
63
  // * 164 (custom format) "[$-414]mmmm\ yyyy;@"
65
64
  //
66
-
67
65
  var DATE_FORMAT_WEIRD_POSTFIX = /;@$/;
68
-
69
66
  function isDateTemplate(template) {
70
67
  // Date format tokens could be in upper case or in lower case.
71
68
  // There seems to be no single standard.
72
69
  // So lowercase the template first.
73
- template = template.toLowerCase(); // On some date formats, there's an "[$-414]" prefix.
74
- // I don't have any idea what that is. Trim it.
70
+ template = template.toLowerCase();
75
71
 
76
- template = template.replace(DATE_FORMAT_WEIRD_PREFIX, ''); // On some date formats, there's an ";@" postfix.
72
+ // On some date formats, there's an "[$-414]" prefix.
77
73
  // I don't have any idea what that is. Trim it.
74
+ template = template.replace(DATE_FORMAT_WEIRD_PREFIX, '');
78
75
 
76
+ // On some date formats, there's an ";@" postfix.
77
+ // I don't have any idea what that is. Trim it.
79
78
  template = template.replace(DATE_FORMAT_WEIRD_POSTFIX, '');
80
79
  var tokens = template.split(/\W+/);
81
-
82
80
  for (var _iterator = _createForOfIteratorHelperLoose(tokens), _step; !(_step = _iterator()).done;) {
83
81
  var token = _step.value;
84
-
85
82
  if (DATE_TEMPLATE_TOKENS.indexOf(token) < 0) {
86
83
  return false;
87
84
  }
88
85
  }
89
-
90
86
  return true;
91
- } // These tokens could be in upper case or in lower case.
92
- // There seems to be no single standard, so using lower case.
87
+ }
93
88
 
94
-
95
- var DATE_TEMPLATE_TOKENS = [// Seconds (min two digits). Example: "05".
96
- 'ss', // Minutes (min two digits). Example: "05". Could also be "Months". Weird.
97
- 'mm', // Hours. Example: "1".
98
- 'h', // Hours (min two digits). Example: "01".
99
- 'hh', // "AM" part of "AM/PM". Lowercased just in case.
100
- 'am', // "PM" part of "AM/PM". Lowercased just in case.
101
- 'pm', // Day. Example: "1"
102
- 'd', // Day (min two digits). Example: "01"
103
- 'dd', // Month (numeric). Example: "1".
104
- 'm', // Month (numeric, min two digits). Example: "01". Could also be "Minutes". Weird.
105
- 'mm', // Month (shortened month name). Example: "Jan".
106
- 'mmm', // Month (full month name). Example: "January".
107
- 'mmmm', // Two-digit year. Example: "20".
108
- 'yy', // Full year. Example: "2020".
109
- 'yyyy', // I don't have any idea what "e" means.
89
+ // These tokens could be in upper case or in lower case.
90
+ // There seems to be no single standard, so using lower case.
91
+ var DATE_TEMPLATE_TOKENS = [
92
+ // Seconds (min two digits). Example: "05".
93
+ 'ss',
94
+ // Minutes (min two digits). Example: "05". Could also be "Months". Weird.
95
+ 'mm',
96
+ // Hours. Example: "1".
97
+ 'h',
98
+ // Hours (min two digits). Example: "01".
99
+ 'hh',
100
+ // "AM" part of "AM/PM". Lowercased just in case.
101
+ 'am',
102
+ // "PM" part of "AM/PM". Lowercased just in case.
103
+ 'pm',
104
+ // Day. Example: "1"
105
+ 'd',
106
+ // Day (min two digits). Example: "01"
107
+ 'dd',
108
+ // Month (numeric). Example: "1".
109
+ 'm',
110
+ // Month (numeric, min two digits). Example: "01". Could also be "Minutes". Weird.
111
+ 'mm',
112
+ // Month (shortened month name). Example: "Jan".
113
+ 'mmm',
114
+ // Month (full month name). Example: "January".
115
+ 'mmmm',
116
+ // Two-digit year. Example: "20".
117
+ 'yy',
118
+ // Full year. Example: "2020".
119
+ 'yyyy',
120
+ // I don't have any idea what "e" means.
110
121
  // It's used in "built-in" XLSX formats:
111
122
  // * 27 '[$-404]e/m/d';
112
123
  // * 36 '[$-404]e/m/d';
@@ -1 +1 @@
1
- {"version":3,"file":"isDateTimestamp.js","names":["isDateTimestamp","styleId","styles","options","style","Error","numberFormat","BUILT_IN_DATE_NUMBER_FORMAT_IDS","indexOf","Number","id","dateFormat","template","smartDateParser","isDateTemplate","DATE_FORMAT_WEIRD_PREFIX","DATE_FORMAT_WEIRD_POSTFIX","toLowerCase","replace","tokens","split","token","DATE_TEMPLATE_TOKENS"],"sources":["../../source/read/isDateTimestamp.js"],"sourcesContent":["// 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//\r\n// Whether a numeric value is a number or a date timestamp, it sometimes could be\r\n// detected by looking at the value \"format\" and seeing if it's a date-specific one.\r\n// https://github.com/catamphetamine/read-excel-file/issues/3#issuecomment-395770777\r\n//\r\n// The list of generic numeric value \"formats\":\r\n// https://xlsxwriter.readthedocs.io/format.html#format-set-num-format\r\n//\r\nexport default function isDateTimestamp(styleId, styles, options) {\r\n if (styleId) {\r\n const style = styles[styleId]\r\n if (!style) {\r\n throw new Error(`Cell style not found: ${styleId}`)\r\n }\r\n if (!style.numberFormat) {\r\n return false\r\n }\r\n if (\r\n // Whether it's a \"number format\" that's conventionally used for storing date timestamps.\r\n BUILT_IN_DATE_NUMBER_FORMAT_IDS.indexOf(Number(style.numberFormat.id)) >= 0 ||\r\n // Whether it's a \"number format\" that uses a \"formatting template\"\r\n // that the developer is certain is a date formatting template.\r\n (options.dateFormat && style.numberFormat.template === options.dateFormat) ||\r\n // Whether the \"smart formatting template\" feature is not disabled\r\n // and it has detected that it's a date formatting template by looking at it.\r\n (options.smartDateParser !== false && style.numberFormat.template && isDateTemplate(style.numberFormat.template))\r\n ) {\r\n return true\r\n }\r\n }\r\n}\r\n\r\n// https://hexdocs.pm/xlsxir/number_styles.html\r\nconst BUILT_IN_DATE_NUMBER_FORMAT_IDS = [14,15,16,17,18,19,20,21,22,27,30,36,45,46,47,50,57]\r\n\r\n// On some date formats, there's an \"[$-414]\" prefix.\r\n// I don't have any idea what that is.\r\n//\r\n// https://stackoverflow.com/questions/4730152/what-indicates-an-office-open-xml-cell-contains-a-date-time-value\r\n//\r\n// Examples:\r\n//\r\n// * 27 (built-in format) \"[$-404]e/m/d\"\r\n// * 164 (custom format) \"[$-414]mmmm\\ yyyy;@\"\r\n//\r\nconst DATE_FORMAT_WEIRD_PREFIX = /^\\[\\$-414\\]/\r\n\r\n// On some date formats, there's an \";@\" postfix.\r\n// I don't have any idea what that is.\r\n// Examples:\r\n//\r\n// * 164 (custom format) \"m/d/yyyy;@\"\r\n// * 164 (custom format) \"[$-414]mmmm\\ yyyy;@\"\r\n//\r\nconst DATE_FORMAT_WEIRD_POSTFIX = /;@$/\r\n\r\nfunction isDateTemplate(template) {\r\n // Date format tokens could be in upper case or in lower case.\r\n // There seems to be no single standard.\r\n // So lowercase the template first.\r\n template = template.toLowerCase()\r\n\r\n // On some date formats, there's an \"[$-414]\" prefix.\r\n // I don't have any idea what that is. Trim it.\r\n template = template.replace(DATE_FORMAT_WEIRD_PREFIX, '')\r\n\r\n // On some date formats, there's an \";@\" postfix.\r\n // I don't have any idea what that is. Trim it.\r\n template = template.replace(DATE_FORMAT_WEIRD_POSTFIX, '')\r\n\r\n const tokens = template.split(/\\W+/)\r\n for (const token of tokens) {\r\n if (DATE_TEMPLATE_TOKENS.indexOf(token) < 0) {\r\n return false\r\n }\r\n }\r\n return true\r\n}\r\n\r\n// These tokens could be in upper case or in lower case.\r\n// There seems to be no single standard, so using lower case.\r\nconst DATE_TEMPLATE_TOKENS = [\r\n // Seconds (min two digits). Example: \"05\".\r\n 'ss',\r\n // Minutes (min two digits). Example: \"05\". Could also be \"Months\". Weird.\r\n 'mm',\r\n // Hours. Example: \"1\".\r\n 'h',\r\n // Hours (min two digits). Example: \"01\".\r\n 'hh',\r\n // \"AM\" part of \"AM/PM\". Lowercased just in case.\r\n 'am',\r\n // \"PM\" part of \"AM/PM\". Lowercased just in case.\r\n 'pm',\r\n // Day. Example: \"1\"\r\n 'd',\r\n // Day (min two digits). Example: \"01\"\r\n 'dd',\r\n // Month (numeric). Example: \"1\".\r\n 'm',\r\n // Month (numeric, min two digits). Example: \"01\". Could also be \"Minutes\". Weird.\r\n 'mm',\r\n // Month (shortened month name). Example: \"Jan\".\r\n 'mmm',\r\n // Month (full month name). Example: \"January\".\r\n 'mmmm',\r\n // Two-digit year. Example: \"20\".\r\n 'yy',\r\n // Full year. Example: \"2020\".\r\n 'yyyy',\r\n\r\n // I don't have any idea what \"e\" means.\r\n // It's used in \"built-in\" XLSX formats:\r\n // * 27 '[$-404]e/m/d';\r\n // * 36 '[$-404]e/m/d';\r\n // * 50 '[$-404]e/m/d';\r\n // * 57 '[$-404]e/m/d';\r\n 'e'\r\n];"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,eAAT,CAAyBC,OAAzB,EAAkCC,MAAlC,EAA0CC,OAA1C,EAAmD;EAChE,IAA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AAjB,EAA2C,EAA3C,CAAX,CARgC,CAUhC;EACA;;EACAH,QAAQ,GAAGA,QAAQ,CAACM,OAAT,CAAiBF,yBAAjB,EAA4C,EAA5C,CAAX;EAEA,IAAMG,MAAM,GAAGP,QAAQ,CAACQ,KAAT,CAAe,KAAf,CAAf;;EACA,qDAAoBD,MAApB,wCAA4B;IAAA,IAAjBE,KAAiB;;IAC1B,IAAIC,oBAAoB,CAACd,OAArB,CAA6Ba,KAA7B,IAAsC,CAA1C,EAA6C;MAC3C,OAAO,KAAP;IACD;EACF;;EACD,OAAO,IAAP;AACD,C,CAED;AACA;;;AACA,IAAMC,oBAAoB,GAAG,CAC3B;AACA,IAF2B,EAG3B;AACA,IAJ2B,EAK3B;AACA,GAN2B,EAO3B;AACA,IAR2B,EAS3B;AACA,IAV2B,EAW3B;AACA,IAZ2B,EAa3B;AACA,GAd2B,EAe3B;AACA,IAhB2B,EAiB3B;AACA,GAlB2B,EAmB3B;AACA,IApB2B,EAqB3B;AACA,KAtB2B,EAuB3B;AACA,MAxB2B,EAyB3B;AACA,IA1B2B,EA2B3B;AACA,MA5B2B,EA8B3B;AACA;AACA;AACA;AACA;AACA;AACA,GApC2B,CAA7B"}
1
+ {"version":3,"file":"isDateTimestamp.js","names":["isDateTimestamp","styleId","styles","options","style","Error","concat","numberFormat","BUILT_IN_DATE_NUMBER_FORMAT_IDS","indexOf","Number","id","dateFormat","template","smartDateParser","isDateTemplate","DATE_FORMAT_WEIRD_PREFIX","DATE_FORMAT_WEIRD_POSTFIX","toLowerCase","replace","tokens","split","_iterator","_createForOfIteratorHelperLoose","_step","done","token","value","DATE_TEMPLATE_TOKENS"],"sources":["../../source/read/isDateTimestamp.js"],"sourcesContent":["// 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//\r\n// Whether a numeric value is a number or a date timestamp, it sometimes could be\r\n// detected by looking at the value \"format\" and seeing if it's a date-specific one.\r\n// https://github.com/catamphetamine/read-excel-file/issues/3#issuecomment-395770777\r\n//\r\n// The list of generic numeric value \"formats\":\r\n// https://xlsxwriter.readthedocs.io/format.html#format-set-num-format\r\n//\r\nexport default function isDateTimestamp(styleId, styles, options) {\r\n if (styleId) {\r\n const style = styles[styleId]\r\n if (!style) {\r\n throw new Error(`Cell style not found: ${styleId}`)\r\n }\r\n if (!style.numberFormat) {\r\n return false\r\n }\r\n if (\r\n // Whether it's a \"number format\" that's conventionally used for storing date timestamps.\r\n BUILT_IN_DATE_NUMBER_FORMAT_IDS.indexOf(Number(style.numberFormat.id)) >= 0 ||\r\n // Whether it's a \"number format\" that uses a \"formatting template\"\r\n // that the developer is certain is a date formatting template.\r\n (options.dateFormat && style.numberFormat.template === options.dateFormat) ||\r\n // Whether the \"smart formatting template\" feature is not disabled\r\n // and it has detected that it's a date formatting template by looking at it.\r\n (options.smartDateParser !== false && style.numberFormat.template && isDateTemplate(style.numberFormat.template))\r\n ) {\r\n return true\r\n }\r\n }\r\n}\r\n\r\n// https://hexdocs.pm/xlsxir/number_styles.html\r\nconst BUILT_IN_DATE_NUMBER_FORMAT_IDS = [14,15,16,17,18,19,20,21,22,27,30,36,45,46,47,50,57]\r\n\r\n// On some date formats, there's an \"[$-414]\" prefix.\r\n// I don't have any idea what that is.\r\n//\r\n// https://stackoverflow.com/questions/4730152/what-indicates-an-office-open-xml-cell-contains-a-date-time-value\r\n//\r\n// Examples:\r\n//\r\n// * 27 (built-in format) \"[$-404]e/m/d\"\r\n// * 164 (custom format) \"[$-414]mmmm\\ yyyy;@\"\r\n//\r\nconst DATE_FORMAT_WEIRD_PREFIX = /^\\[\\$-414\\]/\r\n\r\n// On some date formats, there's an \";@\" postfix.\r\n// I don't have any idea what that is.\r\n// Examples:\r\n//\r\n// * 164 (custom format) \"m/d/yyyy;@\"\r\n// * 164 (custom format) \"[$-414]mmmm\\ yyyy;@\"\r\n//\r\nconst DATE_FORMAT_WEIRD_POSTFIX = /;@$/\r\n\r\nfunction isDateTemplate(template) {\r\n // Date format tokens could be in upper case or in lower case.\r\n // There seems to be no single standard.\r\n // So lowercase the template first.\r\n template = template.toLowerCase()\r\n\r\n // On some date formats, there's an \"[$-414]\" prefix.\r\n // I don't have any idea what that is. Trim it.\r\n template = template.replace(DATE_FORMAT_WEIRD_PREFIX, '')\r\n\r\n // On some date formats, there's an \";@\" postfix.\r\n // I don't have any idea what that is. Trim it.\r\n template = template.replace(DATE_FORMAT_WEIRD_POSTFIX, '')\r\n\r\n const tokens = template.split(/\\W+/)\r\n for (const token of tokens) {\r\n if (DATE_TEMPLATE_TOKENS.indexOf(token) < 0) {\r\n return false\r\n }\r\n }\r\n return true\r\n}\r\n\r\n// These tokens could be in upper case or in lower case.\r\n// There seems to be no single standard, so using lower case.\r\nconst DATE_TEMPLATE_TOKENS = [\r\n // Seconds (min two digits). Example: \"05\".\r\n 'ss',\r\n // Minutes (min two digits). Example: \"05\". Could also be \"Months\". Weird.\r\n 'mm',\r\n // Hours. Example: \"1\".\r\n 'h',\r\n // Hours (min two digits). Example: \"01\".\r\n 'hh',\r\n // \"AM\" part of \"AM/PM\". Lowercased just in case.\r\n 'am',\r\n // \"PM\" part of \"AM/PM\". Lowercased just in case.\r\n 'pm',\r\n // Day. Example: \"1\"\r\n 'd',\r\n // Day (min two digits). Example: \"01\"\r\n 'dd',\r\n // Month (numeric). Example: \"1\".\r\n 'm',\r\n // Month (numeric, min two digits). Example: \"01\". Could also be \"Minutes\". Weird.\r\n 'mm',\r\n // Month (shortened month name). Example: \"Jan\".\r\n 'mmm',\r\n // Month (full month name). Example: \"January\".\r\n 'mmmm',\r\n // Two-digit year. Example: \"20\".\r\n 'yy',\r\n // Full year. Example: \"2020\".\r\n 'yyyy',\r\n\r\n // I don't have any idea what \"e\" means.\r\n // It's used in \"built-in\" XLSX formats:\r\n // * 27 '[$-404]e/m/d';\r\n // * 36 '[$-404]e/m/d';\r\n // * 50 '[$-404]e/m/d';\r\n // * 57 '[$-404]e/m/d';\r\n 'e'\r\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AGA,QAAQ,CAACK,WAAW,CAAC,CAAC;;EAEjC;EACA;EACAL,QAAQ,GAAGA,QAAQ,CAACM,OAAO,CAACH,wBAAwB,EAAE,EAAE,CAAC;;EAEzD;EACA;EACAH,QAAQ,GAAGA,QAAQ,CAACM,OAAO,CAACF,yBAAyB,EAAE,EAAE,CAAC;EAE1D,IAAMG,MAAM,GAAGP,QAAQ,CAACQ,KAAK,CAAC,KAAK,CAAC;EACpC,SAAAC,SAAA,GAAAC,+BAAA,CAAoBH,MAAM,GAAAI,KAAA,IAAAA,KAAA,GAAAF,SAAA,IAAAG,IAAA,GAAE;IAAA,IAAjBC,KAAK,GAAAF,KAAA,CAAAG,KAAA;IACd,IAAIC,oBAAoB,CAACnB,OAAO,CAACiB,KAAK,CAAC,GAAG,CAAC,EAAE;MAC3C,OAAO,KAAK;IACd;EACF;EACA,OAAO,IAAI;AACb;;AAEA;AACA;AACA,IAAME,oBAAoB,GAAG;AAC3B;AACA,IAAI;AACJ;AACA,IAAI;AACJ;AACA,GAAG;AACH;AACA,IAAI;AACJ;AACA,IAAI;AACJ;AACA,IAAI;AACJ;AACA,GAAG;AACH;AACA,IAAI;AACJ;AACA,GAAG;AACH;AACA,IAAI;AACJ;AACA,KAAK;AACL;AACA,MAAM;AACN;AACA,IAAI;AACJ;AACA,MAAM;AAEN;AACA;AACA;AACA;AACA;AACA;AACA,GAAG,CACJ"}
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = parseCell;
7
-
8
7
  var _parseCellValue = _interopRequireDefault(require("./parseCellValue.js"));
9
-
10
8
  var _coordinates = require("./coordinates.js");
11
-
12
9
  var _xlsx = require("../xml/xlsx.js");
13
-
14
10
  var _dom = require("../xml/dom.js");
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
-
18
12
  // Example of a `<c/>`ell element:
19
13
  //
20
14
  // <c>
@@ -42,17 +36,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
42
36
  //
43
37
  function parseCell(node, sheet, xml, values, styles, properties, options) {
44
38
  var coords = (0, _coordinates.parseCellCoordinates)(node.getAttribute('r'));
45
- var valueElement = (0, _xlsx.getCellValue)(sheet, node); // For `xpath`, `value` can be `undefined` while for native `DOMParser` it's `null`.
39
+ var valueElement = (0, _xlsx.getCellValue)(sheet, node);
40
+
41
+ // For `xpath`, `value` can be `undefined` while for native `DOMParser` it's `null`.
46
42
  // So using `value && ...` instead of `if (value !== undefined) { ... }` here
47
43
  // for uniform compatibility with both `xpath` and native `DOMParser`.
48
-
49
44
  var value = valueElement && valueElement.textContent;
50
45
  var type;
51
-
52
46
  if (node.hasAttribute('t')) {
53
47
  type = node.getAttribute('t');
54
48
  }
55
-
56
49
  return {
57
50
  row: coords[0],
58
51
  column: coords[1],
@@ -1 +1 @@
1
- {"version":3,"file":"parseCell.js","names":["parseCell","node","sheet","xml","values","styles","properties","options","coords","parseCellCoordinates","getAttribute","valueElement","getCellValue","value","textContent","type","hasAttribute","row","column","parseCellValue","getInlineStringValue","getCellInlineStringValue","getInlineStringXml","getOuterXml","getStyleId"],"sources":["../../source/read/parseCell.js"],"sourcesContent":["import parseCellValue from './parseCellValue.js'\r\n\r\nimport {\r\n parseCellCoordinates\r\n} from './coordinates.js'\r\n\r\nimport {\r\n getCellValue,\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(node, sheet, xml, values, styles, properties, options) {\r\n const coords = parseCellCoordinates(node.getAttribute('r'))\r\n\r\n const valueElement = getCellValue(sheet, node)\r\n\r\n // For `xpath`, `value` can be `undefined` while for native `DOMParser` it's `null`.\r\n // So using `value && ...` instead of `if (value !== undefined) { ... }` here\r\n // for uniform compatibility with both `xpath` and native `DOMParser`.\r\n let value = valueElement && valueElement.textContent\r\n\r\n let type\r\n if (node.hasAttribute('t')) {\r\n type = node.getAttribute('t')\r\n }\r\n\r\n return {\r\n row: coords[0],\r\n column: coords[1],\r\n value: parseCellValue(value, type, {\r\n getInlineStringValue: () => getCellInlineStringValue(sheet, node),\r\n getInlineStringXml: () => getOuterXml(node),\r\n getStyleId: () => node.getAttribute('s'),\r\n styles,\r\n values,\r\n properties,\r\n options\r\n })\r\n }\r\n}"],"mappings":";;;;;;;AAAA;;AAEA;;AAIA;;AAKA;;;;AAIA;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,SAASA,SAAT,CAAmBC,IAAnB,EAAyBC,KAAzB,EAAgCC,GAAhC,EAAqCC,MAArC,EAA6CC,MAA7C,EAAqDC,UAArD,EAAiEC,OAAjE,EAA0E;EACvF,IAAMC,MAAM,GAAG,IAAAC,iCAAA,EAAqBR,IAAI,CAACS,YAAL,CAAkB,GAAlB,CAArB,CAAf;EAEA,IAAMC,YAAY,GAAG,IAAAC,kBAAA,EAAaV,KAAb,EAAoBD,IAApB,CAArB,CAHuF,CAKvF;EACA;EACA;;EACA,IAAIY,KAAK,GAAGF,YAAY,IAAIA,YAAY,CAACG,WAAzC;EAEA,IAAIC,IAAJ;;EACA,IAAId,IAAI,CAACe,YAAL,CAAkB,GAAlB,CAAJ,EAA4B;IAC1BD,IAAI,GAAGd,IAAI,CAACS,YAAL,CAAkB,GAAlB,CAAP;EACD;;EAED,OAAO;IACLO,GAAG,EAAET,MAAM,CAAC,CAAD,CADN;IAELU,MAAM,EAAEV,MAAM,CAAC,CAAD,CAFT;IAGLK,KAAK,EAAE,IAAAM,0BAAA,EAAeN,KAAf,EAAsBE,IAAtB,EAA4B;MACjCK,oBAAoB,EAAE;QAAA,OAAM,IAAAC,8BAAA,EAAyBnB,KAAzB,EAAgCD,IAAhC,CAAN;MAAA,CADW;MAEjCqB,kBAAkB,EAAE;QAAA,OAAM,IAAAC,gBAAA,EAAYtB,IAAZ,CAAN;MAAA,CAFa;MAGjCuB,UAAU,EAAE;QAAA,OAAMvB,IAAI,CAACS,YAAL,CAAkB,GAAlB,CAAN;MAAA,CAHqB;MAIjCL,MAAM,EAANA,MAJiC;MAKjCD,MAAM,EAANA,MALiC;MAMjCE,UAAU,EAAVA,UANiC;MAOjCC,OAAO,EAAPA;IAPiC,CAA5B;EAHF,CAAP;AAaD"}
1
+ {"version":3,"file":"parseCell.js","names":["_parseCellValue","_interopRequireDefault","require","_coordinates","_xlsx","_dom","obj","__esModule","parseCell","node","sheet","xml","values","styles","properties","options","coords","parseCellCoordinates","getAttribute","valueElement","getCellValue","value","textContent","type","hasAttribute","row","column","parseCellValue","getInlineStringValue","getCellInlineStringValue","getInlineStringXml","getOuterXml","getStyleId"],"sources":["../../source/read/parseCell.js"],"sourcesContent":["import parseCellValue from './parseCellValue.js'\r\n\r\nimport {\r\n parseCellCoordinates\r\n} from './coordinates.js'\r\n\r\nimport {\r\n getCellValue,\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(node, sheet, xml, values, styles, properties, options) {\r\n const coords = parseCellCoordinates(node.getAttribute('r'))\r\n\r\n const valueElement = getCellValue(sheet, node)\r\n\r\n // For `xpath`, `value` can be `undefined` while for native `DOMParser` it's `null`.\r\n // So using `value && ...` instead of `if (value !== undefined) { ... }` here\r\n // for uniform compatibility with both `xpath` and native `DOMParser`.\r\n let value = valueElement && valueElement.textContent\r\n\r\n let type\r\n if (node.hasAttribute('t')) {\r\n type = node.getAttribute('t')\r\n }\r\n\r\n return {\r\n row: coords[0],\r\n column: coords[1],\r\n value: parseCellValue(value, type, {\r\n getInlineStringValue: () => getCellInlineStringValue(sheet, node),\r\n getInlineStringXml: () => getOuterXml(node),\r\n getStyleId: () => node.getAttribute('s'),\r\n styles,\r\n values,\r\n properties,\r\n options\r\n })\r\n }\r\n}"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AAIA,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,IAAI,EAAEC,KAAK,EAAEC,GAAG,EAAEC,MAAM,EAAEC,MAAM,EAAEC,UAAU,EAAEC,OAAO,EAAE;EACvF,IAAMC,MAAM,GAAG,IAAAC,iCAAoB,EAACR,IAAI,CAACS,YAAY,CAAC,GAAG,CAAC,CAAC;EAE3D,IAAMC,YAAY,GAAG,IAAAC,kBAAY,EAACV,KAAK,EAAED,IAAI,CAAC;;EAE9C;EACA;EACA;EACA,IAAIY,KAAK,GAAGF,YAAY,IAAIA,YAAY,CAACG,WAAW;EAEpD,IAAIC,IAAI;EACR,IAAId,IAAI,CAACe,YAAY,CAAC,GAAG,CAAC,EAAE;IAC1BD,IAAI,GAAGd,IAAI,CAACS,YAAY,CAAC,GAAG,CAAC;EAC/B;EAEA,OAAO;IACLO,GAAG,EAAET,MAAM,CAAC,CAAC,CAAC;IACdU,MAAM,EAAEV,MAAM,CAAC,CAAC,CAAC;IACjBK,KAAK,EAAE,IAAAM,0BAAc,EAACN,KAAK,EAAEE,IAAI,EAAE;MACjCK,oBAAoB,EAAE,SAAAA,qBAAA;QAAA,OAAM,IAAAC,8BAAwB,EAACnB,KAAK,EAAED,IAAI,CAAC;MAAA;MACjEqB,kBAAkB,EAAE,SAAAA,mBAAA;QAAA,OAAM,IAAAC,gBAAW,EAACtB,IAAI,CAAC;MAAA;MAC3CuB,UAAU,EAAE,SAAAA,WAAA;QAAA,OAAMvB,IAAI,CAACS,YAAY,CAAC,GAAG,CAAC;MAAA;MACxCL,MAAM,EAANA,MAAM;MACND,MAAM,EAANA,MAAM;MACNE,UAAU,EAAVA,UAAU;MACVC,OAAO,EAAPA;IACF,CAAC;EACH,CAAC;AACH"}
@@ -4,35 +4,30 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = parseCellValue;
7
-
8
7
  var _parseDate = _interopRequireDefault(require("./parseDate.js"));
9
-
10
8
  var _isDateTimestamp = _interopRequireDefault(require("./isDateTimestamp.js"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
-
14
10
  // Parses a string `value` of a cell.
15
11
  function parseCellValue(value, type, _ref) {
16
12
  var getInlineStringValue = _ref.getInlineStringValue,
17
- getInlineStringXml = _ref.getInlineStringXml,
18
- getStyleId = _ref.getStyleId,
19
- styles = _ref.styles,
20
- values = _ref.values,
21
- properties = _ref.properties,
22
- options = _ref.options;
23
-
13
+ getInlineStringXml = _ref.getInlineStringXml,
14
+ getStyleId = _ref.getStyleId,
15
+ styles = _ref.styles,
16
+ values = _ref.values,
17
+ properties = _ref.properties,
18
+ options = _ref.options;
24
19
  if (!type) {
25
20
  // Default cell type is "n" (numeric).
26
21
  // http://www.datypic.com/sc/ooxml/t-ssml_CT_Cell.html
27
22
  type = 'n';
28
- } // Available Excel cell types:
23
+ }
24
+
25
+ // Available Excel cell types:
29
26
  // https://github.com/SheetJS/sheetjs/blob/19620da30be2a7d7b9801938a0b9b1fd3c4c4b00/docbits/52_datatype.md
30
27
  //
31
28
  // Some other document (seems to be old):
32
29
  // http://webapp.docx4java.org/OnlineDemo/ecma376/SpreadsheetML/ST_CellType.html
33
30
  //
34
-
35
-
36
31
  switch (type) {
37
32
  // XLSX tends to store all strings as "shared" (indexed) ones
38
33
  // using "s" cell type (for saving on strage space).
@@ -41,46 +36,41 @@ function parseCellValue(value, type, _ref) {
41
36
  case 'str':
42
37
  value = parseString(value, options);
43
38
  break;
39
+
44
40
  // Sometimes, XLSX stores strings as "inline" strings rather than "shared" (indexed) ones.
45
41
  // Perhaps the specification doesn't force it to use one or another.
46
42
  // Example: `<sheetData><row r="1"><c r="A1" s="1" t="inlineStr"><is><t>Test 123</t></is></c></row></sheetData>`.
47
-
48
43
  case 'inlineStr':
49
44
  value = getInlineStringValue();
50
-
51
45
  if (value === undefined) {
52
46
  throw new Error("Unsupported \"inline string\" cell value structure: ".concat(getInlineStringXml()));
53
47
  }
54
-
55
48
  value = parseString(value, options);
56
49
  break;
50
+
57
51
  // XLSX tends to store string values as "shared" (indexed) ones.
58
52
  // "Shared" strings is a way for an Excel editor to reduce
59
53
  // the file size by storing "commonly used" strings in a dictionary
60
54
  // and then referring to such strings by their index in that dictionary.
61
55
  // Example: `<sheetData><row r="1"><c r="A1" s="1" t="s"><v>0</v></c></row></sheetData>`.
62
-
63
56
  case 's':
64
57
  // If a cell has no value then there's no `<c/>` element for it.
65
58
  // If a `<c/>` element exists then it's not empty.
66
59
  // The `<v/>`alue is a key in the "shared strings" dictionary of the
67
60
  // XLSX file, so look it up in the `values` dictionary by the numeric key.
68
61
  var sharedStringIndex = Number(value);
69
-
70
62
  if (isNaN(sharedStringIndex)) {
71
63
  throw new Error("Invalid \"shared\" string index: ".concat(value));
72
64
  }
73
-
74
65
  if (sharedStringIndex >= values.length) {
75
66
  throw new Error("An out-of-bounds \"shared\" string index: ".concat(value));
76
67
  }
77
-
78
68
  value = values[sharedStringIndex];
79
69
  value = parseString(value, options);
80
70
  break;
71
+
81
72
  // Boolean (TRUE/FALSE) values are stored as either "1" or "0"
82
73
  // in cells of type "b".
83
-
84
74
  case 'b':
85
75
  if (value === '1') {
86
76
  value = true;
@@ -89,55 +79,50 @@ function parseCellValue(value, type, _ref) {
89
79
  } else {
90
80
  throw new Error("Unsupported \"boolean\" cell value: ".concat(value));
91
81
  }
92
-
93
82
  break;
83
+
94
84
  // XLSX specification seems to support cells of type "z":
95
85
  // blank "stub" cells that should be ignored by data processing utilities.
96
-
97
86
  case 'z':
98
87
  value = undefined;
99
88
  break;
89
+
100
90
  // XLSX specification also defines cells of type "e" containing a numeric "error" code.
101
91
  // It's not clear what that means though.
102
92
  // They also wrote: "and `w` property stores its common name".
103
93
  // It's unclear what they meant by that.
104
-
105
94
  case 'e':
106
95
  value = decodeError(value);
107
96
  break;
97
+
108
98
  // XLSX supports date cells of type "d", though seems like it (almost?) never
109
99
  // uses it for storing dates, preferring "n" numeric timestamp cells instead.
110
100
  // The value of a "d" cell is supposedly a string in "ISO 8601" format.
111
101
  // I haven't seen an XLSX file having such cells.
112
102
  // Example: `<sheetData><row r="1"><c r="A1" s="1" t="d"><v>2021-06-10T00:47:45.700Z</v></c></row></sheetData>`.
113
-
114
103
  case 'd':
115
104
  if (value === undefined) {
116
105
  break;
117
106
  }
118
-
119
107
  var parsedDate = new Date(value);
120
-
121
108
  if (isNaN(parsedDate.valueOf())) {
122
109
  throw new Error("Unsupported \"date\" cell value: ".concat(value));
123
110
  }
124
-
125
111
  value = parsedDate;
126
112
  break;
127
- // Numeric cells have type "n".
128
113
 
114
+ // Numeric cells have type "n".
129
115
  case 'n':
130
116
  if (value === undefined) {
131
117
  break;
132
118
  }
133
-
134
- var isDateTimestampNumber = (0, _isDateTimestamp["default"])(getStyleId(), styles, options); // XLSX does have "d" type for dates, but it's not commonly used.
119
+ var isDateTimestampNumber = (0, _isDateTimestamp["default"])(getStyleId(), styles, options);
120
+ // XLSX does have "d" type for dates, but it's not commonly used.
135
121
  // Instead, it prefers using "n" type for storing dates as timestamps.
136
-
137
122
  if (isDateTimestampNumber) {
138
123
  // Parse the number from string.
139
- value = parseNumberDefault(value); // Parse the number as a date timestamp.
140
-
124
+ value = parseNumberDefault(value);
125
+ // Parse the number as a date timestamp.
141
126
  value = (0, _parseDate["default"])(value, properties);
142
127
  } else {
143
128
  // Parse the number from string.
@@ -145,57 +130,45 @@ function parseCellValue(value, type, _ref) {
145
130
  // https://gitlab.com/catamphetamine/read-excel-file/-/issues/85
146
131
  value = (options.parseNumber || parseNumberDefault)(value);
147
132
  }
148
-
149
133
  break;
150
-
151
134
  default:
152
135
  throw new TypeError("Cell type not supported: ".concat(type));
153
- } // Convert empty values to `null`.
154
-
136
+ }
155
137
 
138
+ // Convert empty values to `null`.
156
139
  if (value === undefined) {
157
140
  value = null;
158
141
  }
159
-
160
142
  return value;
161
- } // Decodes numeric error code to a string code.
162
- // https://github.com/SheetJS/sheetjs/blob/19620da30be2a7d7b9801938a0b9b1fd3c4c4b00/docbits/52_datatype.md
163
-
143
+ }
164
144
 
145
+ // Decodes numeric error code to a string code.
146
+ // https://github.com/SheetJS/sheetjs/blob/19620da30be2a7d7b9801938a0b9b1fd3c4c4b00/docbits/52_datatype.md
165
147
  function decodeError(errorCode) {
166
148
  // While the error values are determined by the application,
167
149
  // the following are some example error values that could be used:
168
150
  switch (errorCode) {
169
151
  case 0x00:
170
152
  return '#NULL!';
171
-
172
153
  case 0x07:
173
154
  return '#DIV/0!';
174
-
175
155
  case 0x0F:
176
156
  return '#VALUE!';
177
-
178
157
  case 0x17:
179
158
  return '#REF!';
180
-
181
159
  case 0x1D:
182
160
  return '#NAME?';
183
-
184
161
  case 0x24:
185
162
  return '#NUM!';
186
-
187
163
  case 0x2A:
188
164
  return '#N/A';
189
-
190
165
  case 0x2B:
191
166
  return '#GETTING_DATA';
192
-
193
167
  default:
194
168
  // Such error code doesn't exist. I made it up.
195
169
  return "#ERROR_".concat(errorCode);
196
170
  }
197
171
  }
198
-
199
172
  function parseString(value, options) {
200
173
  // In some weird cases, a developer might want to disable
201
174
  // the automatic trimming of all strings.
@@ -204,27 +177,23 @@ function parseString(value, options) {
204
177
  if (options.trim !== false) {
205
178
  value = value.trim();
206
179
  }
207
-
208
180
  if (value === '') {
209
181
  value = undefined;
210
182
  }
211
-
212
183
  return value;
213
- } // Parses a number from string.
184
+ }
185
+
186
+ // Parses a number from string.
214
187
  // Throws an error if the number couldn't be parsed.
215
188
  // When parsing floating-point number, is affected by
216
189
  // the javascript number encoding precision issues:
217
190
  // https://www.youtube.com/watch?v=2gIxbTn7GSc
218
191
  // https://www.avioconsulting.com/blog/overcoming-javascript-numeric-precision-issues
219
-
220
-
221
192
  function parseNumberDefault(stringifiedNumber) {
222
193
  var parsedNumber = Number(stringifiedNumber);
223
-
224
194
  if (isNaN(parsedNumber)) {
225
195
  throw new Error("Invalid \"numeric\" cell value: ".concat(stringifiedNumber));
226
196
  }
227
-
228
197
  return parsedNumber;
229
198
  }
230
199
  //# sourceMappingURL=parseCellValue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseCellValue.js","names":["parseCellValue","value","type","getInlineStringValue","getInlineStringXml","getStyleId","styles","values","properties","options","parseString","undefined","Error","sharedStringIndex","Number","isNaN","length","decodeError","parsedDate","Date","valueOf","isDateTimestampNumber","isDateTimestamp","parseNumberDefault","parseDate","parseNumber","TypeError","errorCode","trim","stringifiedNumber","parsedNumber"],"sources":["../../source/read/parseCellValue.js"],"sourcesContent":["import parseDate from './parseDate.js'\r\nimport isDateTimestamp from './isDateTimestamp.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 values,\r\n properties,\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 `values` 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 >= values.length) {\r\n throw new Error(`An out-of-bounds \"shared\" string index: ${value}`)\r\n }\r\n value = values[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 const isDateTimestampNumber = isDateTimestamp(getStyleId(), styles, options)\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 (isDateTimestampNumber) {\r\n // Parse the number from string.\r\n value = parseNumberDefault(value)\r\n // Parse the number as a date timestamp.\r\n value = parseDate(value, properties)\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 || parseNumberDefault)(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;;AACA;;;;AAEA;AACe,SAASA,cAAT,CAAwBC,KAAxB,EAA+BC,IAA/B,QAQZ;EAAA,IAPDC,oBAOC,QAPDA,oBAOC;EAAA,IANDC,kBAMC,QANDA,kBAMC;EAAA,IALDC,UAKC,QALDA,UAKC;EAAA,IAJDC,MAIC,QAJDA,MAIC;EAAA,IAHDC,MAGC,QAHDA,MAGC;EAAA,IAFDC,UAEC,QAFDA,UAEC;EAAA,IADDC,OACC,QADDA,OACC;;EACD,IAAI,CAACP,IAAL,EAAW;IACT;IACA;IACAA,IAAI,GAAG,GAAP;EACD,CALA,CAOD;EACA;EACA;EACA;EACA;EACA;;;EACA,QAAQA,IAAR;IACE;IACA;IACA;IACA;IACA,KAAK,KAAL;MACED,KAAK,GAAGS,WAAW,CAACT,KAAD,EAAQQ,OAAR,CAAnB;MACA;IAEF;IACA;IACA;;IACA,KAAK,WAAL;MACER,KAAK,GAAGE,oBAAoB,EAA5B;;MACA,IAAIF,KAAK,KAAKU,SAAd,EAAyB;QACvB,MAAM,IAAIC,KAAJ,+DAA+DR,kBAAkB,EAAjF,EAAN;MACD;;MACDH,KAAK,GAAGS,WAAW,CAACT,KAAD,EAAQQ,OAAR,CAAnB;MACA;IAEF;IACA;IACA;IACA;IACA;;IACA,KAAK,GAAL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A;AACA;;;AACA,SAASsB,kBAAT,CAA4BM,iBAA5B,EAA+C;EAC7C,IAAMC,YAAY,GAAGhB,MAAM,CAACe,iBAAD,CAA3B;;EACA,IAAId,KAAK,CAACe,YAAD,CAAT,EAAyB;IACvB,MAAM,IAAIlB,KAAJ,2CAA2CiB,iBAA3C,EAAN;EACD;;EACD,OAAOC,YAAP;AACD"}
1
+ {"version":3,"file":"parseCellValue.js","names":["_parseDate","_interopRequireDefault","require","_isDateTimestamp","obj","__esModule","parseCellValue","value","type","_ref","getInlineStringValue","getInlineStringXml","getStyleId","styles","values","properties","options","parseString","undefined","Error","concat","sharedStringIndex","Number","isNaN","length","decodeError","parsedDate","Date","valueOf","isDateTimestampNumber","isDateTimestamp","parseNumberDefault","parseDate","parseNumber","TypeError","errorCode","trim","stringifiedNumber","parsedNumber"],"sources":["../../source/read/parseCellValue.js"],"sourcesContent":["import parseDate from './parseDate.js'\r\nimport isDateTimestamp from './isDateTimestamp.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 values,\r\n properties,\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 `values` 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 >= values.length) {\r\n throw new Error(`An out-of-bounds \"shared\" string index: ${value}`)\r\n }\r\n value = values[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 const isDateTimestampNumber = isDateTimestamp(getStyleId(), styles, options)\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 (isDateTimestampNumber) {\r\n // Parse the number from string.\r\n value = parseNumberDefault(value)\r\n // Parse the number as a date timestamp.\r\n value = parseDate(value, properties)\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 || parseNumberDefault)(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,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAkD,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAElD;AACe,SAASE,cAAcA,CAACC,KAAK,EAAEC,IAAI,EAAAC,IAAA,EAQ/C;EAAA,IAPDC,oBAAoB,GAAAD,IAAA,CAApBC,oBAAoB;IACpBC,kBAAkB,GAAAF,IAAA,CAAlBE,kBAAkB;IAClBC,UAAU,GAAAH,IAAA,CAAVG,UAAU;IACVC,MAAM,GAAAJ,IAAA,CAANI,MAAM;I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A,CAACU,SAAS,EAAE;EAC9B;EACA;EACA,QAAQA,SAAS;IACf,KAAK,IAAI;MACP,OAAO,QAAQ;IACjB,KAAK,IAAI;MACP,OAAO,SAAS;IAClB,KAAK,IAAI;MACP,OAAO,SAAS;IAClB,KAAK,IAAI;MACP,OAAO,OAAO;IAChB,KAAK,IAAI;MACP,OAAO,QAAQ;IACjB,KAAK,IAAI;MACP,OAAO,OAAO;IAChB,KAAK,IAAI;MACP,OAAO,MAAM;IACf,KAAK,IAAI;MACP,OAAO,eAAe;IACxB;MACE;MACA,iBAAAf,MAAA,CAAiBe,SAAS;EAC9B;AACF;AAEA,SAASlB,WAAWA,CAACV,KAAK,EAAES,OAAO,EAAE;EACnC;EACA;EACA;EACA;EACA,IAAIA,OAAO,CAACoB,IAAI,KAAK,KAAK,EAAE;IAC1B7B,KAAK,GAAGA,KAAK,CAAC6B,IAAI,CAAC,CAAC;EACtB;EACA,IAAI7B,KAAK,KAAK,EAAE,EAAE;IAChBA,KAAK,GAAGW,SAAS;EACnB;EACA,OAAOX,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASwB,kBAAkBA,CAACM,iBAAiB,EAAE;EAC7C,IAAMC,YAAY,GAAGhB,MAAM,CAACe,iBAAiB,CAAC;EAC9C,IAAId,KAAK,CAACe,YAAY,CAAC,EAAE;IACvB,MAAM,IAAInB,KAAK,oCAAAC,MAAA,CAAkCiB,iBAAiB,CAAE,CAAC;EACvE;EACA,OAAOC,YAAY;AACrB"}
@@ -4,25 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = parseCells;
7
-
8
7
  var _parseCell = _interopRequireDefault(require("./parseCell.js"));
9
-
10
8
  var _xlsx = require("../xml/xlsx.js");
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
-
14
10
  function parseCells(sheet, xml, values, styles, properties, options) {
15
11
  var cells = (0, _xlsx.getCells)(sheet);
16
-
17
12
  if (cells.length === 0) {
18
13
  return [];
19
- } // const mergedCells = getMergedCells(sheet)
14
+ }
15
+
16
+ // const mergedCells = getMergedCells(sheet)
20
17
  // for (const mergedCell of mergedCells) {
21
18
  // const [from, to] = mergedCell.split(':').map(parseCellCoordinates)
22
19
  // console.log('Merged Cell.', 'From:', from, 'To:', to)
23
20
  // }
24
21
 
25
-
26
22
  return cells.map(function (node) {
27
23
  return (0, _parseCell["default"])(node, sheet, xml, values, styles, properties, options);
28
24
  });
@@ -1 +1 @@
1
- {"version":3,"file":"parseCells.js","names":["parseCells","sheet","xml","values","styles","properties","options","cells","getCells","length","map","node","parseCell"],"sources":["../../source/read/parseCells.js"],"sourcesContent":["import parseCell from './parseCell.js'\r\n\r\nimport {\r\n getCells,\r\n getMergedCells\r\n} from '../xml/xlsx.js'\r\n\r\nexport default function parseCells(sheet, xml, values, styles, properties, options) {\r\n const cells = getCells(sheet)\r\n\r\n if (cells.length === 0) {\r\n return []\r\n }\r\n\r\n // const mergedCells = getMergedCells(sheet)\r\n // for (const mergedCell of mergedCells) {\r\n // const [from, to] = mergedCell.split(':').map(parseCellCoordinates)\r\n // console.log('Merged Cell.', 'From:', from, 'To:', to)\r\n // }\r\n\r\n return cells.map((node) => {\r\n return parseCell(node, sheet, xml, values, styles, properties, options)\r\n })\r\n}"],"mappings":";;;;;;;AAAA;;AAEA;;;;AAKe,SAASA,UAAT,CAAoBC,KAApB,EAA2BC,GAA3B,EAAgCC,MAAhC,EAAwCC,MAAxC,EAAgDC,UAAhD,EAA4DC,OAA5D,EAAqE;EAClF,IAAMC,KAAK,GAAG,IAAAC,cAAA,EAASP,KAAT,CAAd;;EAEA,IAAIM,KAAK,CAACE,MAAN,KAAiB,CAArB,EAAwB;IACtB,OAAO,EAAP;EACD,CALiF,CAOlF;EACA;EACA;EACA;EACA;;;EAEA,OAAOF,KAAK,CAACG,GAAN,CAAU,UAACC,IAAD,EAAU;IACzB,OAAO,IAAAC,qBAAA,EAAUD,IAAV,EAAgBV,KAAhB,EAAuBC,GAAvB,EAA4BC,MAA5B,EAAoCC,MAApC,EAA4CC,UAA5C,EAAwDC,OAAxD,CAAP;EACD,CAFM,CAAP;AAGD"}
1
+ {"version":3,"file":"parseCells.js","names":["_parseCell","_interopRequireDefault","require","_xlsx","obj","__esModule","parseCells","sheet","xml","values","styles","properties","options","cells","getCells","length","map","node","parseCell"],"sources":["../../source/read/parseCells.js"],"sourcesContent":["import parseCell from './parseCell.js'\r\n\r\nimport {\r\n getCells,\r\n getMergedCells\r\n} from '../xml/xlsx.js'\r\n\r\nexport default function parseCells(sheet, xml, values, styles, properties, options) {\r\n const cells = getCells(sheet)\r\n\r\n if (cells.length === 0) {\r\n return []\r\n }\r\n\r\n // const mergedCells = getMergedCells(sheet)\r\n // for (const mergedCell of mergedCells) {\r\n // const [from, to] = mergedCell.split(':').map(parseCellCoordinates)\r\n // console.log('Merged Cell.', 'From:', from, 'To:', to)\r\n // }\r\n\r\n return cells.map((node) => {\r\n return parseCell(node, sheet, xml, values, styles, properties, options)\r\n })\r\n}"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAGuB,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAER,SAASE,UAAUA,CAACC,KAAK,EAAEC,GAAG,EAAEC,MAAM,EAAEC,MAAM,EAAEC,UAAU,EAAEC,OAAO,EAAE;EAClF,IAAMC,KAAK,GAAG,IAAAC,cAAQ,EAACP,KAAK,CAAC;EAE7B,IAAIM,KAAK,CAACE,MAAM,KAAK,CAAC,EAAE;IACtB,OAAO,EAAE;EACX;;EAEA;EACA;EACA;EACA;EACA;;EAEA,OAAOF,KAAK,CAACG,GAAG,CAAC,UAACC,IAAI,EAAK;IACzB,OAAO,IAAAC,qBAAS,EAACD,IAAI,EAAEV,KAAK,EAAEC,GAAG,EAAEC,MAAM,EAAEC,MAAM,EAAEC,UAAU,EAAEC,OAAO,CAAC;EACzE,CAAC,CAAC;AACJ"}