read-excel-file 7.0.2 → 8.0.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 (266) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +212 -205
  3. package/browser/index.cjs +8 -5
  4. package/browser/index.d.ts +58 -16
  5. package/browser/index.js +7 -5
  6. package/browser/input.d.ts +1 -0
  7. package/bundle/read-excel-file.min.js +1 -1
  8. package/bundle/read-excel-file.min.js.map +1 -1
  9. package/commonjs/export/parseSheet.js +20 -0
  10. package/commonjs/export/parseSheet.js.map +1 -0
  11. package/commonjs/export/readSheetBrowser.js +29 -0
  12. package/commonjs/export/readSheetBrowser.js.map +1 -0
  13. package/commonjs/export/readSheetNode.js +29 -0
  14. package/commonjs/export/readSheetNode.js.map +1 -0
  15. package/commonjs/export/readSheetUniversal.js +29 -0
  16. package/commonjs/export/readSheetUniversal.js.map +1 -0
  17. package/commonjs/export/readSheetWebWorker.js +29 -0
  18. package/commonjs/export/readSheetWebWorker.js.map +1 -0
  19. package/commonjs/export/readXlsxFileBrowser.js +6 -8
  20. package/commonjs/export/readXlsxFileBrowser.js.map +1 -1
  21. package/commonjs/export/readXlsxFileNode.js +7 -9
  22. package/commonjs/export/readXlsxFileNode.js.map +1 -1
  23. package/commonjs/export/readXlsxFileUniversal.js +7 -9
  24. package/commonjs/export/readXlsxFileUniversal.js.map +1 -1
  25. package/commonjs/export/readXlsxFileWebWorker.js +6 -8
  26. package/commonjs/export/readXlsxFileWebWorker.js.map +1 -1
  27. package/commonjs/export/unpackXlsxFileBrowser.js +2 -1
  28. package/commonjs/export/unpackXlsxFileBrowser.js.map +1 -1
  29. package/commonjs/export/unpackXlsxFileNode.js +4 -3
  30. package/commonjs/export/unpackXlsxFileNode.js.map +1 -1
  31. package/commonjs/export/unpackXlsxFileUniversal.js +13 -3
  32. package/commonjs/export/unpackXlsxFileUniversal.js.map +1 -1
  33. package/commonjs/parseData/InvalidError.js.map +1 -0
  34. package/commonjs/parseData/parseData.js +503 -0
  35. package/commonjs/parseData/parseData.js.map +1 -0
  36. package/commonjs/parseData/parseData.test.js.map +1 -0
  37. package/commonjs/{types → parseData/types}/Boolean.js +1 -1
  38. package/commonjs/parseData/types/Boolean.js.map +1 -0
  39. package/commonjs/parseData/types/Date.js +21 -0
  40. package/commonjs/parseData/types/Date.js.map +1 -0
  41. package/commonjs/{types → parseData/types}/Number.js +1 -1
  42. package/commonjs/parseData/types/Number.js.map +1 -0
  43. package/commonjs/{types → parseData/types}/String.js +1 -1
  44. package/commonjs/parseData/types/String.js.map +1 -0
  45. package/commonjs/{types → parseData/types/additional}/Email.js +3 -3
  46. package/commonjs/parseData/types/additional/Email.js.map +1 -0
  47. package/commonjs/parseData/types/additional/Email.test.js.map +1 -0
  48. package/commonjs/{types → parseData/types/additional}/Integer.js +2 -2
  49. package/commonjs/parseData/types/additional/Integer.js.map +1 -0
  50. package/commonjs/parseData/types/additional/Integer.test.js.map +1 -0
  51. package/commonjs/{types → parseData/types/additional}/URL.js +3 -3
  52. package/commonjs/parseData/types/additional/URL.js.map +1 -0
  53. package/commonjs/parseData/types/additional/URL.test.js.map +1 -0
  54. package/commonjs/xlsx/{getData.js → convertCellsToData2dArray.js} +16 -37
  55. package/commonjs/xlsx/convertCellsToData2dArray.js.map +1 -0
  56. package/commonjs/xlsx/{isDateTimestamp.js → isDateFormat.js} +58 -56
  57. package/commonjs/xlsx/isDateFormat.js.map +1 -0
  58. package/commonjs/xlsx/isDateFormat.test.js.map +1 -0
  59. package/commonjs/xlsx/isDateFormatStyle.js +193 -0
  60. package/commonjs/xlsx/isDateFormatStyle.js.map +1 -0
  61. package/commonjs/xlsx/parseCell.js +16 -18
  62. package/commonjs/xlsx/parseCell.js.map +1 -1
  63. package/commonjs/xlsx/parseCellCoordinates.js +44 -0
  64. package/commonjs/xlsx/parseCellCoordinates.js.map +1 -0
  65. package/commonjs/xlsx/parseCellValue.js +14 -11
  66. package/commonjs/xlsx/parseCellValue.js.map +1 -1
  67. package/commonjs/xlsx/parseCells.js +14 -6
  68. package/commonjs/xlsx/parseCells.js.map +1 -1
  69. package/commonjs/xlsx/parseExcelDate.js +139 -0
  70. package/commonjs/xlsx/parseExcelDate.js.map +1 -0
  71. package/commonjs/xlsx/parseExcelDate.test.js.map +1 -0
  72. package/commonjs/xlsx/parseSheet.js +9 -11
  73. package/commonjs/xlsx/parseSheet.js.map +1 -1
  74. package/commonjs/xlsx/{parseDimensions.js → parseSheetDimensions.js} +7 -6
  75. package/commonjs/xlsx/parseSheetDimensions.js.map +1 -0
  76. package/commonjs/xlsx/parseSpreadsheetContents.js +96 -0
  77. package/commonjs/xlsx/parseSpreadsheetContents.js.map +1 -0
  78. package/commonjs/xlsx/parseSpreadsheetInfo.js +47 -0
  79. package/commonjs/xlsx/parseSpreadsheetInfo.js.map +1 -0
  80. package/commonjs/xlsx/reconstructSheetDimensionsFromSheetCells.js +29 -0
  81. package/commonjs/xlsx/reconstructSheetDimensionsFromSheetCells.js.map +1 -0
  82. package/commonjs/xml/xlsx.js +9 -9
  83. package/commonjs/xml/xlsx.js.map +1 -1
  84. package/commonjs/xml/xpath/xlsx-xpath.js +8 -8
  85. package/commonjs/xml/xpath/xlsx-xpath.js.map +1 -1
  86. package/commonjs/xml/xpath/xpathBrowser.js +4 -4
  87. package/commonjs/xml/xpath/xpathBrowser.js.map +1 -1
  88. package/commonjs/xml/xpath/xpathNode.js +2 -2
  89. package/commonjs/xml/xpath/xpathNode.js.map +1 -1
  90. package/modules/export/parseSheet.js +13 -0
  91. package/modules/export/parseSheet.js.map +1 -0
  92. package/modules/export/readSheetBrowser.js +23 -0
  93. package/modules/export/readSheetBrowser.js.map +1 -0
  94. package/modules/export/readSheetNode.js +23 -0
  95. package/modules/export/readSheetNode.js.map +1 -0
  96. package/modules/export/readSheetUniversal.js +23 -0
  97. package/modules/export/readSheetUniversal.js.map +1 -0
  98. package/modules/export/readSheetWebWorker.js +23 -0
  99. package/modules/export/readSheetWebWorker.js.map +1 -0
  100. package/modules/export/readXlsxFileBrowser.js +6 -8
  101. package/modules/export/readXlsxFileBrowser.js.map +1 -1
  102. package/modules/export/readXlsxFileNode.js +7 -9
  103. package/modules/export/readXlsxFileNode.js.map +1 -1
  104. package/modules/export/readXlsxFileUniversal.js +7 -9
  105. package/modules/export/readXlsxFileUniversal.js.map +1 -1
  106. package/modules/export/readXlsxFileWebWorker.js +6 -8
  107. package/modules/export/readXlsxFileWebWorker.js.map +1 -1
  108. package/modules/export/unpackXlsxFileBrowser.js +3 -1
  109. package/modules/export/unpackXlsxFileBrowser.js.map +1 -1
  110. package/modules/export/unpackXlsxFileNode.js +4 -3
  111. package/modules/export/unpackXlsxFileNode.js.map +1 -1
  112. package/modules/export/unpackXlsxFileUniversal.js +13 -3
  113. package/modules/export/unpackXlsxFileUniversal.js.map +1 -1
  114. package/modules/parseData/InvalidError.js.map +1 -0
  115. package/modules/parseData/parseData.js +494 -0
  116. package/modules/parseData/parseData.js.map +1 -0
  117. package/modules/parseData/parseData.test.js.map +1 -0
  118. package/modules/{types → parseData/types}/Boolean.js +1 -1
  119. package/modules/parseData/types/Boolean.js.map +1 -0
  120. package/modules/parseData/types/Date.js +14 -0
  121. package/modules/parseData/types/Date.js.map +1 -0
  122. package/modules/{types → parseData/types}/Number.js +1 -1
  123. package/modules/parseData/types/Number.js.map +1 -0
  124. package/modules/{types → parseData/types}/String.js +1 -1
  125. package/modules/parseData/types/String.js.map +1 -0
  126. package/modules/{types → parseData/types/additional}/Email.js +3 -3
  127. package/modules/parseData/types/additional/Email.js.map +1 -0
  128. package/modules/parseData/types/additional/Email.test.js.map +1 -0
  129. package/modules/{types → parseData/types/additional}/Integer.js +2 -2
  130. package/modules/parseData/types/additional/Integer.js.map +1 -0
  131. package/modules/parseData/types/additional/Integer.test.js.map +1 -0
  132. package/modules/{types → parseData/types/additional}/URL.js +3 -3
  133. package/modules/parseData/types/additional/URL.js.map +1 -0
  134. package/modules/parseData/types/additional/URL.test.js.map +1 -0
  135. package/modules/xlsx/{getData.js → convertCellsToData2dArray.js} +15 -36
  136. package/modules/xlsx/convertCellsToData2dArray.js.map +1 -0
  137. package/modules/xlsx/{isDateTimestamp.js → isDateFormat.js} +57 -55
  138. package/modules/xlsx/isDateFormat.js.map +1 -0
  139. package/modules/xlsx/isDateFormat.test.js.map +1 -0
  140. package/modules/xlsx/isDateFormatStyle.js +186 -0
  141. package/modules/xlsx/isDateFormatStyle.js.map +1 -0
  142. package/modules/xlsx/parseCell.js +17 -19
  143. package/modules/xlsx/parseCell.js.map +1 -1
  144. package/modules/xlsx/parseCellCoordinates.js +38 -0
  145. package/modules/xlsx/parseCellCoordinates.js.map +1 -0
  146. package/modules/xlsx/parseCellValue.js +14 -11
  147. package/modules/xlsx/parseCellValue.js.map +1 -1
  148. package/modules/xlsx/parseCells.js +14 -6
  149. package/modules/xlsx/parseCells.js.map +1 -1
  150. package/modules/xlsx/parseExcelDate.js +133 -0
  151. package/modules/xlsx/parseExcelDate.js.map +1 -0
  152. package/modules/xlsx/parseExcelDate.test.js.map +1 -0
  153. package/modules/xlsx/parseSheet.js +9 -11
  154. package/modules/xlsx/parseSheet.js.map +1 -1
  155. package/modules/xlsx/{parseDimensions.js → parseSheetDimensions.js} +4 -4
  156. package/modules/xlsx/parseSheetDimensions.js.map +1 -0
  157. package/modules/xlsx/parseSpreadsheetContents.js +91 -0
  158. package/modules/xlsx/parseSpreadsheetContents.js.map +1 -0
  159. package/modules/xlsx/parseSpreadsheetInfo.js +42 -0
  160. package/modules/xlsx/parseSpreadsheetInfo.js.map +1 -0
  161. package/modules/xlsx/reconstructSheetDimensionsFromSheetCells.js +23 -0
  162. package/modules/xlsx/reconstructSheetDimensionsFromSheetCells.js.map +1 -0
  163. package/modules/xml/xlsx.js +6 -6
  164. package/modules/xml/xlsx.js.map +1 -1
  165. package/modules/xml/xpath/xlsx-xpath.js +6 -6
  166. package/modules/xml/xpath/xlsx-xpath.js.map +1 -1
  167. package/modules/xml/xpath/xpathBrowser.js +4 -4
  168. package/modules/xml/xpath/xpathBrowser.js.map +1 -1
  169. package/modules/xml/xpath/xpathNode.js +2 -2
  170. package/modules/xml/xpath/xpathNode.js.map +1 -1
  171. package/node/index.cjs +8 -5
  172. package/node/index.d.ts +56 -21
  173. package/node/index.js +7 -5
  174. package/node/input.d.ts +5 -0
  175. package/package.json +1 -1
  176. package/rollup.config.mjs +1 -1
  177. package/types/parseData/parseData.d.ts +38 -0
  178. package/types/parseData/parseDataError.d.ts +239 -0
  179. package/types/parseData/parseDataSchema.d.ts +48 -0
  180. package/types/parseData/parseDataValueType.d.ts +45 -0
  181. package/types/types.d.ts +20 -0
  182. package/universal/index.cjs +8 -5
  183. package/universal/index.d.ts +58 -16
  184. package/universal/index.js +7 -5
  185. package/universal/input.d.ts +1 -0
  186. package/web-worker/index.cjs +8 -5
  187. package/web-worker/index.d.ts +58 -16
  188. package/web-worker/index.js +7 -5
  189. package/web-worker/input.d.ts +1 -0
  190. package/commonjs/export/readSheetNamesBrowser.js +0 -23
  191. package/commonjs/export/readSheetNamesBrowser.js.map +0 -1
  192. package/commonjs/export/readSheetNamesNode.js +0 -23
  193. package/commonjs/export/readSheetNamesNode.js.map +0 -1
  194. package/commonjs/export/readSheetNamesUniversal.js +0 -23
  195. package/commonjs/export/readSheetNamesUniversal.js.map +0 -1
  196. package/commonjs/export/readSheetNamesWebWorker.js +0 -23
  197. package/commonjs/export/readSheetNamesWebWorker.js.map +0 -1
  198. package/commonjs/types/Boolean.js.map +0 -1
  199. package/commonjs/types/Date.js +0 -36
  200. package/commonjs/types/Date.js.map +0 -1
  201. package/commonjs/types/Email.js.map +0 -1
  202. package/commonjs/types/Email.test.js.map +0 -1
  203. package/commonjs/types/Integer.js.map +0 -1
  204. package/commonjs/types/Integer.test.js.map +0 -1
  205. package/commonjs/types/InvalidError.js.map +0 -1
  206. package/commonjs/types/Number.js.map +0 -1
  207. package/commonjs/types/String.js.map +0 -1
  208. package/commonjs/types/URL.js.map +0 -1
  209. package/commonjs/types/URL.test.js.map +0 -1
  210. package/commonjs/xlsx/coordinates.js +0 -55
  211. package/commonjs/xlsx/coordinates.js.map +0 -1
  212. package/commonjs/xlsx/getData.js.map +0 -1
  213. package/commonjs/xlsx/isDateTimestamp.js.map +0 -1
  214. package/commonjs/xlsx/parseDate.js +0 -73
  215. package/commonjs/xlsx/parseDate.js.map +0 -1
  216. package/commonjs/xlsx/parseDate.test.js.map +0 -1
  217. package/commonjs/xlsx/parseDimensions.js.map +0 -1
  218. package/commonjs/xlsx/parseProperties.js +0 -46
  219. package/commonjs/xlsx/parseProperties.js.map +0 -1
  220. package/commonjs/xlsx/parseXlsxFileContents.js +0 -119
  221. package/commonjs/xlsx/parseXlsxFileContents.js.map +0 -1
  222. package/commonjs/xlsx/parseXlsxFileContentsWithOptionalSchema.js +0 -45
  223. package/commonjs/xlsx/parseXlsxFileContentsWithOptionalSchema.js.map +0 -1
  224. package/commonjs/xlsx/schema/mapToObjects.js +0 -482
  225. package/commonjs/xlsx/schema/mapToObjects.js.map +0 -1
  226. package/commonjs/xlsx/schema/mapToObjects.test.js.map +0 -1
  227. package/modules/export/readSheetNamesBrowser.js +0 -17
  228. package/modules/export/readSheetNamesBrowser.js.map +0 -1
  229. package/modules/export/readSheetNamesNode.js +0 -17
  230. package/modules/export/readSheetNamesNode.js.map +0 -1
  231. package/modules/export/readSheetNamesUniversal.js +0 -17
  232. package/modules/export/readSheetNamesUniversal.js.map +0 -1
  233. package/modules/export/readSheetNamesWebWorker.js +0 -17
  234. package/modules/export/readSheetNamesWebWorker.js.map +0 -1
  235. package/modules/types/Boolean.js.map +0 -1
  236. package/modules/types/Date.js +0 -29
  237. package/modules/types/Date.js.map +0 -1
  238. package/modules/types/Email.js.map +0 -1
  239. package/modules/types/Email.test.js.map +0 -1
  240. package/modules/types/Integer.js.map +0 -1
  241. package/modules/types/Integer.test.js.map +0 -1
  242. package/modules/types/InvalidError.js.map +0 -1
  243. package/modules/types/Number.js.map +0 -1
  244. package/modules/types/String.js.map +0 -1
  245. package/modules/types/URL.js.map +0 -1
  246. package/modules/types/URL.test.js.map +0 -1
  247. package/modules/xlsx/coordinates.js +0 -48
  248. package/modules/xlsx/coordinates.js.map +0 -1
  249. package/modules/xlsx/getData.js.map +0 -1
  250. package/modules/xlsx/isDateTimestamp.js.map +0 -1
  251. package/modules/xlsx/parseDate.js +0 -67
  252. package/modules/xlsx/parseDate.js.map +0 -1
  253. package/modules/xlsx/parseDate.test.js.map +0 -1
  254. package/modules/xlsx/parseDimensions.js.map +0 -1
  255. package/modules/xlsx/parseProperties.js +0 -41
  256. package/modules/xlsx/parseProperties.js.map +0 -1
  257. package/modules/xlsx/parseXlsxFileContents.js +0 -114
  258. package/modules/xlsx/parseXlsxFileContents.js.map +0 -1
  259. package/modules/xlsx/parseXlsxFileContentsWithOptionalSchema.js +0 -39
  260. package/modules/xlsx/parseXlsxFileContentsWithOptionalSchema.js.map +0 -1
  261. package/modules/xlsx/schema/mapToObjects.js +0 -472
  262. package/modules/xlsx/schema/mapToObjects.js.map +0 -1
  263. package/modules/xlsx/schema/mapToObjects.test.js.map +0 -1
  264. package/types.d.ts +0 -121
  265. /package/commonjs/{types → parseData}/InvalidError.js +0 -0
  266. /package/modules/{types → parseData}/InvalidError.js +0 -0
