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
@@ -1,73 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = parseExcelDate;
7
- // Parses an Excel Date ("serial") into a corresponding javascript Date in UTC+0 timezone.
8
- // (with time equal to 00:00)
9
- //
10
- // https://www.pcworld.com/article/3063622/software/mastering-excel-date-time-serial-numbers-networkdays-datevalue-and-more.html
11
- // "If you need to calculate dates in your spreadsheets,
12
- // Excel uses its own unique system, which it calls Serial Numbers".
13
- //
14
- function parseExcelDate(excelSerialDate, options) {
15
- // https://support.microsoft.com/en-gb/help/214330/differences-between-the-1900-and-the-1904-date-system-in-excel
16
- if (options && options.epoch1904) {
17
- excelSerialDate += 1462;
18
- }
19
-
20
- // "Excel serial date" is just
21
- // the count of days since `01/01/1900`
22
- // (seems that it may be even fractional).
23
- //
24
- // The count of days elapsed
25
- // since `01/01/1900` (Excel epoch)
26
- // till `01/01/1970` (Unix epoch).
27
- // Accounts for leap years
28
- // (19 of them, yielding 19 extra days).
29
- var daysBeforeUnixEpoch = 70 * 365 + 19;
30
-
31
- // An hour, approximately, because a minute
32
- // may be longer than 60 seconds, due to "leap seconds".
33
- //
34
- // Still, Javascript `Date` (and UNIX time in general) intentionally
35
- // drops the concept of "leap seconds" in order to make things simpler.
36
- // So it's fine.
37
- // https://stackoverflow.com/questions/53019726/where-are-the-leap-seconds-in-javascript
38
- //
39
- // "The JavaScript Date object specifically adheres to the concept of Unix Time
40
- // (albeit with higher precision). This is part of the POSIX specification,
41
- // and thus is sometimes called "POSIX Time". It does not count leap seconds,
42
- // but rather assumes every day had exactly 86,400 seconds. You can read about
43
- // this in section 20.3.1.1 of the current ECMAScript specification, which states:
44
- //
45
- // "Time is measured in ECMAScript in milliseconds since 01 January, 1970 UTC.
46
- // In time values leap seconds are ignored. It is assumed that there are exactly
47
- // 86,400,000 milliseconds per day."
48
- //
49
- // The fact is, that the unpredictable nature of leap seconds makes them very
50
- // difficult to work with in APIs. One can't generally pass timestamps around
51
- // that need leap seconds tables to be interpreted correctly, and expect that
52
- // one system will interpret them the same as another. For example, while your
53
- // example timestamp 1483228826 is 2017-01-01T00:00:00Z on your system,
54
- // it would be interpreted as 2017-01-01T00:00:26Z on POSIX based systems,
55
- // or systems without leap second tables. So they aren't portable.
56
- // Even on systems that have full updated tables, there's no telling what those
57
- // tables will contain in the future (beyond the 6-month IERS announcement period),
58
- // so I can't produce a future timestamp without risk that it may eventually change.
59
- //
60
- // To be clear - to support leap seconds in a programming language, the implementation
61
- // must go out of its way to do so, and must make tradeoffs that are not always acceptable.
62
- // Though there are exceptions, the general position is to not support them - not because
63
- // of any subversion or active countermeasures, but because supporting them properly is much,
64
- // much harder."
65
- //
66
- // https://en.wikipedia.org/wiki/Unix_time#Leap_seconds
67
- // https://en.wikipedia.org/wiki/Leap_year
68
- // https://en.wikipedia.org/wiki/Leap_second
69
- //
70
- var hour = 60 * 60 * 1000;
71
- return new Date(Math.round((excelSerialDate - daysBeforeUnixEpoch) * 24 * hour));
72
- }
73
- //# sourceMappingURL=parseDate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseDate.js","names":["parseExcelDate","excelSerialDate","options","epoch1904","daysBeforeUnixEpoch","hour","Date","Math","round"],"sources":["../../source/xlsx/parseDate.js"],"sourcesContent":["// Parses an Excel Date (\"serial\") into a corresponding javascript Date in UTC+0 timezone.\r\n// (with time equal to 00:00)\r\n//\r\n// https://www.pcworld.com/article/3063622/software/mastering-excel-date-time-serial-numbers-networkdays-datevalue-and-more.html\r\n// \"If you need to calculate dates in your spreadsheets,\r\n// Excel uses its own unique system, which it calls Serial Numbers\".\r\n//\r\nexport default function parseExcelDate(excelSerialDate, options) {\r\n // https://support.microsoft.com/en-gb/help/214330/differences-between-the-1900-and-the-1904-date-system-in-excel\r\n if (options && options.epoch1904) {\r\n excelSerialDate += 1462\r\n }\r\n\r\n // \"Excel serial date\" is just\r\n // the count of days since `01/01/1900`\r\n // (seems that it may be even fractional).\r\n //\r\n // The count of days elapsed\r\n // since `01/01/1900` (Excel epoch)\r\n // till `01/01/1970` (Unix epoch).\r\n // Accounts for leap years\r\n // (19 of them, yielding 19 extra days).\r\n const daysBeforeUnixEpoch = 70 * 365 + 19\r\n\r\n // An hour, approximately, because a minute\r\n // may be longer than 60 seconds, due to \"leap seconds\".\r\n //\r\n // Still, Javascript `Date` (and UNIX time in general) intentionally\r\n // drops the concept of \"leap seconds\" in order to make things simpler.\r\n // So it's fine.\r\n // https://stackoverflow.com/questions/53019726/where-are-the-leap-seconds-in-javascript\r\n //\r\n // \"The JavaScript Date object specifically adheres to the concept of Unix Time\r\n // (albeit with higher precision). This is part of the POSIX specification,\r\n // and thus is sometimes called \"POSIX Time\". It does not count leap seconds,\r\n // but rather assumes every day had exactly 86,400 seconds. You can read about\r\n // this in section 20.3.1.1 of the current ECMAScript specification, which states:\r\n //\r\n // \"Time is measured in ECMAScript in milliseconds since 01 January, 1970 UTC.\r\n // In time values leap seconds are ignored. It is assumed that there are exactly\r\n // 86,400,000 milliseconds per day.\"\r\n //\r\n // The fact is, that the unpredictable nature of leap seconds makes them very\r\n // difficult to work with in APIs. One can't generally pass timestamps around\r\n // that need leap seconds tables to be interpreted correctly, and expect that\r\n // one system will interpret them the same as another. For example, while your\r\n // example timestamp 1483228826 is 2017-01-01T00:00:00Z on your system,\r\n // it would be interpreted as 2017-01-01T00:00:26Z on POSIX based systems,\r\n // or systems without leap second tables. So they aren't portable.\r\n // Even on systems that have full updated tables, there's no telling what those\r\n // tables will contain in the future (beyond the 6-month IERS announcement period),\r\n // so I can't produce a future timestamp without risk that it may eventually change.\r\n //\r\n // To be clear - to support leap seconds in a programming language, the implementation\r\n // must go out of its way to do so, and must make tradeoffs that are not always acceptable.\r\n // Though there are exceptions, the general position is to not support them - not because\r\n // of any subversion or active countermeasures, but because supporting them properly is much,\r\n // much harder.\"\r\n //\r\n // https://en.wikipedia.org/wiki/Unix_time#Leap_seconds\r\n // https://en.wikipedia.org/wiki/Leap_year\r\n // https://en.wikipedia.org/wiki/Leap_second\r\n //\r\n const hour = 60 * 60 * 1000\r\n\r\n return new Date(Math.round((excelSerialDate - daysBeforeUnixEpoch) * 24 * hour))\r\n}"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAcA,CAACC,eAAe,EAAEC,OAAO,EAAE;EAC/D;EACA,IAAIA,OAAO,IAAIA,OAAO,CAACC,SAAS,EAAE;IAChCF,eAAe,IAAI,IAAI;EACzB;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,IAAMG,mBAAmB,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE;;EAEzC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,IAAMC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;EAE3B,OAAO,IAAIC,IAAI,CAACC,IAAI,CAACC,KAAK,CAAC,CAACP,eAAe,GAAGG,mBAAmB,IAAI,EAAE,GAAGC,IAAI,CAAC,CAAC;AAClF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseDate.test.js","names":["_mocha","require","_chai","_parseDate","_interopRequireDefault","obj","__esModule","describe","it","date","convertToUTCTimezone","Date","expect","parseDate","getTime","to","equal","getTimezoneOffset"],"sources":["../../source/xlsx/parseDate.test.js"],"sourcesContent":["import { describe, it } from 'mocha'\r\nimport { expect } from 'chai'\r\n\r\nimport parseDate from './parseDate.js'\r\n\r\ndescribe('parseDate', () => {\r\n\tit('should parse Excel \"serial\" dates', () => {\r\n\t\tconst date = convertToUTCTimezone(new Date(2018, 3 - 1, 24))\r\n // Excel stores dates as integers.\r\n // E.g. '24/03/2018' === 43183\r\n\t\texpect(parseDate(43183).getTime()).to.equal(date.getTime())\r\n\t})\r\n})\r\n\r\n// Converts timezone to UTC while preserving the same time\r\nfunction convertToUTCTimezone(date) {\r\n\t// Doesn't account for leap seconds but I guess that's ok\r\n\t// given that javascript's own `Date()` does not either.\r\n\t// https://www.timeanddate.com/time/leap-seconds-background.html\r\n\t//\r\n\t// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset\r\n\t//\r\n\treturn new Date(date.getTime() - date.getTimezoneOffset() * 60 * 1000)\r\n}\r\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAsC,SAAAG,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAEtC,IAAAE,eAAQ,EAAC,WAAW,EAAE,YAAM;EAC3B,IAAAC,SAAE,EAAC,mCAAmC,EAAE,YAAM;IAC7C,IAAMC,IAAI,GAAGC,oBAAoB,CAAC,IAAIC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IAC1D;IACA;IACF,IAAAC,YAAM,EAAC,IAAAC,qBAAS,EAAC,KAAK,CAAC,CAACC,OAAO,CAAC,CAAC,CAAC,CAACC,EAAE,CAACC,KAAK,CAACP,IAAI,CAACK,OAAO,CAAC,CAAC,CAAC;EAC5D,CAAC,CAAC;AACH,CAAC,CAAC;;AAEF;AACA,SAASJ,oBAAoBA,CAACD,IAAI,EAAE;EACnC;EACA;EACA;EACA;EACA;EACA;EACA,OAAO,IAAIE,IAAI,CAACF,IAAI,CAACK,OAAO,CAAC,CAAC,GAAGL,IAAI,CAACQ,iBAAiB,CAAC,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AACvE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseDimensions.js","names":["_coordinates","require","_xlsx","_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","o","minLen","_arrayLikeToArray","n","Object","prototype","toString","call","slice","constructor","name","Array","from","test","len","length","arr2","r","l","t","Symbol","iterator","e","u","a","f","next","done","push","value","isArray","parseDimensions","sheet","dimensions","getDimensions","split","map","parseCellCoordinates","_ref","_ref2","row","column"],"sources":["../../source/xlsx/parseDimensions.js"],"sourcesContent":["import {\r\n parseCellCoordinates\r\n} from './coordinates.js'\r\n\r\nimport {\r\n getDimensions\r\n} from '../xml/xlsx.js'\r\n\r\n// `dimensions` defines the spreadsheet area containing all non-empty cells.\r\n// https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.sheetdimension?view=openxml-2.8.1\r\nexport default function parseDimensions(sheet) {\r\n let dimensions = getDimensions(sheet)\r\n if (dimensions) {\r\n dimensions = dimensions.split(':').map(parseCellCoordinates).map(([row, column]) => ({\r\n row,\r\n column\r\n }))\r\n // Sometimes there can be just a single cell as a spreadsheet's \"dimensions\".\r\n // For example, the default \"dimensions\" in Apache POI library is \"A1\",\r\n // meaning that only the first cell in the spreadsheet is used.\r\n //\r\n // A quote from Apache POI library:\r\n // \"Single cell ranges are formatted like single cell references (e.g. 'A1' instead of 'A1:A1').\"\r\n //\r\n if (dimensions.length === 1) {\r\n dimensions = [dimensions[0], dimensions[0]]\r\n }\r\n return dimensions\r\n }\r\n}\r\n\r\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AAEuB,SAAAE,eAAAC,GAAA,EAAAC,CAAA,WAAAC,eAAA,CAAAF,GAAA,KAAAG,qBAAA,CAAAH,GAAA,EAAAC,CAAA,KAAAG,2BAAA,CAAAJ,GAAA,EAAAC,CAAA,KAAAI,gBAAA;AAAA,SAAAA,iBAAA,cAAAC,SAAA;AAAA,SAAAF,4BAAAG,CAAA,EAAAC,MAAA,SAAAD,CAAA,qBAAAA,CAAA,sBAAAE,iBAAA,CAAAF,CAAA,EAAAC,MAAA,OAAAE,CAAA,GAAAC,MAAA,CAAAC,SAAA,CAAAC,QAAA,CAAAC,IAAA,CAAAP,CAAA,EAAAQ,KAAA,aAAAL,CAAA,iBAAAH,CAAA,CAAAS,WAAA,EAAAN,CAAA,GAAAH,CAAA,CAAAS,WAAA,CAAAC,IAAA,MAAAP,CAAA,cAAAA,CAAA,mBAAAQ,KAAA,CAAAC,IAAA,CAAAZ,CAAA,OAAAG,CAAA,+DAAAU,IAAA,CAAAV,CAAA,UAAAD,iBAAA,CAAAF,CAAA,EAAAC,MAAA;AAAA,SAAAC,kBAAAT,GAAA,EAAAqB,GAAA,QAAAA,GAAA,YAAA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AU,EAAE;IACdA,UAAU,GAAGA,UAAU,CAACE,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAACC,iCAAoB,CAAC,CAACD,GAAG,CAAC,UAAAE,IAAA;MAAA,IAAAC,KAAA,GAAA/C,cAAA,CAAA8C,IAAA;QAAEE,GAAG,GAAAD,KAAA;QAAEE,MAAM,GAAAF,KAAA;MAAA,OAAO;QACnFC,GAAG,EAAHA,GAAG;QACHC,MAAM,EAANA;MACF,CAAC;IAAA,CAAC,CAAC;IACH;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAIR,UAAU,CAAClB,MAAM,KAAK,CAAC,EAAE;MAC3BkB,UAAU,GAAG,CAACA,UAAU,CAAC,CAAC,CAAC,EAAEA,UAAU,CAAC,CAAC,CAAC,CAAC;IAC7C;IACA,OAAOA,UAAU;EACnB;AACF"}
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = parseProperties;
7
- var _xlsx = require("../xml/xlsx.js");
8
- // I guess `xl/workbook.xml` file should always be present inside the *.xlsx archive.
9
- function parseProperties(content, xml) {
10
- var book = xml.createDocument(content);
11
- var properties = {};
12
-
13
- // Read `<workbookPr/>` element to detect whether dates are 1900-based or 1904-based.
14
- // https://support.microsoft.com/en-gb/help/214330/differences-between-the-1900-and-the-1904-date-system-in-excel
15
- // http://webapp.docx4java.org/OnlineDemo/ecma376/SpreadsheetML/workbookPr.html
16
-
17
- var workbookProperties = (0, _xlsx.getWorkbookProperties)(book);
18
- if (workbookProperties && workbookProperties.getAttribute('date1904') === '1') {
19
- properties.epoch1904 = true;
20
- }
21
-
22
- // Get sheets info (indexes, names, if they're available).
23
- // Example:
24
- // <sheets>
25
- // <sheet
26
- // xmlns:ns="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
27
- // name="Sheet1"
28
- // sheetId="1"
29
- // ns:id="rId3"/>
30
- // </sheets>
31
- // http://www.datypic.com/sc/ooxml/e-ssml_sheet-1.html
32
-
33
- properties.sheets = [];
34
- var addSheetInfo = function addSheetInfo(sheet) {
35
- if (sheet.getAttribute('name')) {
36
- properties.sheets.push({
37
- id: sheet.getAttribute('sheetId'),
38
- name: sheet.getAttribute('name'),
39
- relationId: sheet.getAttribute('r:id')
40
- });
41
- }
42
- };
43
- (0, _xlsx.getSheets)(book).forEach(addSheetInfo);
44
- return properties;
45
- }
46
- //# sourceMappingURL=parseProperties.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseProperties.js","names":["_xlsx","require","parseProperties","content","xml","book","createDocument","properties","workbookProperties","getWorkbookProperties","getAttribute","epoch1904","sheets","addSheetInfo","sheet","push","id","name","relationId","getSheets","forEach"],"sources":["../../source/xlsx/parseProperties.js"],"sourcesContent":["import {\r\n getWorkbookProperties,\r\n getSheets\r\n} from '../xml/xlsx.js'\r\n\r\n// I guess `xl/workbook.xml` file should always be present inside the *.xlsx archive.\r\nexport default function parseProperties(content, xml) {\r\n const book = xml.createDocument(content)\r\n\r\n const properties = {};\r\n\r\n // Read `<workbookPr/>` element to detect whether dates are 1900-based or 1904-based.\r\n // https://support.microsoft.com/en-gb/help/214330/differences-between-the-1900-and-the-1904-date-system-in-excel\r\n // http://webapp.docx4java.org/OnlineDemo/ecma376/SpreadsheetML/workbookPr.html\r\n\r\n const workbookProperties = getWorkbookProperties(book)\r\n\r\n if (workbookProperties && workbookProperties.getAttribute('date1904') === '1') {\r\n properties.epoch1904 = true\r\n }\r\n\r\n // Get sheets info (indexes, names, if they're available).\r\n // Example:\r\n // <sheets>\r\n // <sheet\r\n // xmlns:ns=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"\r\n // name=\"Sheet1\"\r\n // sheetId=\"1\"\r\n // ns:id=\"rId3\"/>\r\n // </sheets>\r\n // http://www.datypic.com/sc/ooxml/e-ssml_sheet-1.html\r\n\r\n properties.sheets = []\r\n\r\n const addSheetInfo = (sheet) => {\r\n if (sheet.getAttribute('name')) {\r\n properties.sheets.push({\r\n id: sheet.getAttribute('sheetId'),\r\n name: sheet.getAttribute('name'),\r\n relationId: sheet.getAttribute('r:id')\r\n })\r\n }\r\n }\r\n\r\n getSheets(book).forEach(addSheetInfo)\r\n\r\n return properties;\r\n}"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAKA;AACe,SAASC,eAAeA,CAACC,OAAO,EAAEC,GAAG,EAAE;EACpD,IAAMC,IAAI,GAAGD,GAAG,CAACE,cAAc,CAACH,OAAO,CAAC;EAExC,IAAMI,UAAU,GAAG,CAAC,CAAC;;EAErB;EACA;EACA;;EAEA,IAAMC,kBAAkB,GAAG,IAAAC,2BAAqB,EAACJ,IAAI,CAAC;EAEtD,IAAIG,kBAAkB,IAAIA,kBAAkB,CAACE,YAAY,CAAC,UAAU,CAAC,KAAK,GAAG,EAAE;IAC7EH,UAAU,CAACI,SAAS,GAAG,IAAI;EAC7B;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEAJ,UAAU,CAACK,MAAM,GAAG,EAAE;EAEtB,IAAMC,YAAY,GAAG,SAAfA,YAAYA,CAAIC,KAAK,EAAK;IAC9B,IAAIA,KAAK,CAACJ,YAAY,CAAC,MAAM,CAAC,EAAE;MAC9BH,UAAU,CAACK,MAAM,CAACG,IAAI,CAAC;QACrBC,EAAE,EAAEF,KAAK,CAACJ,YAAY,CAAC,SAAS,CAAC;QACjCO,IAAI,EAAEH,KAAK,CAACJ,YAAY,CAAC,MAAM,CAAC;QAChCQ,UAAU,EAAEJ,KAAK,CAACJ,YAAY,CAAC,MAAM;MACvC,CAAC,CAAC;IACJ;EACF,CAAC;EAED,IAAAS,eAAS,EAACd,IAAI,CAAC,CAACe,OAAO,CAACP,YAAY,CAAC;EAErC,OAAON,UAAU;AACnB"}
@@ -1,119 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = parseXlsxFileContents;
7
- var _parseProperties = _interopRequireDefault(require("./parseProperties.js"));
8
- var _parseFilePaths = _interopRequireDefault(require("./parseFilePaths.js"));
9
- var _parseStyles = _interopRequireDefault(require("./parseStyles.js"));
10
- var _parseSharedStrings = _interopRequireDefault(require("./parseSharedStrings.js"));
11
- var _parseSheet = _interopRequireDefault(require("./parseSheet.js"));
12
- var _getData = _interopRequireDefault(require("./getData.js"));
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
15
- 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."); }
16
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
17
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
18
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
19
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
20
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
22
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
23
- // For an introduction in reading `*.xlsx` files see "The minimum viable XLSX reader":
24
- // https://www.brendanlong.com/the-minimum-viable-xlsx-reader.html
25
- /**
26
- * Reads data from an `.xlsx` spreadsheet.
27
- * @param {Record<string,string>} contents - A map of XML files inside XLSX file (which is just a zipped directory).
28
- * @param {object} xml — An object with a function `createDocument(string)`.
29
- * @param {number?} options.sheet - Workbook sheet id (`1` by default).
30
- * @param {string?} options.dateFormat - Date format, e.g. "mm/dd/yyyy". Values having this format template set will be parsed as dates.
31
- * @return {object} An object of shape `{ data, cells, properties }`. `data: string[][]` is an array of rows, each row being an array of cell values. `cells: string[][]` is an array of rows, each row being an array of cells. `properties: object` is the spreadsheet properties (e.g. whether date epoch is 1904 instead of 1900).
32
- */
33
- function parseXlsxFileContents(contents, xml) {
34
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
35
- if (!options.sheet) {
36
- options = _objectSpread({
37
- sheet: 1
38
- }, options);
39
- }
40
- var getXmlFileContent = function getXmlFileContent(filePath) {
41
- if (!contents[filePath]) {
42
- throw new Error("\"".concat(filePath, "\" file not found inside the *.xlsx file zip archive"));
43
- }
44
- return contents[filePath];
45
- };
46
-
47
- // Read the paths to certain files inside the `.xlsx` `.zip` archive.
48
- // These paths aren't standardized between different spreadsheet editors.
49
- // https://github.com/tidyverse/readxl/issues/104
50
- var filePaths = (0, _parseFilePaths["default"])(getXmlFileContent('xl/_rels/workbook.xml.rels'), xml);
51
-
52
- // Usual file path for "shared strings": "xl/sharedStrings.xml".
53
- var values = filePaths.sharedStrings ? (0, _parseSharedStrings["default"])(getXmlFileContent(filePaths.sharedStrings), xml) : [];
54
-
55
- // Usual file path for "styles": "xl/styles.xml".
56
- var styles = filePaths.styles ? (0, _parseStyles["default"])(getXmlFileContent(filePaths.styles), xml) : {};
57
- var properties = (0, _parseProperties["default"])(getXmlFileContent('xl/workbook.xml'), xml);
58
-
59
- // A feature for getting the list of sheets in an Excel file.
60
- // https://github.com/catamphetamine/read-excel-file/issues/14
61
- if (options.getSheets) {
62
- return properties.sheets.map(function (_ref) {
63
- var name = _ref.name;
64
- return {
65
- name: name
66
- };
67
- });
68
- }
69
-
70
- // Find the sheet by name, or take the first one.
71
- var sheetId = getSheetId(options.sheet, properties.sheets);
72
-
73
- // If the sheet wasn't found then throw an error.
74
- // Example: "xl/worksheets/sheet1.xml".
75
- if (!sheetId || !filePaths.sheets[sheetId]) {
76
- throw createSheetNotFoundError(options.sheet, properties.sheets);
77
- }
78
-
79
- // Parse sheet data.
80
- var sheet = (0, _parseSheet["default"])(getXmlFileContent(filePaths.sheets[sheetId]), xml, values, styles, properties, options);
81
- options = _objectSpread({
82
- // Create a `rowIndexSourceMap` for the original dataset, if not passed,
83
- // because "empty" rows will be dropped from the input data.
84
- rowIndexSourceMap: []
85
- }, options);
86
-
87
- // Get spreadsheet data.
88
- var data = (0, _getData["default"])(sheet, options);
89
-
90
- // Can return properties, if required.
91
- if (options.properties) {
92
- return {
93
- data: data,
94
- properties: properties
95
- };
96
- }
97
-
98
- // Return spreadsheet data.
99
- return data;
100
- }
101
- function getSheetId(sheet, sheets) {
102
- if (typeof sheet === 'number') {
103
- var _sheet = sheets[sheet - 1];
104
- return _sheet && _sheet.relationId;
105
- }
106
- for (var _iterator = _createForOfIteratorHelperLoose(sheets), _step; !(_step = _iterator()).done;) {
107
- var _sheet2 = _step.value;
108
- if (_sheet2.name === sheet) {
109
- return _sheet2.relationId;
110
- }
111
- }
112
- }
113
- function createSheetNotFoundError(sheet, sheets) {
114
- var sheetsList = sheets && sheets.map(function (sheet, i) {
115
- return "\"".concat(sheet.name, "\" (#").concat(i + 1, ")");
116
- }).join(', ');
117
- return new Error("Sheet ".concat(typeof sheet === 'number' ? '#' + sheet : '"' + sheet + '"', " not found in the *.xlsx file.").concat(sheets ? ' Available sheets: ' + sheetsList + '.' : ''));
118
- }
119
- //# sourceMappingURL=parseXlsxFileContents.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseXlsxFileContents.js","names":["_parseProperties","_interopRequireDefault","require","_parseFilePaths","_parseStyles","_parseSharedStrings","_parseSheet","_getData","obj","__esModule","_typeof","o","Symbol","iterator","constructor","prototype","_createForOfIteratorHelperLoose","allowArrayLike","it","call","next","bind","Array","isArray","_unsupportedIterableToArray","length","i","done","value","TypeError","minLen","_arrayLikeToArray","n","Object","toString","slice","name","from","test","arr","len","arr2","ownKeys","e","r","t","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","toPrimitive","undefined","res","Number","parseXlsxFileContents","contents","xml","options","sheet","getXmlFileContent","filePath","Error","concat","filePaths","parseFilePaths","values","sharedStrings","parseSharedStrings","styles","parseStyles","properties","parseProperties","getSheets","sheets","map","_ref","sheetId","getSheetId","createSheetNotFoundError","parseSheet","rowIndexSourceMap","data","getData","_sheet","relationId","_iterator","_step","sheetsList","join"],"sources":["../../source/xlsx/parseXlsxFileContents.js"],"sourcesContent":["import parseProperties from './parseProperties.js'\r\nimport parseFilePaths from './parseFilePaths.js'\r\nimport parseStyles from './parseStyles.js'\r\nimport parseSharedStrings from './parseSharedStrings.js'\r\nimport parseSheet from './parseSheet.js'\r\nimport getData from './getData.js'\r\n\r\n// For an introduction in reading `*.xlsx` files see \"The minimum viable XLSX reader\":\r\n// https://www.brendanlong.com/the-minimum-viable-xlsx-reader.html\r\n\r\n/**\r\n * Reads data from an `.xlsx` spreadsheet.\r\n * @param {Record<string,string>} contents - A map of XML files inside XLSX file (which is just a zipped directory).\r\n * @param {object} xml — An object with a function `createDocument(string)`.\r\n * @param {number?} options.sheet - Workbook sheet id (`1` by default).\r\n * @param {string?} options.dateFormat - Date format, e.g. \"mm/dd/yyyy\". Values having this format template set will be parsed as dates.\r\n * @return {object} An object of shape `{ data, cells, properties }`. `data: string[][]` is an array of rows, each row being an array of cell values. `cells: string[][]` is an array of rows, each row being an array of cells. `properties: object` is the spreadsheet properties (e.g. whether date epoch is 1904 instead of 1900).\r\n */\r\nexport default function parseXlsxFileContents(contents, xml, options = {}) {\r\n if (!options.sheet) {\r\n options = {\r\n sheet: 1,\r\n ...options\r\n }\r\n }\r\n\r\n const getXmlFileContent = (filePath) => {\r\n if (!contents[filePath]) {\r\n throw new Error(`\"${filePath}\" file not found inside the *.xlsx file zip archive`)\r\n }\r\n return contents[filePath]\r\n }\r\n\r\n // Read the paths to certain files inside the `.xlsx` `.zip` archive.\r\n // These paths aren't standardized between different spreadsheet editors.\r\n // https://github.com/tidyverse/readxl/issues/104\r\n const filePaths = parseFilePaths(getXmlFileContent('xl/_rels/workbook.xml.rels'), xml)\r\n\r\n // Usual file path for \"shared strings\": \"xl/sharedStrings.xml\".\r\n const values = filePaths.sharedStrings\r\n ? parseSharedStrings(getXmlFileContent(filePaths.sharedStrings), xml)\r\n : []\r\n\r\n // Usual file path for \"styles\": \"xl/styles.xml\".\r\n const styles = filePaths.styles\r\n ? parseStyles(getXmlFileContent(filePaths.styles), xml)\r\n : {}\r\n\r\n const properties = parseProperties(getXmlFileContent('xl/workbook.xml'), xml)\r\n\r\n // A feature for getting the list of sheets in an Excel file.\r\n // https://github.com/catamphetamine/read-excel-file/issues/14\r\n if (options.getSheets) {\r\n return properties.sheets.map(({ name }) => ({\r\n name\r\n }))\r\n }\r\n\r\n // Find the sheet by name, or take the first one.\r\n const sheetId = getSheetId(options.sheet, properties.sheets)\r\n\r\n // If the sheet wasn't found then throw an error.\r\n // Example: \"xl/worksheets/sheet1.xml\".\r\n if (!sheetId || !filePaths.sheets[sheetId]) {\r\n throw createSheetNotFoundError(options.sheet, properties.sheets)\r\n }\r\n\r\n // Parse sheet data.\r\n const sheet = parseSheet(\r\n getXmlFileContent(filePaths.sheets[sheetId]),\r\n xml,\r\n values,\r\n styles,\r\n properties,\r\n options\r\n )\r\n\r\n options = {\r\n // Create a `rowIndexSourceMap` for the original dataset, if not passed,\r\n // because \"empty\" rows will be dropped from the input data.\r\n rowIndexSourceMap: [],\r\n ...options\r\n }\r\n\r\n // Get spreadsheet data.\r\n const data = getData(sheet, options)\r\n\r\n // Can return properties, if required.\r\n if (options.properties) {\r\n return {\r\n data,\r\n properties\r\n }\r\n }\r\n\r\n // Return spreadsheet data.\r\n return data\r\n}\r\n\r\nfunction getSheetId(sheet, sheets) {\r\n if (typeof sheet === 'number') {\r\n const _sheet = sheets[sheet - 1]\r\n return _sheet && _sheet.relationId\r\n }\r\n for (const _sheet of sheets) {\r\n if (_sheet.name === sheet) {\r\n return _sheet.relationId\r\n }\r\n }\r\n}\r\n\r\nfunction createSheetNotFoundError(sheet, sheets) {\r\n const sheetsList = sheets && sheets.map((sheet, i) => `\"${sheet.name}\" (#${i + 1})`).join(', ')\r\n return new Error(`Sheet ${typeof sheet === 'number' ? '#' + sheet : '\"' + s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A,GAAAzF,+BAAA,CAAqB6E,MAAM,GAAAa,KAAA,IAAAA,KAAA,GAAAD,SAAA,IAAA9E,IAAA,GAAE;IAAA,IAAlB4E,OAAM,GAAAG,KAAA,CAAA9E,KAAA;IACf,IAAI2E,OAAM,CAACnE,IAAI,KAAK0C,KAAK,EAAE;MACzB,OAAOyB,OAAM,CAACC,UAAU;IAC1B;EACF;AACF;AAEA,SAASN,wBAAwBA,CAACpB,KAAK,EAAEe,MAAM,EAAE;EAC/C,IAAMc,UAAU,GAAGd,MAAM,IAAIA,MAAM,CAACC,GAAG,CAAC,UAAChB,KAAK,EAAEpD,CAAC;IAAA,YAAAwD,MAAA,CAASJ,KAAK,CAAC1C,IAAI,WAAA8C,MAAA,CAAOxD,CAAC,GAAG,CAAC;EAAA,CAAG,CAAC,CAACkF,IAAI,CAAC,IAAI,CAAC;EAC/F,OAAO,IAAI3B,KAAK,UAAAC,MAAA,CAAU,OAAOJ,KAAK,KAAK,QAAQ,GAAG,GAAG,GAAGA,KAAK,GAAG,GAAG,GAAGA,KAAK,GAAG,GAAG,oCAAAI,MAAA,CAAiCW,MAAM,GAAG,qBAAqB,GAAGc,UAAU,GAAG,GAAG,GAAG,EAAE,CAAE,CAAC;AACjL"}
@@ -1,45 +0,0 @@
1
- "use strict";
2
-
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports["default"] = parseXlsxFileContentsWithOptionalSchema;
8
- var _parseXlsxFileContents = _interopRequireDefault(require("./parseXlsxFileContents.js"));
9
- var _mapToObjects = _interopRequireDefault(require("./schema/mapToObjects.js"));
10
- var _excluded = ["schema"];
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
16
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
17
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
18
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
19
- /**
20
- * Reads data from an `.xlsx` spreadsheet.
21
- * @param {Record<string,string>} contents — A map of XML files inside XLSX file (which is just a zipped directory).
22
- * @param {object} xml — An object with a function `createDocument(string)`.
23
- * @param {object} options
24
- * @returns Spreadsheet data
25
- */
26
- function parseXlsxFileContentsWithOptionalSchema(contents, xml, _ref) {
27
- var schema = _ref.schema,
28
- options = _objectWithoutProperties(_ref, _excluded);
29
- if (options.map) {
30
- throw new Error('`map` option was removed. Pass a `schema` option instead.');
31
- }
32
- // `parseXlsxFileContents()` function creates `options.rowIndexSourceMap` property.
33
- // It maps parsed data row indexes to spreadsheet row indexes.
34
- // That's because empty rows are ignored (discarded) when parsing using `schema`.
35
- var result = (0, _parseXlsxFileContents["default"])(contents, xml, _objectSpread(_objectSpread({}, options), {}, {
36
- properties: schema || options.properties
37
- }));
38
- if (schema) {
39
- return (0, _mapToObjects["default"])(result.data, schema, _objectSpread(_objectSpread({}, options), {}, {
40
- properties: result.properties
41
- }));
42
- }
43
- return result;
44
- }
45
- //# sourceMappingURL=parseXlsxFileContentsWithOptionalSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseXlsxFileContentsWithOptionalSchema.js","names":["_parseXlsxFileContents","_interopRequireDefault","require","_mapToObjects","_excluded","obj","__esModule","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","_typeof","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","_objectWithoutProperties","source","excluded","target","_objectWithoutPropertiesLoose","i","sourceSymbolKeys","indexOf","prototype","propertyIsEnumerable","sourceKeys","parseXlsxFileContentsWithOptionalSchema","contents","xml","_ref","schema","options","map","Error","result","parseXlsxFileContents","properties","mapToObjects","data"],"sources":["../../source/xlsx/parseXlsxFileContentsWithOptionalSchema.js"],"sourcesContent":["import parseXlsxFileContents from './parseXlsxFileContents.js'\r\n\r\nimport mapToObjects from './schema/mapToObjects.js'\r\n\r\n/**\r\n * Reads data from an `.xlsx` spreadsheet.\r\n * @param {Record<string,string>} contents — A map of XML files inside XLSX file (which is just a zipped directory).\r\n * @param {object} xml — An object with a function `createDocument(string)`.\r\n * @param {object} options\r\n * @returns Spreadsheet data\r\n */\r\nexport default function parseXlsxFileContentsWithOptionalSchema(contents, xml, { schema, ...options }) {\r\n\tif (options.map) {\r\n\t\tthrow new Error('`map` option was removed. Pass a `schema` option instead.')\r\n\t}\r\n\t// `parseXlsxFileContents()` function creates `options.rowIndexSourceMap` property.\r\n\t// It maps parsed data row indexes to spreadsheet row indexes.\r\n\t// That's because empty rows are ignored (discarded) when parsing using `schema`.\r\n\tconst result = parseXlsxFileContents(contents, xml, {\r\n\t\t...options,\r\n\t\tproperties: schema || options.properties\r\n\t})\r\n\tif (schema) {\r\n\t\treturn mapToObjects(result.data, schema, {\r\n\t\t\t...options,\r\n\t\t\tproperties: result.properties\r\n\t\t})\r\n\t}\r\n\treturn result\r\n}"],"mappings":";;;;;;;AAAA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAmD,IAAAE,SAAA;AAAA,SAAAH,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAAA,SAAAE,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA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