@@ -0,0 +1,186 @@
1
+ // XLSX does have "d" type for dates, but it's not commonly used.
2
+ // Instead, it prefers using "n" type for storing dates as timestamps.
3
+ //
4
+ // Whether a numeric value is a number or a date timestamp, it sometimes could be
5
+ // detected by looking at the value "format" and seeing if it's a date-specific one.
6
+
7
+ import isDateFormat from './isDateFormat.js';
8
+ export default function isDateFormatStyle(styleId, styles, options) {
9
+ if (styleId) {
10
+ var style = styles[styleId];
11
+ if (!style) {
12
+ throw new Error("Cell style not found: ".concat(styleId));
13
+ }
14
+ if (!style.numberFormat) {
15
+ return false;
16
+ }
17
+ if (
18
+ // Whether it's a "number format" that's conventionally used for storing date timestamps.
19
+ BUILT_IN_DATE_FORMAT_IDS.indexOf(Number(style.numberFormat.id)) >= 0 ||
20
+ // Whether it's a "number format" that uses a "formatting template"
21
+ // that the developer is certain is a date formatting template.
22
+ options.dateFormat && style.numberFormat.template === options.dateFormat ||
23
+ // Whether the "smart formatting template" feature is not disabled
24
+ // and it has detected that it's a date formatting template by looking at it.
25
+ options.smartDateParser !== false && style.numberFormat.template && isDateFormat(style.numberFormat.template)) {
26
+ return true;
27
+ }
28
+ }
29
+ }
30
+
31
+ // Built-in formats have ID < 164.
32
+ // Some of those formats are intended to use when displaying dates.
33
+ //
34
+ // Depending on the "locale" used by the spreadsheet viewing application,
35
+ // different built-in format IDs might correspond to different templates.
36
+ // https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.numberingformat?view=openxml-2.8.1
37
+ //
38
+ // Here's a list of "locale"-independent built-in format IDs that're known to represent dates.
39
+ //
40
+ var LOCALE_INDEPENDENT_BUILT_IN_DATE_FORMAT_IDS = [14,
41
+ // mm-dd-yy
42
+ 15,
43
+ // d-mmm-yy
44
+ 16,
45
+ // d-mmm
46
+ 17,
47
+ // mmm-yy
48
+ 18,
49
+ // h:mm AM/PM
50
+ 19,
51
+ // h:mm:ss AM/PM
52
+ 20,
53
+ // h:mm
54
+ 21,
55
+ // h:mm:ss
56
+ 22,
57
+ // m/d/yy h:mm
58
+ 45,
59
+ // mm:ss
60
+ 46,
61
+ // [h]:mm:ss
62
+ 47 // mmss.0
63
+ ];
64
+
65
+ // "zh-tw" OR "zh-cn" locales.
66
+ // Language glyphs (aka "hieroglyphs") are not replaced with their respective unicode values here.
67
+ var MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS = [27,
68
+ // [$-404]e/m/d OR yyyy"年"m"月"
69
+ 28,
70
+ // [$-404]e"年"m"月"d"日" OR m"月"d"日"
71
+ 29,
72
+ // [$-404]e"年"m"月"d"日" OR m"月"d"日"
73
+ 30,
74
+ // m/d/yy OR m-d-yy
75
+ 31,
76
+ // yyyy"年"m"月"d"日" OR yyyy"年"m"月"d"日"
77
+ 32,
78
+ // hh"時"mm"分" OR h"时"mm"分"
79
+ 33,
80
+ // hh"時"mm"分"ss"秒" OR h"时"mm"分"ss"秒"
81
+ 34,
82
+ // 上午/下午hh"時"mm"分" OR 上午/下午h"时"mm"分"
83
+ 35,
84
+ // 上午/下午hh"時"mm"分"ss"秒" OR 上午/下午h"时"mm"分"ss"秒"
85
+ 36,
86
+ // [$-404]e/m/d OR yyyy"年"m"月"
87
+ 50,
88
+ // [$-404]e/m/d OR yyyy"年"m"月"
89
+ 51,
90
+ // [$-404]e"年"m"月"d"日" OR m"月"d"日"
91
+ 52,
92
+ // 上午/下午hh"時"mm"分" OR yyyy"年"m"月"
93
+ 53,
94
+ // 上午/下午hh"時"mm"分"ss"秒" OR m"月"d"日"
95
+ 54,
96
+ // [$-404]e"年"m"月"d"日" OR m"月"d"日"
97
+ 55,
98
+ // 上午/下午hh"時"mm"分" OR 上午/下午h"时"mm"分"
99
+ 56,
100
+ // 上午/下午hh"時"mm"分"ss"秒" OR 上午/下午h"时"mm"分"ss"秒"
101
+ 57,
102
+ // [$-404]e/m/d OR yyyy"年"m"月"
103
+ 58 // [$-404]e"年"m"月"d"日" OR m"月"d"日"
104
+ ];
105
+
106
+ // "ja-jp" OR "ko-kr" locales.
107
+ // Language glyphs (aka "hieroglyphs") are not replaced with their respective unicode values here.
108
+ var JAPANESE_OR_KOREAN_LOCALE_BUILT_IN_DATE_FORMAT_IDS = [27,
109
+ // [$-411]ge.m.d OR yyyy"年" mm"月" dd"日"
110
+ 28,
111
+ // [$-411]ggge"年"m"月"d"日" OR mm-dd
112
+ 29,
113
+ // [$-411]ggge"年"m"月"d"日" OR mm-dd
114
+ 30,
115
+ // m/d/yy OR mm-dd-yy
116
+ 31,
117
+ // yyyy"年"m"月"d"日" OR yyyy"년" mm"월" dd"일"
118
+ 32,
119
+ // h"時"mm"分" OR h"시" mm"분"
120
+ 33,
121
+ // h"時"mm"分"ss"秒" OR h"시" mm"분" ss"초"
122
+ 34,
123
+ // yyyy"年"m"月" OR yyyy-mm-dd
124
+ 35,
125
+ // m"月"d"日" OR yyyy-mm-dd
126
+ 36,
127
+ // [$-411]ge.m.d OR yyyy"年" mm"月" dd"日"
128
+ 50,
129
+ // [$-411]ge.m.d OR yyyy"年" mm"月" dd"日"
130
+ 51,
131
+ // [$-411]ggge"年"m"月"d"日" OR mm-dd
132
+ 52,
133
+ // yyyy"年"m"月" OR yyyy-mm-dd
134
+ 53,
135
+ // m"月"d"日" OR yyyy-mm-dd
136
+ 54,
137
+ // [$-411]ggge"年"m"月"d"日" OR mm-dd
138
+ 55,
139
+ // yyyy"年"m"月" OR yyyy-mm-dd
140
+ 56,
141
+ // m"月"d"日" OR yyyy-mm-dd
142
+ 57,
143
+ // [$-411]ge.m.d OR yyyy"年" mm"月" dd"日"
144
+ 58 // [$-411]ggge"年"m"月"d"日" OR mm-dd
145
+ ];
146
+
147
+ // "th-th" locale.
148
+ // Language glyphs (aka "hieroglyphs") are not replaced with their respective unicode values here.
149
+ var THAI_LOCALE_BUILT_IN_DATE_FORMAT_IDS = [71,
150
+ // ว/ด/ปปปป
151
+ 72,
152
+ // ว-ดดด-ปป
153
+ 73,
154
+ // ว-ดดด
155
+ 74,
156
+ // ดดด-ปป
157
+ 75,
158
+ // ช:นน
159
+ 76,
160
+ // ช:นน:ทท
161
+ 77,
162
+ // ว/ด/ปปปป ช:นน
163
+ 78,
164
+ // นน:ทท
165
+ 79,
166
+ // [ช]:นน:ทท
167
+ 80,
168
+ // นน:ทท.0
169
+ 81 // d/m/bb
170
+ ];
171
+
172
+ // Start with language-agnostic date format IDs.
173
+ var BUILT_IN_DATE_FORMAT_IDS = LOCALE_INDEPENDENT_BUILT_IN_DATE_FORMAT_IDS.concat(
174
+ // Add Mainland Chinese or Taiwanese date format IDs that haven't already been added.
175
+ MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS).concat(
176
+ // Add Japanese or Korean date format IDs that haven't already been added.
177
+ JAPANESE_OR_KOREAN_LOCALE_BUILT_IN_DATE_FORMAT_IDS.filter(function (numberFormatId) {
178
+ return MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS.indexOf(numberFormatId) < 0;
179
+ })).concat(
180
+ // Add Thai date format IDs that haven't already been added.
181
+ THAI_LOCALE_BUILT_IN_DATE_FORMAT_IDS.filter(function (numberFormatId) {
182
+ return MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS.indexOf(numberFormatId) < 0;
183
+ }).filter(function (numberFormatId) {
184
+ return JAPANESE_OR_KOREAN_LOCALE_BUILT_IN_DATE_FORMAT_IDS.indexOf(numberFormatId) < 0;
185
+ }));
186
+ //# sourceMappingURL=isDateFormatStyle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isDateFormatStyle.js","names":["isDateFormat","isDateFormatStyle","styleId","styles","options","style","Error","concat","numberFormat","BUILT_IN_DATE_FORMAT_IDS","indexOf","Number","id","dateFormat","template","smartDateParser","LOCALE_INDEPENDENT_BUILT_IN_DATE_FORMAT_IDS","MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS","JAPANESE_OR_KOREAN_LOCALE_BUILT_IN_DATE_FORMAT_IDS","THAI_LOCALE_BUILT_IN_DATE_FORMAT_IDS","filter","numberFormatId"],"sources":["../../source/xlsx/isDateFormatStyle.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\r\nimport isDateFormat from './isDateFormat.js'\r\n\r\nexport default function isDateFormatStyle(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_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 && isDateFormat(style.numberFormat.template))\r\n ) {\r\n return true\r\n }\r\n }\r\n}\r\n\r\n// Built-in formats have ID < 164.\r\n// Some of those formats are intended to use when displaying dates.\r\n//\r\n// Depending on the \"locale\" used by the spreadsheet viewing application,\r\n// different built-in format IDs might correspond to different templates.\r\n// https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.numberingformat?view=openxml-2.8.1\r\n//\r\n// Here's a list of \"locale\"-independent built-in format IDs that're known to represent dates.\r\n//\r\nconst LOCALE_INDEPENDENT_BUILT_IN_DATE_FORMAT_IDS = [\r\n 14, // mm-dd-yy\r\n 15, // d-mmm-yy\r\n 16, // d-mmm\r\n 17, // mmm-yy\r\n 18, // h:mm AM/PM\r\n 19, // h:mm:ss AM/PM\r\n 20, // h:mm\r\n 21, // h:mm:ss\r\n 22, // m/d/yy h:mm\r\n 45, // mm:ss\r\n 46, // [h]:mm:ss\r\n 47 // mmss.0\r\n]\r\n\r\n// \"zh-tw\" OR \"zh-cn\" locales.\r\n// Language glyphs (aka \"hieroglyphs\") are not replaced with their respective unicode values here.\r\nconst MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS = [\r\n 27, // [$-404]e/m/d OR yyyy\"年\"m\"月\"\r\n 28, // [$-404]e\"年\"m\"月\"d\"日\" OR m\"月\"d\"日\"\r\n 29, // [$-404]e\"年\"m\"月\"d\"日\" OR m\"月\"d\"日\"\r\n 30, // m/d/yy OR m-d-yy\r\n 31, // yyyy\"年\"m\"月\"d\"日\" OR yyyy\"年\"m\"月\"d\"日\"\r\n 32, // hh\"時\"mm\"分\" OR h\"时\"mm\"分\"\r\n 33, // hh\"時\"mm\"分\"ss\"秒\" OR h\"时\"mm\"分\"ss\"秒\"\r\n 34, // 上午/下午hh\"時\"mm\"分\" OR 上午/下午h\"时\"mm\"分\"\r\n 35, // 上午/下午hh\"時\"mm\"分\"ss\"秒\" OR 上午/下午h\"时\"mm\"分\"ss\"秒\"\r\n 36, // [$-404]e/m/d OR yyyy\"年\"m\"月\"\r\n 50, // [$-404]e/m/d OR yyyy\"年\"m\"月\"\r\n 51, // [$-404]e\"年\"m\"月\"d\"日\" OR m\"月\"d\"日\"\r\n 52, // 上午/下午hh\"時\"mm\"分\" OR yyyy\"年\"m\"月\"\r\n 53, // 上午/下午hh\"時\"mm\"分\"ss\"秒\" OR m\"月\"d\"日\"\r\n 54, // [$-404]e\"年\"m\"月\"d\"日\" OR m\"月\"d\"日\"\r\n 55, // 上午/下午hh\"時\"mm\"分\" OR 上午/下午h\"时\"mm\"分\"\r\n 56, // 上午/下午hh\"時\"mm\"分\"ss\"秒\" OR 上午/下午h\"时\"mm\"分\"ss\"秒\"\r\n 57, // [$-404]e/m/d OR yyyy\"年\"m\"月\"\r\n 58 // [$-404]e\"年\"m\"月\"d\"日\" OR m\"月\"d\"日\"\r\n]\r\n\r\n// \"ja-jp\" OR \"ko-kr\" locales.\r\n// Language glyphs (aka \"hieroglyphs\") are not replaced with their respective unicode values here.\r\nconst JAPANESE_OR_KOREAN_LOCALE_BUILT_IN_DATE_FORMAT_IDS = [\r\n 27, // [$-411]ge.m.d OR yyyy\"年\" mm\"月\" dd\"日\"\r\n 28, // [$-411]ggge\"年\"m\"月\"d\"日\" OR mm-dd\r\n 29, // [$-411]ggge\"年\"m\"月\"d\"日\" OR mm-dd\r\n 30, // m/d/yy OR mm-dd-yy\r\n 31, // yyyy\"年\"m\"月\"d\"日\" OR yyyy\"년\" mm\"월\" dd\"일\"\r\n 32, // h\"時\"mm\"分\" OR h\"시\" mm\"분\"\r\n 33, // h\"時\"mm\"分\"ss\"秒\" OR h\"시\" mm\"분\" ss\"초\"\r\n 34, // yyyy\"年\"m\"月\" OR yyyy-mm-dd\r\n 35, // m\"月\"d\"日\" OR yyyy-mm-dd\r\n 36, // [$-411]ge.m.d OR yyyy\"年\" mm\"月\" dd\"日\"\r\n 50, // [$-411]ge.m.d OR yyyy\"年\" mm\"月\" dd\"日\"\r\n 51, // [$-411]ggge\"年\"m\"月\"d\"日\" OR mm-dd\r\n 52, // yyyy\"年\"m\"月\" OR yyyy-mm-dd\r\n 53, // m\"月\"d\"日\" OR yyyy-mm-dd\r\n 54, // [$-411]ggge\"年\"m\"月\"d\"日\" OR mm-dd\r\n 55, // yyyy\"年\"m\"月\" OR yyyy-mm-dd\r\n 56, // m\"月\"d\"日\" OR yyyy-mm-dd\r\n 57, // [$-411]ge.m.d OR yyyy\"年\" mm\"月\" dd\"日\"\r\n 58 // [$-411]ggge\"年\"m\"月\"d\"日\" OR mm-dd\r\n]\r\n\r\n// \"th-th\" locale.\r\n// Language glyphs (aka \"hieroglyphs\") are not replaced with their respective unicode values here.\r\nconst THAI_LOCALE_BUILT_IN_DATE_FORMAT_IDS = [\r\n 71, // ว/ด/ปปปป\r\n 72, // ว-ดดด-ปป\r\n 73, // ว-ดดด\r\n 74, // ดดด-ปป\r\n 75, // ช:นน\r\n 76, // ช:นน:ทท\r\n 77, // ว/ด/ปปปป ช:นน\r\n 78, // นน:ทท\r\n 79, // [ช]:นน:ทท\r\n 80, // นน:ทท.0\r\n 81 // d/m/bb\r\n]\r\n\r\n// Start with language-agnostic date format IDs.\r\nconst BUILT_IN_DATE_FORMAT_IDS = LOCALE_INDEPENDENT_BUILT_IN_DATE_FORMAT_IDS.concat(\r\n // Add Mainland Chinese or Taiwanese date format IDs that haven't already been added.\r\n MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS\r\n).concat(\r\n // Add Japanese or Korean date format IDs that haven't already been added.\r\n JAPANESE_OR_KOREAN_LOCALE_BUILT_IN_DATE_FORMAT_IDS.filter(\r\n numberFormatId => MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS.indexOf(numberFormatId) < 0\r\n )\r\n).concat(\r\n // Add Thai date format IDs that haven't already been added.\r\n THAI_LOCALE_BUILT_IN_DATE_FORMAT_IDS.filter(\r\n numberFormatId => MAINLAND_CHINESE_OR_TAIWANESE_LOCALE_BUILT_IN_DATE_FORMAT_IDS.indexOf(numberFormatId) < 0\r\n ).filter(\r\n numberFormatId => JAPANESE_OR_KOREAN_LOCALE_BUILT_IN_DATE_FORMAT_IDS.indexOf(numberFormatId) < 0\r\n )\r\n)\r\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,YAAY,MAAM,mBAAmB;AAE5C,eAAe,SAASC,iBAAiBA,CAACC,OAAO,EAAEC,MAAM,EAAEC,OAAO,EAAE;EAClE,IAAIF,OAAO,EAAE;IACX,IAAMG,KAAK,GAAGF,MAAM,CAACD,OAAO,CAAC;IAC7B,IAAI,CAACG,KAAK,EAAE;MACV,MAAM,IAAIC,KAAK,0BAAAC,MAAA,CAA0BL,OAAO,CAAE,CAAC;IACrD;IACA,IAAI,CAACG,KAAK,CAACG,YAAY,EAAE;MACvB,OAAO,KAAK;IACd;IACA;IACE;IACAC,wBAAwB,CAACC,OAAO,CAACC,MAAM,CAACN,KAAK,CAACG,YAAY,CAACI,EAAE,CAAC,CAAC,IAAI,CAAC;IACpE;IACA;IACCR,OAAO,CAACS,UAAU,IAAIR,KAAK,CAACG,YAAY,CAACM,QAAQ,KAAKV,OAAO,CAACS,UAAW;IAC1E;IACA;IACCT,OAAO,CAACW,eAAe,KAAK,KAAK,IAAIV,KAAK,CAACG,YAAY,CAACM,QAAQ,IAAId,YAAY,CAACK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AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE;AAAE;AACJ,EAAE,CAAE;AAAA,CACL;;AAED;AACA,IAAMV,wBAAwB,GAAGO,2CAA2C,CAACT,MAAM;AACjF;AACAU,6DACF,CAAC,CAACV,MAAM;AACN;AACAW,kDAAkD,CAACE,MAAM,CACvD,UAAAC,cAAc;EAAA,OAAIJ,6DAA6D,CAACP,OAAO,CAACW,cAAc,CAAC,GAAG,CAAC;AAAA,CAC7G,CACF,CAAC,CAACd,MAAM;AACN;AACAY,oCAAoC,CAACC,MAAM,CACzC,UAAAC,cAAc;EAAA,OAAIJ,6DAA6D,CAACP,OAAO,CAACW,cAAc,CAAC,GAAG,CAAC;AAAA,CAC7G,CAAC,CAACD,MAAM,CACN,UAAAC,cAAc;EAAA,OAAIH,kDAAkD,CAACR,OAAO,CAACW,cAAc,CAAC,GAAG,CAAC;AAAA,CAClG,CACF,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import parseCellValue from './parseCellValue.js';
2
- import { parseCellCoordinates } from './coordinates.js';
3
- import { getCellValue, getCellInlineStringValue } from '../xml/xlsx.js';
2
+ import parseCellCoordinates from './parseCellCoordinates.js';
3
+ import { getCellValueElement, getCellInlineStringValue } from '../xml/xlsx.js';
4
4
  import { getOuterXml } from '../xml/dom.js';
5
5
 
6
6
  // Example of a `<c/>`ell element:
@@ -28,34 +28,32 @@ import { getOuterXml } from '../xml/dom.js';
28
28
  // </extLst>
29
29
  // </c>
30
30
  //
31
- export default function parseCell(node, sheet, xml, values, styles, properties, options) {
32
- var coords = parseCellCoordinates(node.getAttribute('r'));
33
- var valueElement = getCellValue(sheet, node);
31
+ export default function parseCell(element, sheetDocument, sharedStrings, styles, epoch1904, options) {
32
+ var coordinates = parseCellCoordinates(element.getAttribute('r'));
33
+ var valueElement = getCellValueElement(sheetDocument, element);
34
34
 
35
- // For `xpath`, `value` can be `undefined` while for native `DOMParser` it's `null`.
36
- // So using `value && ...` instead of `if (value !== undefined) { ... }` here
37
- // for uniform compatibility with both `xpath` and native `DOMParser`.
35
+ // When the value element doesn't exist, it would be returned as `undefined`
36
+ // when using `xpath` and as `null` when using `DOMParser`.
37
+ // So here it uses `value && ...` syntax instead of `if (value !== undefined) { ... }`
38
+ // for compatibility with both `xpath` and `DOMParser`.
38
39
  var value = valueElement && valueElement.textContent;
39
- var type;
40
- if (node.hasAttribute('t')) {
41
- type = node.getAttribute('t');
42
- }
40
+ var type = element.getAttribute('t');
43
41
  return {
44
- row: coords[0],
45
- column: coords[1],
42
+ row: coordinates[0],
43
+ column: coordinates[1],
46
44
  value: parseCellValue(value, type, {
47
45
  getInlineStringValue: function getInlineStringValue() {
48
- return getCellInlineStringValue(sheet, node);
46
+ return getCellInlineStringValue(sheetDocument, element);
49
47
  },
50
48
  getInlineStringXml: function getInlineStringXml() {
51
- return getOuterXml(node);
49
+ return getOuterXml(element);
52
50
  },
53
51
  getStyleId: function getStyleId() {
54
- return node.getAttribute('s');
52
+ return element.getAttribute('s');
55
53
  },
56
54
  styles: styles,
57
- values: values,
58
- properties: properties,
55
+ sharedStrings: sharedStrings,
56
+ epoch1904: epoch1904,
59
57
  options: options
60
58
  })
61
59
  };
@@ -1 +1 @@
1
- {"version":3,"file":"parseCell.js","names":["parseCellValue","parseCellCoordinates","getCellValue","getCellInlineStringValue","getOuterXml","parseCell","node","sheet","xml","values","styles","properties","options","coords","getAttribute","valueElement","value","textContent","type","hasAttribute","row","column","getInlineStringValue","getInlineStringXml","getStyleId"],"sources":["../../source/xlsx/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,OAAOA,cAAc,MAAM,qBAAqB;AAEhD,SACEC,oBAAoB,QACf,kBAAkB;AAEzB,SACEC,YAAY,EACZC,wBAAwB,QACnB,gBAAgB;AAEvB,SACEC,WAAW,QACN,eAAe;;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;AACA,eAAe,SAASC,SAASA,CAACC,IAAI,EAAEC,KAAK,EAAEC,GAAG,EAAEC,MAAM,EAAEC,MAAM,EAAEC,UAAU,EAAEC,OAAO,EAAE;EACvF,IAAMC,MAAM,GAAGZ,oBAAoB,CAACK,IAAI,CAACQ,YAAY,CAAC,GAAG,CAAC,CAAC;EAE3D,IAAMC,YAAY,GAAGb,YAAY,CAACK,KAAK,EAAED,IAAI,CAAC;;EAE9C;EACA;EACA;EACA,IAAIU,KAAK,GAAGD,YAAY,IAAIA,YAAY,CAACE,WAAW;EAEpD,IAAIC,IAAI;EACR,IAAIZ,IAAI,CAACa,YAAY,CAAC,GAAG,CAAC,EAAE;IAC1BD,IAAI,GAAGZ,IAAI,CAACQ,YAAY,CAAC,GAAG,CAAC;EAC/B;EAEA,OAAO;IACLM,GAAG,EAAEP,MAAM,CAAC,CAAC,CAAC;IACdQ,MAAM,EAAER,MAAM,CAAC,CAAC,CAAC;IACjBG,KAAK,EAAEhB,cAAc,CAACgB,KAAK,EAAEE,IAAI,EAAE;MACjCI,oBAAoB,EAAE,SAAAA,qBAAA;QAAA,OAAMnB,wBAAwB,CAACI,KAAK,EAAED,IAAI,CAAC;MAAA;MACjEiB,kBAAkB,EAAE,SAAAA,mBAAA;QAAA,OAAMnB,WAAW,CAACE,IAAI,CAAC;MAAA;MAC3CkB,UAAU,EAAE,SAAAA,WAAA;QAAA,OAAMlB,IAAI,CAACQ,YAAY,CAAC,GAAG,CAAC;MAAA;MACxCJ,MAAM,EAANA,MAAM;MACND,MAAM,EAANA,MAAM;MACNE,UAAU,EAAVA,UAAU;MACVC,OAAO,EAAPA;IACF,CAAC;EACH,CAAC;AACH"}
1
+ {"version":3,"file":"parseCell.js","names":["parseCellValue","parseCellCoordinates","getCellValueElement","getCellInlineStringValue","getOuterXml","parseCell","element","sheetDocument","sharedStrings","styles","epoch1904","options","coordinates","getAttribute","valueElement","value","textContent","type","row","column","getInlineStringValue","getInlineStringXml","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,OAAOA,cAAc,MAAM,qBAAqB;AAChD,OAAOC,oBAAoB,MAAM,2BAA2B;AAE5D,SACEC,mBAAmB,EACnBC,wBAAwB,QACnB,gBAAgB;AAEvB,SACEC,WAAW,QACN,eAAe;;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;AACA,eAAe,SAASC,SAASA,CAACC,OAAO,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,EAAEC,SAAS,EAAEC,OAAO,EAAE;EACnG,IAAMC,WAAW,GAAGX,oBAAoB,CAACK,OAAO,CAACO,YAAY,CAAC,GAAG,CAAC,CAAC;EACnE,IAAMC,YAAY,GAAGZ,mBAAmB,CAACK,aAAa,EAAED,OAAO,CAAC;;EAEhE;EACA;EACA;EACA;EACA,IAAMS,KAAK,GAAGD,YAAY,IAAIA,YAAY,CAACE,WAAW;EACtD,IAAMC,IAAI,GAAGX,OAAO,CAACO,YAAY,CAAC,GAAG,CAAC;EAEtC,OAAO;IACLK,GAAG,EAAEN,WAAW,CAAC,CAAC,CAAC;IACnBO,MAAM,EAAEP,WAAW,CAAC,CAAC,CAAC;IACtBG,KAAK,EAAEf,cAAc,CAACe,KAAK,EAAEE,IAAI,EAAE;MACjCG,oBAAoB,EAAE,SAAAA,qBAAA;QAAA,OAAMjB,wBAAwB,CAACI,aAAa,EAAED,OAAO,CAAC;MAAA;MAC5Ee,kBAAkB,EAAE,SAAAA,mBAAA;QAAA,OAAMjB,WAAW,CAACE,OAAO,CAAC;MAAA;MAC9CgB,UAAU,EAAE,SAAAA,WAAA;QAAA,OAAMhB,OAAO,CAACO,YAAY,CAAC,GAAG,CAAC;MAAA;MAC3CJ,MAAM,EAANA,MAAM;MACND,aAAa,EAAbA,aAAa;MACbE,SAAS,EAATA,SAAS;MACTC,OAAO,EAAPA;IACF,CAAC;EACH,CAAC;AACH"}
@@ -0,0 +1,38 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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
+ 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
+ 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
+ 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
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ export default function parseCellCoordinates(coordinatesString) {
8
+ // Coordinate examples: "AA2091", "R988", "B1".
9
+ var _coordinatesString$sp = coordinatesString.split(/(\d+)/),
10
+ _coordinatesString$sp2 = _slicedToArray(_coordinatesString$sp, 2),
11
+ column = _coordinatesString$sp2[0],
12
+ row = _coordinatesString$sp2[1];
13
+ return [
14
+ // Row.
15
+ 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.
19
+ getColumnNumberFromColumnLetters(column.trim())];
20
+ }
21
+
22
+ // 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"];
24
+
25
+ // Converts a letter coordinate to a digit coordinate.
26
+ // Examples: "A" -> 1, "B" -> 2, "Z" -> 26, "AA" -> 27, etc.
27
+ function getColumnNumberFromColumnLetters(columnLetters) {
28
+ // `for ... of ...` would require Babel polyfill for iterating a string.
29
+ var n = 0;
30
+ var i = 0;
31
+ while (i < columnLetters.length) {
32
+ n *= 26;
33
+ n += LETTERS.indexOf(columnLetters[i]);
34
+ i++;
35
+ }
36
+ return n;
37
+ }
38
+ //# sourceMappingURL=parseCellCoordinates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseCellCoordinates.js","names":["parseCellCoordinates","coordinatesString","_coordinatesString$sp","split","_coordinatesString$sp2","_slicedToArray","column","row","Number","getColumnNumberFromColumnLetters","trim","LETTERS","columnLetters","n","i","length","indexOf"],"sources":["../../source/xlsx/parseCellCoordinates.js"],"sourcesContent":["export default function parseCellCoordinates(coordinatesString) {\r\n // Coordinate examples: \"AA2091\", \"R988\", \"B1\".\r\n const [column, row] = coordinatesString.split(/(\\d+)/)\r\n return [\r\n // Row.\r\n Number(row),\r\n // Column.\r\n\t\t// It's not clear why would `column` ever be non-trimmed,\r\n\t\t// but if it was added here then perhaps it could hypothetically happen, or smth.\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,eAAe,SAASA,oBAAoBA,CAACC,iBAAiB,EAAE;EAC9D;EACA,IAAAC,qBAAA,GAAsBD,iBAAiB,CAACE,KAAK,CAAC,OAAO,CAAC;IAAAC,sBAAA,GAAAC,cAAA,CAAAH,qBAAA;IAA/CI,MAAM,GAAAF,sBAAA;IAAEG,GAAG,GAAAH,sBAAA;EAClB,OAAO;EACL;EACAI,MAAM,CAACD,GAAG,CAAC;EACX;EACF;EACA;EACEE,gCAAgC,CAACH,MAAM,CAACI,IAAI,CAAC,CAAC,CAAC,CAChD;AACH;;AAEA;AACA,IAAMC,OAAO,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;;AAEtJ;AACA;AACA,SAASF,gCAAgCA,CAACG,aAAa,EAAE;EACvD;EACA,IAAIC,CAAC,GAAG,CAAC;EACT,IAAIC,CAAC,GAAG,CAAC;EACT,OAAOA,CAAC,GAAGF,aAAa,CAACG,MAAM,EAAE;IAC/BF,CAAC,IAAI,EAAE;IACPA,CAAC,IAAIF,OAAO,CAACK,OAAO,CAACJ,aAAa,CAACE,CAAC,CAAC,CAAC;IACtCA,CAAC,EAAE;EACL;EACA,OAAOD,CAAC;AACV"}
@@ -1,5 +1,5 @@
1
- import parseDate from './parseDate.js';
2
- import isDateTimestamp from './isDateTimestamp.js';
1
+ import parseExcelDate from './parseExcelDate.js';
2
+ import isDateFormatStyle from './isDateFormatStyle.js';
3
3
 
4
4
  // Parses a string `value` of a cell.
5
5
  export default function parseCellValue(value, type, _ref) {
@@ -7,8 +7,8 @@ export default function parseCellValue(value, type, _ref) {
7
7
  getInlineStringXml = _ref.getInlineStringXml,
8
8
  getStyleId = _ref.getStyleId,
9
9
  styles = _ref.styles,
10
- values = _ref.values,
11
- properties = _ref.properties,
10
+ sharedStrings = _ref.sharedStrings,
11
+ epoch1904 = _ref.epoch1904,
12
12
  options = _ref.options;
13
13
  if (!type) {
14
14
  // Default cell type is "n" (numeric).
@@ -51,15 +51,15 @@ export default function parseCellValue(value, type, _ref) {
51
51
  // If a cell has no value then there's no `<c/>` element for it.
52
52
  // If a `<c/>` element exists then it's not empty.
53
53
  // The `<v/>`alue is a key in the "shared strings" dictionary of the
54
- // XLSX file, so look it up in the `values` dictionary by the numeric key.
54
+ // XLSX file, so look it up in the `sharedStrings` dictionary by the numeric key.
55
55
  var sharedStringIndex = Number(value);
56
56
  if (isNaN(sharedStringIndex)) {
57
57
  throw new Error("Invalid \"shared\" string index: ".concat(value));
58
58
  }
59
- if (sharedStringIndex >= values.length) {
59
+ if (sharedStringIndex >= sharedStrings.length) {
60
60
  throw new Error("An out-of-bounds \"shared\" string index: ".concat(value));
61
61
  }
62
- value = values[sharedStringIndex];
62
+ value = sharedStrings[sharedStringIndex];
63
63
  value = parseString(value, options);
64
64
  break;
65
65
 
@@ -110,19 +110,22 @@ export default function parseCellValue(value, type, _ref) {
110
110
  if (value === undefined) {
111
111
  break;
112
112
  }
113
- var isDateTimestampNumber = isDateTimestamp(getStyleId(), styles, options);
114
113
  // XLSX does have "d" type for dates, but it's not commonly used.
115
114
  // Instead, it prefers using "n" type for storing dates as timestamps.
116
- if (isDateTimestampNumber) {
115
+ var styleId = getStyleId();
116
+ if (styleId && isDateFormatStyle(styleId, styles, options)) {
117
117
  // Parse the number from string.
118
118
  value = parseNumberDefault(value);
119
119
  // Parse the number as a date timestamp.
120
- value = parseDate(value, properties);
120
+ value = parseExcelDate(value, {
121
+ epoch1904: epoch1904
122
+ });
121
123
  } else {
122
124
  // Parse the number from string.
123
125
  // Supports custom parsing function to work around javascript number encoding precision issues.
124
126
  // https://gitlab.com/catamphetamine/read-excel-file/-/issues/85
125
- value = (options.parseNumber || parseNumberDefault)(value);
127
+ var parseNumber = options.parseNumber || parseNumberDefault;
128
+ value = parseNumber(value);
126
129
  }
127
130
  break;
128
131
  default:
@@ -1 +1 @@
1
- {"version":3,"file":"parseCellValue.js","names":["parseDate","isDateTimestamp","parseCellValue","value","type","_ref","getInlineStringValue","getInlineStringXml","getStyleId","styles","values","properties","options","parseString","undefined","Error","concat","sharedStringIndex","Number","isNaN","length","decodeError","parsedDate","Date","valueOf","isDateTimestampNumber","parseNumberDefault","parseNumber","TypeError","errorCode","trim","stringifiedNumber","parsedNumber"],"sources":["../../source/xlsx/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,OAAOA,SAAS,MAAM,gBAAgB;AACtC,OAAOC,eAAe,MAAM,sBAAsB;;AAElD;AACA,eAAe,SAASC,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;IACNC,MAAM,GAAAL,IAAA,CAANK,MAAM;IACNC,UAAU,GAAAN,IAAA,CAAVM,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;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,iBAAAb,MAAA,CAAiBa,SAAS;EAC9B;AACF;AAEA,SAAShB,WAAWA,CAACV,KAAK,EAAES,OAAO,EAAE;EACnC;EACA;EACA;EACA;EACA,IAAIA,OAAO,CAACkB,IAAI,KAAK,KAAK,EAAE;IAC1B3B,KAAK,GAAGA,KAAK,CAAC2B,IAAI,CAAC,CAAC;EACtB;EACA,IAAI3B,KAAK,KAAK,EAAE,EAAE;IAChBA,KAAK,GAAGW,SAAS;EACnB;EACA,OAAOX,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASuB,kBAAkBA,CAACK,iBAAiB,EAAE;EAC7C,IAAMC,YAAY,GAAGd,MAAM,CAACa,iBAAiB,CAAC;EAC9C,IAAIZ,KAAK,CAACa,YAAY,CAAC,EAAE;IACvB,MAAM,IAAIjB,KAAK,oCAAAC,MAAA,CAAkCe,iBAAiB,CAAE,CAAC;EACvE;EACA,OAAOC,YAAY;AACrB"}
1
+ {"version":3,"file":"parseCellValue.js","names":["parseExcelDate","isDateFormatStyle","parseCellValue","value","type","_ref","getInlineStringValue","getInlineStringXml","getStyleId","styles","sharedStrings","epoch1904","options","parseString","undefined","Error","concat","sharedStringIndex","Number","isNaN","length","decodeError","parsedDate","Date","valueOf","styleId","parseNumberDefault","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,OAAOA,cAAc,MAAM,qBAAqB;AAChD,OAAOC,iBAAiB,MAAM,wBAAwB;;AAEtD;AACA,eAAe,SAASC,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;IACNC,aAAa,GAAAL,IAAA,CAAbK,aAAa;IACbC,SAAS,GAAAN,IAAA,CAATM,SAAS;IACTC,OAAO,GAAAP,IAAA,CAAPO,OAAO;EAEP,IAAI,CAACR,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,GAAGU,WAAW,CAACV,KAAK,EAAES,OAAO,CAAC;MACnC;;IAEF;IACA;IACA;IACA,KAAK,WAAW;MACdT,KAAK,GAAGG,oBAAoB,CAAC,CAAC;MAC9B,IAAIH,KAAK,KAAKW,SAAS,EAAE;QACvB,MAAM,IAAIC,KAAK,wDAAAC,MAAA,CAAsDT,kBAAkB,CAAC,CAAC,CAAE,CAAC;MAC9F;MACAJ,KAAK,GAAGU,WAAW,CAACV,KAAK,EAAES,OAAO,CAAC;MACnC;;IAEF;IACA;IACA;IACA;IACA;IACA,KAAK,GAAG;MACN;MACA;MACA;MACA;MACA,IAAMK,iBAAiB,GAAGC,MAAM,CAACf,KAAK,CAAC;MACvC,I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ACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASuB,kBAAkBA,CAACK,iBAAiB,EAAE;EAC7C,IAAMC,YAAY,GAAGd,MAAM,CAACa,iBAAiB,CAAC;EAC9C,IAAIZ,KAAK,CAACa,YAAY,CAAC,EAAE;IACvB,MAAM,IAAIjB,KAAK,oCAAAC,MAAA,CAAkCe,iBAAiB,CAAE,CAAC;EACvE;EACA,OAAOC,YAAY;AACrB"}
@@ -1,19 +1,27 @@
1
+ import { getCellElements } from '../xml/xlsx.js';
1
2
  import parseCell from './parseCell.js';
2
- import { getCells, getMergedCells } from '../xml/xlsx.js';
3
- export default function parseCells(sheet, xml, values, styles, properties, options) {
4
- var cells = getCells(sheet);
3
+ export default function parseCells(sheetDocument, sharedStrings, styles, epoch1904, options) {
4
+ var cells = getCellElements(sheetDocument);
5
5
  if (cells.length === 0) {
6
6
  return [];
7
7
  }
8
8
 
9
- // const mergedCells = getMergedCells(sheet)
9
+ // It seems like the idea of parsing "merged cells" was abandoned without being finished.
10
+ // Here, it seems to just get to the stage of parsing merged cell coordinates.
11
+ // Perhaps it's because it's not clear how would the package return merged cell results.
12
+ // I.e. should it just duplicate the value in each one of the merged cells?
13
+ // Or should it keep the existing behavior of only returning the value of the top-most left-most cell
14
+ // and then return `null` for the other ones?
15
+ // Perhaps the latter (existing) approach was found to be the most sensible.
16
+ //
17
+ // const mergedCells = getMergedCellCoordinates(sheetDocument)
10
18
  // for (const mergedCell of mergedCells) {
11
19
  // const [from, to] = mergedCell.split(':').map(parseCellCoordinates)
12
20
  // console.log('Merged Cell.', 'From:', from, 'To:', to)
13
21
  // }
14
22
 
15
- return cells.map(function (node) {
16
- return parseCell(node, sheet, xml, values, styles, properties, options);
23
+ return cells.map(function (element) {
24
+ return parseCell(element, sheetDocument, sharedStrings, styles, epoch1904, options);
17
25
  });
18
26
  }
19
27
  //# sourceMappingURL=parseCells.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseCells.js","names":["parseCell","getCells","getMergedCells","parseCells","sheet","xml","values","styles","properties","options","cells","length","map","node"],"sources":["../../source/xlsx/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,OAAOA,SAAS,MAAM,gBAAgB;AAEtC,SACEC,QAAQ,EACRC,cAAc,QACT,gBAAgB;AAEvB,eAAe,SAASC,UAAUA,CAACC,KAAK,EAAEC,GAAG,EAAEC,MAAM,EAAEC,MAAM,EAAEC,UAAU,EAAEC,OAAO,EAAE;EAClF,IAAMC,KAAK,GAAGT,QAAQ,CAACG,KAAK,CAAC;EAE7B,IAAIM,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE;IACtB,OAAO,EAAE;EACX;;EAEA;EACA;EACA;EACA;EACA;;EAEA,OAAOD,KAAK,CAACE,GAAG,CAAC,UAACC,IAAI,EAAK;IACzB,OAAOb,SAAS,CAACa,IAAI,EAAET,KAAK,EAAEC,GAAG,EAAEC,MAAM,EAAEC,MAAM,EAAEC,UAAU,EAAEC,OAAO,CAAC;EACzE,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"parseCells.js","names":["getCellElements","parseCell","parseCells","sheetDocument","sharedStrings","styles","epoch1904","options","cells","length","map","element"],"sources":["../../source/xlsx/parseCells.js"],"sourcesContent":["import { getCellElements } from '../xml/xlsx.js'\r\n\r\nimport parseCell from './parseCell.js'\r\n\r\nexport default function parseCells(sheetDocument, sharedStrings, styles, epoch1904, options) {\r\n const cells = getCellElements(sheetDocument)\r\n\r\n if (cells.length === 0) {\r\n return []\r\n }\r\n\r\n // It seems like the idea of parsing \"merged cells\" was abandoned without being finished.\r\n // Here, it seems to just get to the stage of parsing merged cell coordinates.\r\n // Perhaps it's because it's not clear how would the package return merged cell results.\r\n // I.e. should it just duplicate the value in each one of the merged cells?\r\n // Or should it keep the existing behavior of only returning the value of the top-most left-most cell\r\n // and then return `null` for the other ones?\r\n // Perhaps the latter (existing) approach was found to be the most sensible.\r\n //\r\n // const mergedCells = getMergedCellCoordinates(sheetDocument)\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((element) => {\r\n return parseCell(element, sheetDocument, sharedStrings, styles, epoch1904, options)\r\n })\r\n}"],"mappings":"AAAA,SAASA,eAAe,QAAQ,gBAAgB;AAEhD,OAAOC,SAAS,MAAM,gBAAgB;AAEtC,eAAe,SAASC,UAAUA,CAACC,aAAa,EAAEC,aAAa,EAAEC,MAAM,EAAEC,SAAS,EAAEC,OAAO,EAAE;EAC3F,IAAMC,KAAK,GAAGR,eAAe,CAACG,aAAa,CAAC;EAE5C,IAAIK,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE;IACtB,OAAO,EAAE;EACX;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA,OAAOD,KAAK,CAACE,GAAG,CAAC,UAACC,OAAO,EAAK;IAC5B,OAAOV,SAAS,CAACU,OAAO,EAAER,aAAa,EAAEC,aAAa,EAAEC,MAAM,EAAEC,SAAS,EAAEC,OAAO,CAAC;EACrF,CAAC,CAAC;AACJ"}