read-excel-file 9.2.0 → 9.3.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.
- package/.gitlab-ci.yml +1 -1
- package/CHANGELOG.md +5 -0
- package/README.md +153 -50
- package/bundle/read-excel-file.min.js +1 -1
- package/bundle/read-excel-file.min.js.map +1 -1
- package/bundle/read-excel-file.min.old.js +2 -0
- package/bundle/read-excel-file.min.old.js.map +1 -0
- package/commonjs/export/convertValuesFromUint8ArraysToStrings.js +3 -0
- package/commonjs/export/convertValuesFromUint8ArraysToStrings.js.map +1 -1
- package/commonjs/export/parseSheet.js +12 -9
- package/commonjs/export/parseSheet.js.map +1 -1
- package/commonjs/export/readSheetBrowser.js +6 -2
- package/commonjs/export/readSheetBrowser.js.map +1 -1
- package/commonjs/export/readSheetNode.js +6 -2
- package/commonjs/export/readSheetNode.js.map +1 -1
- package/commonjs/export/readSheetUniversal.js +14 -2
- package/commonjs/export/readSheetUniversal.js.map +1 -1
- package/commonjs/export/readSheetWebWorker.js +12 -2
- package/commonjs/export/readSheetWebWorker.js.map +1 -1
- package/commonjs/export/readXlsxFileBrowser.js +6 -2
- package/commonjs/export/readXlsxFileBrowser.js.map +1 -1
- package/commonjs/export/readXlsxFileNode.js +6 -2
- package/commonjs/export/readXlsxFileNode.js.map +1 -1
- package/commonjs/export/readXlsxFileUniversal.js +14 -2
- package/commonjs/export/readXlsxFileUniversal.js.map +1 -1
- package/commonjs/export/readXlsxFileWebWorker.js +12 -2
- package/commonjs/export/readXlsxFileWebWorker.js.map +1 -1
- package/commonjs/export/unpackXlsxFileBrowser.js +29 -6
- package/commonjs/export/unpackXlsxFileBrowser.js.map +1 -1
- package/commonjs/export/unpackXlsxFileNode.js +6 -0
- package/commonjs/export/unpackXlsxFileNode.js.map +1 -1
- package/commonjs/export/unpackXlsxFileUniversal.js +6 -0
- package/commonjs/export/unpackXlsxFileUniversal.js.map +1 -1
- package/commonjs/export/unpackXlsxFileWebWorker.js +14 -0
- package/commonjs/export/unpackXlsxFileWebWorker.js.map +1 -0
- package/commonjs/parseSheetData/parseSheetData.js +6 -6
- package/commonjs/parseSheetData/parseSheetData.js.map +1 -1
- package/commonjs/utility/checkpoint.js +33 -0
- package/commonjs/utility/checkpoint.js.map +1 -0
- package/commonjs/utility/isObject.js +15 -0
- package/commonjs/utility/isObject.js.map +1 -0
- package/commonjs/utility/isPromise.js +18 -0
- package/commonjs/utility/isPromise.js.map +1 -0
- package/commonjs/xlsx/convertCellsToData2dArray.js +0 -3
- package/commonjs/xlsx/convertCellsToData2dArray.js.map +1 -1
- package/commonjs/xlsx/isDateFormatStyle.js +2 -2
- package/commonjs/xlsx/isDateFormatStyle.js.map +1 -1
- package/commonjs/xlsx/parseCell.js +89 -24
- package/commonjs/xlsx/parseCell.js.map +1 -1
- package/{modules/xlsx/parseCellCoordinates.js → commonjs/xlsx/parseCellAddress.js} +18 -7
- package/commonjs/xlsx/parseCellAddress.js.map +1 -0
- package/commonjs/xlsx/parseCellValue.js +7 -23
- package/commonjs/xlsx/parseCellValue.js.map +1 -1
- package/commonjs/xlsx/parseFilePaths.js +31 -32
- package/commonjs/xlsx/parseFilePaths.js.map +1 -1
- package/commonjs/xlsx/parseNumber.js +20 -0
- package/commonjs/xlsx/parseNumber.js.map +1 -0
- package/commonjs/xlsx/parseSharedString.js +64 -0
- package/commonjs/xlsx/parseSharedString.js.map +1 -0
- package/commonjs/xlsx/parseSharedStrings.js +45 -5
- package/commonjs/xlsx/parseSharedStrings.js.map +1 -1
- package/commonjs/xlsx/parseSheet.js +93 -9
- package/commonjs/xlsx/parseSheet.js.map +1 -1
- package/commonjs/xlsx/parseSheetData.js +68 -0
- package/commonjs/xlsx/parseSheetData.js.map +1 -0
- package/commonjs/xlsx/parseSpreadsheetContents.js +244 -43
- package/commonjs/xlsx/parseSpreadsheetContents.js.map +1 -1
- package/commonjs/xlsx/parseSpreadsheetInfo.js +67 -36
- package/commonjs/xlsx/parseSpreadsheetInfo.js.map +1 -1
- package/commonjs/xlsx/parseStyles.js +89 -36
- package/commonjs/xlsx/parseStyles.js.map +1 -1
- package/commonjs/xml/dom.js +2 -1
- package/commonjs/xml/dom.js.map +1 -1
- package/commonjs/xml/parseXmlStream.js +14 -0
- package/commonjs/xml/parseXmlStream.js.map +1 -0
- package/commonjs/xml/parseXmlStream.sax.js +109 -0
- package/commonjs/xml/parseXmlStream.sax.js.map +1 -0
- package/commonjs/xml/parseXmlStream.saxen.code.js +953 -0
- package/commonjs/xml/parseXmlStream.saxen.code.js.map +1 -0
- package/commonjs/xml/parseXmlStream.saxen.js +85 -0
- package/commonjs/xml/parseXmlStream.saxen.js.map +1 -0
- package/commonjs/xml/xlsx.js +75 -40
- package/commonjs/xml/xlsx.js.map +1 -1
- package/commonjs/zip/unzipFromArrayBuffer.js +5 -14
- package/commonjs/zip/unzipFromArrayBuffer.js.map +1 -1
- package/commonjs/zip/unzipFromStream.fflate.js +154 -25
- package/commonjs/zip/unzipFromStream.fflate.js.map +1 -1
- package/commonjs/zip/unzipFromStream.js.map +1 -1
- package/commonjs/zip/unzipFromStream.unzipper.js +37 -26
- package/commonjs/zip/unzipFromStream.unzipper.js.map +1 -1
- package/modules/export/convertValuesFromUint8ArraysToStrings.js +2 -0
- package/modules/export/convertValuesFromUint8ArraysToStrings.js.map +1 -1
- package/modules/export/parseSheet.js +12 -9
- package/modules/export/parseSheet.js.map +1 -1
- package/modules/export/readSheetBrowser.js +5 -2
- package/modules/export/readSheetBrowser.js.map +1 -1
- package/modules/export/readSheetNode.js +5 -2
- package/modules/export/readSheetNode.js.map +1 -1
- package/modules/export/readSheetUniversal.js +14 -2
- package/modules/export/readSheetUniversal.js.map +1 -1
- package/modules/export/readSheetWebWorker.js +12 -2
- package/modules/export/readSheetWebWorker.js.map +1 -1
- package/modules/export/readXlsxFileBrowser.js +5 -2
- package/modules/export/readXlsxFileBrowser.js.map +1 -1
- package/modules/export/readXlsxFileNode.js +5 -2
- package/modules/export/readXlsxFileNode.js.map +1 -1
- package/modules/export/readXlsxFileUniversal.js +14 -2
- package/modules/export/readXlsxFileUniversal.js.map +1 -1
- package/modules/export/readXlsxFileWebWorker.js +12 -2
- package/modules/export/readXlsxFileWebWorker.js.map +1 -1
- package/modules/export/unpackXlsxFileBrowser.js +26 -6
- package/modules/export/unpackXlsxFileBrowser.js.map +1 -1
- package/modules/export/unpackXlsxFileNode.js +3 -0
- package/modules/export/unpackXlsxFileNode.js.map +1 -1
- package/modules/export/unpackXlsxFileUniversal.js +3 -0
- package/modules/export/unpackXlsxFileUniversal.js.map +1 -1
- package/modules/export/unpackXlsxFileWebWorker.js +6 -0
- package/modules/export/unpackXlsxFileWebWorker.js.map +1 -0
- package/modules/parseSheetData/parseSheetData.js +4 -4
- package/modules/parseSheetData/parseSheetData.js.map +1 -1
- package/modules/utility/checkpoint.js +25 -0
- package/modules/utility/checkpoint.js.map +1 -0
- package/modules/utility/isObject.js +9 -0
- package/modules/utility/isObject.js.map +1 -0
- package/modules/utility/isPromise.js +12 -0
- package/modules/utility/isPromise.js.map +1 -0
- package/modules/xlsx/convertCellsToData2dArray.js +0 -3
- package/modules/xlsx/convertCellsToData2dArray.js.map +1 -1
- package/modules/xlsx/isDateFormatStyle.js +2 -2
- package/modules/xlsx/isDateFormatStyle.js.map +1 -1
- package/modules/xlsx/parseCell.js +85 -24
- package/modules/xlsx/parseCell.js.map +1 -1
- package/{commonjs/xlsx/parseCellCoordinates.js → modules/xlsx/parseCellAddress.js} +12 -13
- package/modules/xlsx/parseCellAddress.js.map +1 -0
- package/modules/xlsx/parseCellValue.js +7 -23
- package/modules/xlsx/parseCellValue.js.map +1 -1
- package/modules/xlsx/parseFilePaths.js +31 -33
- package/modules/xlsx/parseFilePaths.js.map +1 -1
- package/modules/xlsx/parseNumber.js +14 -0
- package/modules/xlsx/parseNumber.js.map +1 -0
- package/modules/xlsx/parseSharedString.js +55 -0
- package/modules/xlsx/parseSharedString.js.map +1 -0
- package/modules/xlsx/parseSharedStrings.js +46 -5
- package/modules/xlsx/parseSharedStrings.js.map +1 -1
- package/modules/xlsx/parseSheet.js +91 -9
- package/modules/xlsx/parseSheet.js.map +1 -1
- package/modules/xlsx/parseSheetData.js +55 -0
- package/modules/xlsx/parseSheetData.js.map +1 -0
- package/modules/xlsx/parseSpreadsheetContents.js +242 -43
- package/modules/xlsx/parseSpreadsheetContents.js.map +1 -1
- package/modules/xlsx/parseSpreadsheetInfo.js +67 -37
- package/modules/xlsx/parseSpreadsheetInfo.js.map +1 -1
- package/modules/xlsx/parseStyles.js +88 -36
- package/modules/xlsx/parseStyles.js.map +1 -1
- package/modules/xml/dom.js +2 -1
- package/modules/xml/dom.js.map +1 -1
- package/modules/xml/parseXmlStream.js +18 -0
- package/modules/xml/parseXmlStream.js.map +1 -0
- package/modules/xml/parseXmlStream.sax.js +103 -0
- package/modules/xml/parseXmlStream.sax.js.map +1 -0
- package/modules/xml/parseXmlStream.saxen.code.js +947 -0
- package/modules/xml/parseXmlStream.saxen.code.js.map +1 -0
- package/modules/xml/parseXmlStream.saxen.js +79 -0
- package/modules/xml/parseXmlStream.saxen.js.map +1 -0
- package/modules/xml/xlsx.js +72 -36
- package/modules/xml/xlsx.js.map +1 -1
- package/modules/zip/unzipFromArrayBuffer.js +5 -14
- package/modules/zip/unzipFromArrayBuffer.js.map +1 -1
- package/modules/zip/unzipFromStream.fflate.js +157 -24
- package/modules/zip/unzipFromStream.fflate.js.map +1 -1
- package/modules/zip/unzipFromStream.js +56 -2
- package/modules/zip/unzipFromStream.js.map +1 -1
- package/modules/zip/unzipFromStream.unzipper.js +38 -26
- package/modules/zip/unzipFromStream.unzipper.js.map +1 -1
- package/package.json +4 -6
- package/commonjs/xlsx/parseCellCoordinates.js.map +0 -1
- package/commonjs/xlsx/parseCells.js +0 -34
- package/commonjs/xlsx/parseCells.js.map +0 -1
- package/commonjs/xlsx/parseSheetDimensions.js +0 -43
- package/commonjs/xlsx/parseSheetDimensions.js.map +0 -1
- package/commonjs/xml/xml.js +0 -13
- package/commonjs/xml/xml.js.map +0 -1
- package/commonjs/xml/xmlBrowser.js +0 -17
- package/commonjs/xml/xmlBrowser.js.map +0 -1
- package/commonjs/xml/xpath/xlsx-xpath.js +0 -92
- package/commonjs/xml/xpath/xlsx-xpath.js.map +0 -1
- package/commonjs/xml/xpath/xpathBrowser.js +0 -33
- package/commonjs/xml/xpath/xpathBrowser.js.map +0 -1
- package/commonjs/xml/xpath/xpathNode.js +0 -16
- package/commonjs/xml/xpath/xpathNode.js.map +0 -1
- package/modules/xlsx/parseCellCoordinates.js.map +0 -1
- package/modules/xlsx/parseCells.js +0 -27
- package/modules/xlsx/parseCells.js.map +0 -1
- package/modules/xlsx/parseSheetDimensions.js +0 -37
- package/modules/xlsx/parseSheetDimensions.js.map +0 -1
- package/modules/xml/xml.js +0 -7
- package/modules/xml/xml.js.map +0 -1
- package/modules/xml/xmlBrowser.js +0 -11
- package/modules/xml/xmlBrowser.js.map +0 -1
- package/modules/xml/xpath/xlsx-xpath.js +0 -73
- package/modules/xml/xpath/xlsx-xpath.js.map +0 -1
- package/modules/xml/xpath/xpathBrowser.js +0 -27
- package/modules/xml/xpath/xpathBrowser.js.map +0 -1
- package/modules/xml/xpath/xpathNode.js +0 -9
- package/modules/xml/xpath/xpathNode.js.map +0 -1
package/.gitlab-ci.yml
CHANGED
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
[](https://www.npmjs.com/package/read-excel-file)
|
|
2
|
+
[](https://www.npmjs.com/package/read-excel-file)
|
|
3
|
+
|
|
4
|
+
# read-excel-file
|
|
2
5
|
|
|
3
6
|
Read `.xlsx` files in a browser or Node.js.
|
|
4
7
|
|
|
@@ -176,7 +179,7 @@ This package provides a separate `import` path for each different environment, a
|
|
|
176
179
|
|
|
177
180
|
It can read from a [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File), a [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) or an [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer).
|
|
178
181
|
|
|
179
|
-
Example:
|
|
182
|
+
Example 1: Read from a selected file.
|
|
180
183
|
|
|
181
184
|
```html
|
|
182
185
|
<input type="file" id="input" />
|
|
@@ -188,99 +191,165 @@ import { readSheet } from 'read-excel-file/browser'
|
|
|
188
191
|
const input = document.getElementById('input')
|
|
189
192
|
|
|
190
193
|
input.addEventListener('change', () => {
|
|
191
|
-
const data = await readSheet(
|
|
194
|
+
const data = await readSheet(event.target.files[0])
|
|
192
195
|
})
|
|
193
196
|
```
|
|
194
197
|
|
|
195
|
-
Note: Internet Explorer 11 is an old browser that doesn't support [`Promise`](https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Promise), and hence requires a [polyfill](https://www.npmjs.com/package/promise-polyfill).
|
|
196
|
-
|
|
197
|
-
<details>
|
|
198
|
-
<summary>Example 2: Reading from a URL</summary>
|
|
198
|
+
<!-- Note: Internet Explorer 11 is an old browser that doesn't support [`Promise`](https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Promise), and hence requires a [polyfill](https://www.npmjs.com/package/promise-polyfill). -->
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
Example 2: Read from a URL.
|
|
201
201
|
|
|
202
202
|
```js
|
|
203
|
+
import { readSheet } from 'read-excel-file/browser'
|
|
204
|
+
|
|
203
205
|
const response = await fetch('https://example.com/spreadsheet.xlsx')
|
|
204
|
-
const
|
|
206
|
+
const blob = await response.blob()
|
|
205
207
|
const data = await readSheet(blob)
|
|
206
208
|
```
|
|
207
|
-
</details>
|
|
208
209
|
|
|
210
|
+
<!--
|
|
209
211
|
<details>
|
|
210
212
|
<summary>Example 3: Using <code>read-excel-file</code> in a Web Worker</summary>
|
|
211
213
|
|
|
212
214
|
######
|
|
213
215
|
|
|
214
|
-
|
|
216
|
+
`read-excel-file` already uses [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) internally when reading `.xlsx` file contents. This is in order to avoid freezing the UI when reading large files. So using an additional Web Worker on top of that isn't really necessary. But for those who still prefer to manually run `read-excel-file` in their own Web Worker, there's `read-excel-file/web-worker` import path which is same as `read-excel-file/browser` except that it doesn't spawn any Web Workers.
|
|
217
|
+
</details>
|
|
218
|
+
-->
|
|
219
|
+
|
|
220
|
+
### Node.js
|
|
221
|
+
|
|
222
|
+
`read-excel-file/node`
|
|
223
|
+
|
|
224
|
+
It can read from a file path, a [`Stream`](https://nodejs.org/api/stream.html), a [`Buffer`](https://nodejs.org/api/buffer.html) or a [`Blob`](https://developer.mozilla.org/docs/Web/API/Blob).
|
|
225
|
+
|
|
226
|
+
Example 1: Read from a file path.
|
|
215
227
|
|
|
216
228
|
```js
|
|
217
|
-
|
|
229
|
+
import { readSheet } from 'read-excel-file/node'
|
|
230
|
+
|
|
231
|
+
const data = await readSheet('/path/to/file')
|
|
232
|
+
```
|
|
218
233
|
|
|
219
|
-
|
|
234
|
+
Example 2: Read from a [`Stream`](https://nodejs.org/api/stream.html)
|
|
220
235
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
236
|
+
```js
|
|
237
|
+
import { readSheet } from 'read-excel-file/node'
|
|
238
|
+
|
|
239
|
+
const data = await readSheet(fs.createReadStream('/path/to/file'))
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Universal
|
|
243
|
+
|
|
244
|
+
`read-excel-file/universal`
|
|
245
|
+
|
|
246
|
+
This one works both in a web browser and Node.js. It can only read from a [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) or an [`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), which could be a bit less convenient for general use.
|
|
247
|
+
|
|
248
|
+
```js
|
|
249
|
+
import { readSheet } from 'read-excel-file/universal'
|
|
250
|
+
|
|
251
|
+
const data = await readSheet(blob)
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Note: the `/universal` export can't use [workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) so it's inherently "single-threaded" and "blocking".
|
|
255
|
+
|
|
256
|
+
## Worker
|
|
257
|
+
|
|
258
|
+
<!-- XML parser currently doesn't use "workers" and hence it "blocks" the main thread. -->
|
|
259
|
+
|
|
260
|
+
<!-- Previous inaccurate statement: All exports of `read-excel-file` already use a [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) under the hood when reading `.xlsx` file contents. This is in order to avoid freezing the UI when reading large files. So using an additional Web Worker on top of that isn't really necessary. Still, for those who require it, this example shows how a user chooses a file and the web application reads it in a [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) using `read-excel-file/web-worker` import path. -->
|
|
261
|
+
|
|
262
|
+
When reading extremely large `.xlsx` files — say, starting from a [few megabytes](#performance) in size — there's a slight inconvenience of freezing the application during the "XML parsing" phase or "[schema parsing](#schema)" phase while reading the file.
|
|
263
|
+
|
|
264
|
+
To work around this minor issue in a web browser, one could read `.xlsx` files in a separate [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) using `read-excel-file/web-worker` export.
|
|
265
|
+
|
|
266
|
+
<details>
|
|
267
|
+
<summary>Example: Read a file using <code>read-excel-file/web-worker</code> in a Web Worker in a browser.</summary>
|
|
268
|
+
|
|
269
|
+
######
|
|
270
|
+
|
|
271
|
+
```js
|
|
272
|
+
const worker = new Worker(new URL('worker.js', import.meta.url))
|
|
225
273
|
|
|
226
|
-
worker.
|
|
227
|
-
|
|
274
|
+
worker.onmessage = (event) => {
|
|
275
|
+
// File has been read.
|
|
276
|
+
console.log('Sheet data', event.data)
|
|
228
277
|
}
|
|
229
278
|
|
|
230
|
-
|
|
279
|
+
worker.onerror = (event) => {
|
|
280
|
+
// Handle errors here.
|
|
281
|
+
console.error(event.error)
|
|
282
|
+
}
|
|
231
283
|
|
|
284
|
+
// "Choose file" button.
|
|
232
285
|
const input = document.getElementById('input')
|
|
233
286
|
|
|
234
|
-
|
|
235
|
-
|
|
287
|
+
// When user chooses a file, send it to the Web Worker.
|
|
288
|
+
input.addEventListener('change', async () => {
|
|
289
|
+
const file = await event.target.files[0].arrayBuffer()
|
|
290
|
+
// Send the `.xlsx` file to the worker.
|
|
291
|
+
// (advanced) One could also pass `transferList` argument here.
|
|
292
|
+
worker.postMessage(file)
|
|
236
293
|
})
|
|
237
294
|
```
|
|
238
295
|
|
|
239
|
-
#####
|
|
296
|
+
##### `./worker.js`
|
|
240
297
|
|
|
241
298
|
```js
|
|
242
299
|
import { readSheet } from 'read-excel-file/web-worker'
|
|
243
300
|
|
|
244
|
-
onmessage = async
|
|
245
|
-
|
|
246
|
-
postMessage(sheetData)
|
|
301
|
+
onmessage = async (event) => {
|
|
302
|
+
postMessage(await readSheet(event.data))
|
|
247
303
|
}
|
|
248
304
|
```
|
|
249
305
|
</details>
|
|
250
306
|
|
|
251
|
-
|
|
307
|
+
<!--
|
|
308
|
+
######
|
|
252
309
|
|
|
253
|
-
|
|
310
|
+
In Node.js, a very similar API called [Worker Threads](https://nodejs.org/api/worker_threads.html) could be used to prevent "blocking" of the main thread while reading a huge file.
|
|
254
311
|
|
|
255
|
-
|
|
312
|
+
<details>
|
|
313
|
+
<summary>Example: Read a file using <code>read-excel-file/node</code> in a Worker Thread in Node.js.</summary>
|
|
256
314
|
|
|
257
|
-
|
|
315
|
+
######
|
|
258
316
|
|
|
259
317
|
```js
|
|
260
|
-
import {
|
|
261
|
-
|
|
262
|
-
const data = await readSheet('/path/to/file')
|
|
263
|
-
```
|
|
318
|
+
import { Worker } from 'node:worker_threads'
|
|
264
319
|
|
|
265
|
-
|
|
320
|
+
const worker = new Worker(new URL('worker.js', import.meta.url))
|
|
266
321
|
|
|
267
|
-
|
|
268
|
-
|
|
322
|
+
worker.on('message', (sheetData) => {
|
|
323
|
+
// File has been read.
|
|
324
|
+
console.log('Sheet data', sheetData)
|
|
325
|
+
})
|
|
269
326
|
|
|
270
|
-
|
|
271
|
-
|
|
327
|
+
worker.on('error', (error) => {
|
|
328
|
+
// Handle errors here.
|
|
329
|
+
console.error(error)
|
|
330
|
+
})
|
|
272
331
|
|
|
273
|
-
|
|
332
|
+
// The server receives an `.xlsx` file.
|
|
333
|
+
const file = fs.readFileSync('./spreadsheet.xlsx')
|
|
274
334
|
|
|
275
|
-
`
|
|
335
|
+
// Send the `.xlsx` file to the worker.
|
|
336
|
+
// (advanced) One could also pass `transferList` argument here.
|
|
337
|
+
worker.postMessage(file)
|
|
338
|
+
```
|
|
276
339
|
|
|
277
|
-
|
|
340
|
+
##### `./worker.js`
|
|
278
341
|
|
|
279
342
|
```js
|
|
280
|
-
import {
|
|
343
|
+
import { parentPort } from 'node:worker_threads'
|
|
281
344
|
|
|
282
|
-
|
|
345
|
+
import { readSheet } from 'read-excel-file/node'
|
|
346
|
+
|
|
347
|
+
parentPort.on('message', async (file) => {
|
|
348
|
+
parentPort.postMessage(await readSheet(file))
|
|
349
|
+
})
|
|
283
350
|
```
|
|
351
|
+
</details>
|
|
352
|
+
-->
|
|
284
353
|
|
|
285
354
|
## Strings
|
|
286
355
|
|
|
@@ -322,11 +391,25 @@ This package doesn't support reading cells that use formulas to calculate the va
|
|
|
322
391
|
|
|
323
392
|
Here're the results of reading [sample `.xlsx` files](https://examplefile.com/document/xlsx) of different size:
|
|
324
393
|
|
|
325
|
-
|File Size| Browser
|
|
326
|
-
|
|
327
|
-
| 1 MB | 0.
|
|
328
|
-
| 10 MB |
|
|
329
|
-
| 50 MB |
|
|
394
|
+
|File Size| Browser | Node.js |
|
|
395
|
+
|---------|----------|----------|
|
|
396
|
+
| 1 MB | 0.1 sec. | 0.1 sec. |
|
|
397
|
+
| 10 MB | 0.5 sec. | 0.6 sec. |
|
|
398
|
+
| 50 MB | 2.6 sec. | 3.0 sec. |
|
|
399
|
+
|
|
400
|
+
To run the benchmark in Node.js, clone the repository, download the sample `.xlsx` files to `./test/benchmark` folder, run `npm install` and then `npm run test:benchmark`.
|
|
401
|
+
|
|
402
|
+
To run the benchmark in a web browser, open the demo page, open the console and choose an `.xlsx` file.
|
|
403
|
+
|
|
404
|
+
#### Under the Hood
|
|
405
|
+
|
|
406
|
+
How it works is it first unzips an `.xlsx` file into a tree of `.xml` files and then parses those `.xml` files into spreadsheet data.
|
|
407
|
+
|
|
408
|
+
The unzipping part is "asynchronous" in Node.js and conditionally "asychronous" in web browsers (i.e. it is "asynchronous" only for `.xlsx` files larger than `512 KB`).
|
|
409
|
+
|
|
410
|
+
The XML parsing part is "synchronous" and is written using a [SAX parser](https://en.wikipedia.org/wiki/Simple_API_for_XML).
|
|
411
|
+
|
|
412
|
+
If `schema` parameter was passed, it will perform an additional last step of parsing sheet data using a schema. This part is "synchronous", and could be performed separately using `parseSheetData()` function.
|
|
330
413
|
|
|
331
414
|
## Schema
|
|
332
415
|
|
|
@@ -707,7 +790,7 @@ To include this library directly via a `<script/>` tag on a page, one can use an
|
|
|
707
790
|
<script>
|
|
708
791
|
var input = document.getElementById('input')
|
|
709
792
|
input.addEventListener('change', function() {
|
|
710
|
-
readXlsxFile(
|
|
793
|
+
readXlsxFile(event.target.files[0]).then(function(rows) {
|
|
711
794
|
// `rows` is an array of rows
|
|
712
795
|
// each row being an array of cells.
|
|
713
796
|
})
|
|
@@ -715,6 +798,26 @@ To include this library directly via a `<script/>` tag on a page, one can use an
|
|
|
715
798
|
</script>
|
|
716
799
|
```
|
|
717
800
|
|
|
801
|
+
<!--
|
|
802
|
+
## Possible Enhancements
|
|
803
|
+
|
|
804
|
+
### Streaming Decompression
|
|
805
|
+
|
|
806
|
+
Currently, it reads and unpacks an `.xlsx` file archive "all at once". But it could also do this in a "streaming" fashion. The existing `unzipFromStream.js` function uses [`unzipper-esm`](https://www.npmjs.com/package/unzipper-esm) package and could easily be refactored to return not just the entire `.xlsx` archive contents but instead an `objectMode: true` readable stream of `file` entries, each `file` entry itself being a readable stream of decompressed data. And, considering that the `sheet.xml` parser is already written in a "streaming" fashion, it could synergize well with such "sreaming" decompression. But how much beneficial could it be? I guess, not much. The reason is that `.xlsx` files aren't that huge, and fitting an `.xlsx` file in memory isn't that big of a deal, considering that the parsed data from that `.xlsx` file would occupy an order of magnitude more RAM. So the effect of such change would be minimal, if not negligible.
|
|
807
|
+
|
|
808
|
+
Still, if someone decides to flex their intellectual muscle and toy with implementing "streaming" decompression, an `.xlsx` file would have to be read in 3 passes: first read the file paths from `xl/_rels/workbook.xml.rels`, then read "shared strings" and "styles", then read the individual sheet data files. But again, if the file input is a readable stream, it could only be read once, after which it closes. So this type of a "chicken and an egg" dilemma introduced by `.xlsx` file structure specification really makes it cumbersome to parse an `.xlsx` file in a "streaming" fashion rather than "all at once". Specifically, the input argument would have to be passed in the form of a "create readable stream" function rather than just a "readable stream" in order for "streaming" mode to be enabled.
|
|
809
|
+
|
|
810
|
+
Reading the `.xml` files is implemented in mixed fashion: `sharedStrings.xml` and `sheet{id}.xml` are read in a "streaming" fashion (because those're the largest ones) while other `.xml` files are read in non-"streaming" fashion (for better code readability).
|
|
811
|
+
|
|
812
|
+
Finally, one could go even further with the "streaming" approach and output not just `Sheet[]` array but an `objectMode: true` stream of `Sheet` objects, the `data` property of each `Sheet` being not just `SheetData = Row[]` but an `objectMode: true` stream of `Row`s.
|
|
813
|
+
-->
|
|
814
|
+
|
|
815
|
+
## Dependencies
|
|
816
|
+
|
|
817
|
+
* [`fflate`](https://www.npmjs.com/package/fflate) — Unzips `.zip` archives in web browsers.
|
|
818
|
+
* [`unzipper-esm`](https://www.npmjs.com/package/unzipper-esm) — Unzips `.zip` archives in Node.js using `stream` API.
|
|
819
|
+
* [`saxen`](https://www.npmjs.com/package/saxen) — Parses XML in a streaming fashion.
|
|
820
|
+
|
|
718
821
|
## GitHub
|
|
719
822
|
|
|
720
823
|
On March 9th, 2020, GitHub, Inc. silently [banned](https://medium.com/@catamphetamine/how-github-blocked-me-and-all-my-libraries-c32c61f061d3) my account (erasing all my repos, issues and comments, even in my employer's private repos) without any notice or explanation. Because of that, all source codes had to be promptly moved to GitLab. The [GitHub repo](https://github.com/catamphetamine/read-excel-file) is now only used as a backup (you can star the repo there too), and the primary repo is now the [GitLab one](https://gitlab.com/catamphetamine/read-excel-file). Issues can be reported in any repo.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).readXlsxFile=e()}(this,(function(){"use strict";var r={createDocument:function(r){return(new DOMParser).parseFromString(r.trim(),"text/xml")}},e={},t=Uint8Array,n=Uint16Array,o=Int32Array,i=new t([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),a=new t([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),u=new t([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),f=function(r,e){for(var t=new n(31),i=0;i<31;++i)t[i]=e+=1<<r[i-1];var a=new o(t[30]);for(i=1;i<30;++i)for(var u=t[i];u<t[i+1];++u)a[u]=u-t[i]<<5|i;return{b:t,r:a}},l=f(i,2),c=l.b,s=l.r;c[28]=258,s[258]=28;for(var m=f(a,0).b,d=new n(32768),v=0;v<32768;++v){var h=(43690&v)>>1|(21845&v)<<1;h=(61680&(h=(52428&h)>>2|(13107&h)<<2))>>4|(3855&h)<<4,d[v]=((65280&h)>>8|(255&h)<<8)>>1}var y=function(r,e,t){for(var o=r.length,i=0,a=new n(e);i<o;++i)r[i]&&++a[r[i]-1];var u,f=new n(e);for(i=1;i<e;++i)f[i]=f[i-1]+a[i-1]<<1;if(t){u=new n(1<<e);var l=15-e;for(i=0;i<o;++i)if(r[i])for(var c=i<<4|r[i],s=e-r[i],m=f[r[i]-1]++<<s,v=m|(1<<s)-1;m<=v;++m)u[d[m]>>l]=c}else for(u=new n(o),i=0;i<o;++i)r[i]&&(u[i]=d[f[r[i]-1]++]>>15-r[i]);return u},b=new t(288);for(v=0;v<144;++v)b[v]=8;for(v=144;v<256;++v)b[v]=9;for(v=256;v<280;++v)b[v]=7;for(v=280;v<288;++v)b[v]=8;var p=new t(32);for(v=0;v<32;++v)p[v]=5;var g=y(b,9,1),w=y(p,5,1),A=function(r){for(var e=r[0],t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},S=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(7&e)&t},O=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(7&e)},x=function(r){return(r+7)/8|0},I=function(r,e,n){return(null==e||e<0)&&(e=0),(null==n||n>r.length)&&(n=r.length),new t(r.subarray(e,n))},j=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],E=function(r,e,t){var n=new Error(e||j[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,E),!t)throw n;return n},k=function(r,e,n,o){var f=r.length,l=o?o.length:0;if(!f||e.f&&!e.l)return n||new t(0);var s=!n,d=s||2!=e.i,v=e.i;s&&(n=new t(3*f));var h=function(r){var e=n.length;if(r>e){var o=new t(Math.max(2*e,r));o.set(n),n=o}},b=e.f||0,p=e.p||0,j=e.b||0,k=e.l,T=e.d,N=e.m,C=e.n,D=8*f;do{if(!k){b=S(r,p,1);var M=S(r,p+1,3);if(p+=3,!M){var F=r[(G=x(p)+4)-4]|r[G-3]<<8,U=G+F;if(U>f){v&&E(0);break}d&&h(j+F),n.set(r.subarray(G,U),j),e.b=j+=F,e.p=p=8*U,e.f=b;continue}if(1==M)k=g,T=w,N=9,C=5;else if(2==M){var P=S(r,p,31)+257,$=S(r,p+10,15)+4,z=P+S(r,p+5,31)+1;p+=14;for(var L=new t(z),R=new t(19),X=0;X<$;++X)R[u[X]]=S(r,p+3*X,7);p+=3*$;var B=A(R),V=(1<<B)-1,W=y(R,B,1);for(X=0;X<z;){var G,_=W[S(r,p,V)];if(p+=15&_,(G=_>>4)<16)L[X++]=G;else{var q=0,H=0;for(16==G?(H=3+S(r,p,3),p+=2,q=L[X-1]):17==G?(H=3+S(r,p,7),p+=3):18==G&&(H=11+S(r,p,127),p+=7);H--;)L[X++]=q}}var J=L.subarray(0,P),K=L.subarray(P);N=A(J),C=A(K),k=y(J,N,1),T=y(K,C,1)}else E(1);if(p>D){v&&E(0);break}}d&&h(j+131072);for(var Q=(1<<N)-1,Y=(1<<C)-1,Z=p;;Z=p){var rr=(q=k[O(r,p)&Q])>>4;if((p+=15&q)>D){v&&E(0);break}if(q||E(2),rr<256)n[j++]=rr;else{if(256==rr){Z=p,k=null;break}var er=rr-254;if(rr>264){var tr=i[X=rr-257];er=S(r,p,(1<<tr)-1)+c[X],p+=tr}var nr=T[O(r,p)&Y],or=nr>>4;nr||E(3),p+=15&nr;K=m[or];if(or>3){tr=a[or];K+=O(r,p)&(1<<tr)-1,p+=tr}if(p>D){v&&E(0);break}d&&h(j+131072);var ir=j+er;if(j<K){var ar=l-K,ur=Math.min(K,ir);for(ar+j<0&&E(3);j<ur;++j)n[j]=o[ar+j]}for(;j<ir;++j)n[j]=n[j-K]}}e.l=k,e.p=Z,e.b=j,e.f=b,k&&(b=1,e.m=N,e.d=T,e.n=C)}while(!b);return j!=n.length&&s?I(n,0,j):n.subarray(0,j)},T=new t(0),N=function(r,e,t){for(var n=r(),o=r.toString(),i=o.slice(o.indexOf("[")+1,o.lastIndexOf("]")).replace(/\s+/g,"").split(","),a=0;a<n.length;++a){var u=n[a],f=i[a];if("function"==typeof u){e+=";"+f+"=";var l=u.toString();if(u.prototype)if(-1!=l.indexOf("[native code]")){var c=l.indexOf(" ",8)+1;e+=l.slice(c,l.indexOf("(",c))}else for(var s in e+=l,u.prototype)e+=";"+f+".prototype."+s+"="+u.prototype[s].toString();else e+=l}else t[f]=u}return e},C=[],D=function(r,t,n,o){if(!C[n]){for(var i="",a={},u=r.length-1,f=0;f<u;++f)i=N(r[f],i,a);C[n]={c:N(r[u],i,a),e:a}}var l=function(r,e){var t={};for(var n in r)t[n]=r[n];for(var n in e)t[n]=e[n];return t}({},C[n].e);return function(r,t,n,o,i){var a=new Worker(e[t]||(e[t]=URL.createObjectURL(new Blob([r+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return a.onmessage=function(r){var e=r.data,t=e.$e$;if(t){var n=new Error(t[0]);n.code=t[1],n.stack=t[2],i(n,null)}else i(null,e)},a.postMessage(n,o),a}(C[n].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",n,l,function(r){var e=[];for(var t in r)r[t].buffer&&e.push((r[t]=new r[t].constructor(r[t])).buffer);return e}(l),o)},M=function(){return[t,n,o,i,a,u,c,m,g,w,d,j,y,A,S,O,x,I,E,k,R,F,U]},F=function(r){return postMessage(r,[r.buffer])},U=function(r){return r&&{out:r.size&&new t(r.size),dictionary:r.dictionary}},P=function(r,e,t,n,o,i){var a=D(t,n,o,(function(r,e){a.terminate(),i(r,e)}));return a.postMessage([r,e],e.consume?[r.buffer]:[]),function(){a.terminate()}},$=function(r,e){return r[e]|r[e+1]<<8},z=function(r,e){return(r[e]|r[e+1]<<8|r[e+2]<<16|r[e+3]<<24)>>>0},L=function(r,e){return z(r,e)+4294967296*z(r,e+4)};function R(r,e){return k(r,{i:2},e&&e.out,e&&e.dictionary)}var X="undefined"!=typeof TextDecoder&&new TextDecoder;try{X.decode(T,{stream:!0}),1}catch(r){}var B=function(r){for(var e="",t=0;;){var n=r[t++],o=(n>127)+(n>223)+(n>239);if(t+o>r.length)return{s:e,r:I(r,t-1)};o?3==o?(n=((15&n)<<18|(63&r[t++])<<12|(63&r[t++])<<6|63&r[t++])-65536,e+=String.fromCharCode(55296|n>>10,56320|1023&n)):e+=1&o?String.fromCharCode((31&n)<<6|63&r[t++]):String.fromCharCode((15&n)<<12|(63&r[t++])<<6|63&r[t++]):e+=String.fromCharCode(n)}};function V(r,e){if(e){for(var t="",n=0;n<r.length;n+=16384)t+=String.fromCharCode.apply(null,r.subarray(n,n+16384));return t}if(X)return X.decode(r);var o=B(r),i=o.s;return(t=o.r).length&&E(8),i}var W=function(r,e){return e+30+$(r,e+26)+$(r,e+28)},G=function(r,e,t){var n=$(r,e+28),o=$(r,e+30),i=V(r.subarray(e+46,e+46+n),!(2048&$(r,e+8))),a=e+46+n,u=_(r,a,o,t,z(r,e+20),z(r,e+24),z(r,e+42)),f=u[0],l=u[1],c=u[2];return[$(r,e+10),f,l,i,a+o+$(r,e+32),c]},_=function(r,e,t,n,o,i,a){var u=4294967295==o,f=4294967295==i,l=4294967295==a,c=e+t;if(n&&u+f+l){for(;e+4<c;e+=4+$(r,e+2))if(1==$(r,e))return[u?L(r,e+4+8*f):o,f?L(r,e+4):i,l?L(r,e+4+8*(f+u)):a,1];n<2&&E(13)}return[o,i,a,0]},q="function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout?setTimeout:function(r){r()};function H(r,e,n){n||(n=e,e={}),"function"!=typeof n&&E(7);var o=[],i=function(){for(var r=0;r<o.length;++r)o[r]()},a={},u=function(r,e){q((function(){n(r,e)}))};q((function(){u=n}));for(var f=r.length-22;101010256!=z(r,f);--f)if(!f||r.length-f>65558)return u(E(13,0,1),null),i;var l=$(r,f+8);if(l){var c=l,s=z(r,f+16),m=117853008==z(r,f-20);if(m){var d=z(r,f-12);(m=101075792==z(r,d))&&(c=l=z(r,d+32),s=z(r,d+48))}for(var v=e&&e.filter,h=function(e){var n=G(r,s,m),f=n[0],c=n[1],d=n[2],h=n[3],y=n[4],b=n[5],p=W(r,b);s=y;var g=function(r,e){r?(i(),u(r,null)):(e&&(a[h]=e),--l||u(null,a))};if(!v||v({name:h,size:c,originalSize:d,compression:f}))if(f)if(8==f){var w=r.subarray(p,p+c);if(d<524288||c>.8*d)try{g(null,R(w,{out:new t(d)}))}catch(r){g(r,null)}else o.push(function(r,e,t){return t||(t=e,e={}),"function"!=typeof t&&E(7),P(r,e,[M],(function(r){return F(R(r.data[0],U(r.data[1])))}),1,t)}(w,{size:d},g))}else g(E(14,"unknown compression type "+f,1),null);else g(null,I(r,p,p+c));else g(null,null)},y=0;y<c;++y)h()}else u(null,{});return i}function J(r,e){return function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=e.filter,n=arguments.length>2?arguments[2]:void 0;return n(new Uint8Array(r),{filter:function(r){return!t||t({path:r.name})}})}(r,e,K,!0)}function K(r){return new Promise((function(e,t){H(r,(function(r,n){r?t(r):e(n)}))}))}function Q(r){for(var e={},t=0,n=Object.keys(r);t<n.length;t++){var o=n[t];e[o]=V(r[o])}return e}function Y(r){var e=r.path;return e.endsWith(".xml")||e.endsWith(".xml.rels")}function Z(r){return J(r,{filter:Y}).then(Q)}function rr(r,e){for(var t=0;t<r.childNodes.length;){var n=r.childNodes[t];if(1===n.nodeType&&or(n)===e)return n;t++}}function er(r,e){for(var t=[],n=0;n<r.childNodes.length;){var o=r.childNodes[n];1===o.nodeType&&or(o)===e&&t.push(o),n++}return t}function tr(r,e,t){for(var n=0;n<r.childNodes.length;){var o=r.childNodes[n];e?1===o.nodeType&&or(o)===e&&t(o,n):t(o,n),n++}}var nr=/.+\:/;function or(r){return r.tagName.replace(nr,"")}function ir(r){for(var e=0;e<r.childNodes.length;){if(1===r.childNodes[e].nodeType)return r.childNodes[e];e++}}function ar(r){if(1!==r.nodeType)return r.textContent;for(var e="<"+or(r),t=0;t<r.attributes.length;)e+=" "+r.attributes[t].name+'="'+r.attributes[t].value+'"',t++;e+=">";for(var n=0;n<r.childNodes.length;)e+=ar(r.childNodes[n]),n++;return e+="</"+or(r)+">"}function ur(r){var e,t,n=r.documentElement;return e=function(r){var e=rr(r,"t");if(e)return e.textContent;var t="";return tr(r,"r",(function(r){t+=rr(r,"t").textContent})),t},t=[],tr(n,"si",(function(r,n){t.push(e(r,n))})),t}function fr(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=function(r,e){if(!r)return;if("string"==typeof r)return lr(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);"Object"===t&&r.constructor&&(t=r.constructor.name);if("Map"===t||"Set"===t)return Array.from(r);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return lr(r,e)}(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0;return function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function lr(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function cr(r,e){for(var t,n=e.createDocument(r),o=rr(n.documentElement,"workbookPr"),i=Boolean(o)&&"1"===o.getAttribute("date1904"),a=[],u=fr(function(r){return er(rr(r.documentElement,"sheets"),"sheet")}(n));!(t=u()).done;){var f=t.value;f.getAttribute("name")&&a.push({id:f.getAttribute("sheetId"),name:f.getAttribute("name"),relationId:f.getAttribute("r:id")})}return{epoch1904:i,sheets:a}}function sr(r,e){var t=e.createDocument(r),n={sheets:{},sharedStrings:void 0,styles:void 0};return function(r){return er(r.documentElement,"Relationship")}(t).forEach((function(r){var e=r.getAttribute("Target");switch(r.getAttribute("Type")){case"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles":n.styles=mr(e);break;case"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings":n.sharedStrings=mr(e);break;case"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet":n.sheets[r.getAttribute("Id")]=mr(e)}})),n}function mr(r){return"/"===r[0]?r.slice(1):"xl/"+r}function dr(r){return dr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},dr(r)}function vr(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.push.apply(t,n)}return t}function hr(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?vr(Object(t),!0).forEach((function(e){yr(r,e,t[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):vr(Object(t)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))}))}return r}function yr(r,e,t){return(e=function(r){var e=function(r,e){if("object"!==dr(r)||null===r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!==dr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"===dr(e)?e:String(e)}(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function br(r,e){if(!r)return{};var t,n,o=e.createDocument(r),i=(t=o,n=rr(t.documentElement,"cellStyleXfs"),n?er(n,"xf"):[]).map(gr),a=function(r){var e=rr(r.documentElement,"numFmts");return e?er(e,"numFmt"):[]}(o).map(pr).reduce((function(r,e){return r[e.id]=e,r}),[]);return function(r){var e=rr(r.documentElement,"cellXfs");return e?er(e,"xf"):[]}(o).map((function(r){return r.hasAttribute("xfId")?hr(hr({},i[r.xfId]),gr(r,a)):gr(r,a)}))}function pr(r){return{id:r.getAttribute("numFmtId"),template:r.getAttribute("formatCode")}}function gr(r,e){var t={};if(r.hasAttribute("numFmtId")){var n=r.getAttribute("numFmtId");e[n]?t.numberFormat=e[n]:t.numberFormat={id:n}}return t}var wr=17,Ar=1,Sr=1,Or=864e5,xr=365;function Ir(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=function(r,e){if(!r)return;if("string"==typeof r)return jr(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);"Object"===t&&r.constructor&&(t=r.constructor.name);if("Map"===t||"Set"===t)return Array.from(r);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return jr(r,e)}(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0;return function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function jr(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}var Er=/^\[\$-[^\]]+\]/,kr=/;@$/,Tr={};function Nr(r){if(r in Tr)return Tr[r];var e=function(r){r=r.toLowerCase(),r=r.replace(Er,""),r=r.replace(kr,"");var e=r.split(/\W+/);if(e.length<0)return!1;for(var t,n=Ir(e);!(t=n()).done;){var o=t.value;if(Cr.indexOf(o)<0)return!1}return!0}(r);return Tr[r]=e,e}var Cr=["ss","mm","h","hh","am","pm","d","dd","m","mm","mmm","mmmm","yy","yyyy","e"];var Dr=[27,28,29,30,31,32,33,34,35,36,50,51,52,53,54,55,56,57,58],Mr=[27,28,29,30,31,32,33,34,35,36,50,51,52,53,54,55,56,57,58],Fr=[14,15,16,17,18,19,20,21,22,45,46,47].concat(Dr).concat(Mr.filter((function(r){return Dr.indexOf(r)<0}))).concat([71,72,73,74,75,76,77,78,79,80,81].filter((function(r){return Dr.indexOf(r)<0})).filter((function(r){return Mr.indexOf(r)<0})));function Ur(r,e,t){var n=t.getInlineStringValue,o=t.getInlineStringXml,i=t.getStyleId,a=t.styles,u=t.sharedStrings,f=t.epoch1904,l=t.options;switch(e||(e="n"),e){case"str":r=Pr(r,l);break;case"inlineStr":if(void 0===(r=n()))throw new Error('Unsupported "inline string" cell value structure: '.concat(o()));r=Pr(r,l);break;case"s":var c=Number(r);if(isNaN(c))throw new Error('Invalid "shared" string index: '.concat(r));if(c>=u.length)throw new Error('An out-of-bounds "shared" string index: '.concat(r));r=Pr(r=u[c],l);break;case"b":if("1"===r)r=!0;else{if("0"!==r)throw new Error('Unsupported "boolean" cell value: '.concat(r));r=!1}break;case"z":r=void 0;break;case"e":r=function(r){switch(r){case 0:return"#NULL!";case 7:return"#DIV/0!";case 15:return"#VALUE!";case 23:return"#REF!";case 29:return"#NAME?";case 36:return"#NUM!";case 42:return"#N/A";case 43:return"#GETTING_DATA";default:return"#ERROR_".concat(r)}}(r);break;case"d":if(void 0===r)break;var s=new Date(r);if(isNaN(s.valueOf()))throw new Error('Unsupported "date" cell value: '.concat(r));r=s;break;case"n":if(void 0===r)break;var m=i();if(m&&function(r,e,t){if(r){var n=e[r];if(!n)throw new Error("Cell style not found: ".concat(r));if(!n.numberFormat)return!1;if(Fr.indexOf(Number(n.numberFormat.id))>=0||t.dateFormat&&n.numberFormat.template===t.dateFormat||!1!==t.smartDateParser&&n.numberFormat.template&&Nr(n.numberFormat.template))return!0}}(m,a,l))r=function(r,e){e&&e.epoch1904&&(r+=4*xr+Ar+Sr);var t=Ar+Sr+70*xr+wr;return new Date(Math.floor((r-t)*Or))}(r=$r(r),{epoch1904:f});else r=(l.parseNumber||$r)(r);break;default:throw new TypeError("Cell type not supported: ".concat(e))}return void 0===r&&(r=null),r}function Pr(r,e){return!1!==e.trim&&(r=r.trim()),""===r&&(r=void 0),r}function $r(r){var e=Number(r);if(isNaN(e))throw new Error('Invalid "numeric" cell value: '.concat(r));return e}function zr(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,i,a,u=[],f=!0,l=!1;try{if(i=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=i.call(t)).done)&&(u.push(n.value),u.length!==e);f=!0);}catch(r){l=!0,o=r}finally{try{if(!f&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(r,e)||function(r,e){if(!r)return;if("string"==typeof r)return Lr(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);"Object"===t&&r.constructor&&(t=r.constructor.name);if("Map"===t||"Set"===t)return Array.from(r);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Lr(r,e)}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Lr(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function Rr(r){var e=zr(r.split(/(\d+)/),2),t=e[0],n=e[1];return[Number(n),Br(t.trim())]}var Xr=["","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"];function Br(r){for(var e=0,t=0;t<r.length;)e*=26,e+=Xr.indexOf(r[t]),t++;return e}function Vr(r,e,t,n,o,i){var a=Rr(r.getAttribute("r")),u=function(r,e){return rr(e,"v")}(0,r),f=u&&u.textContent,l=r.getAttribute("t");return{row:a[0],column:a[1],value:Ur(f,l,{getInlineStringValue:function(){return function(r,e){var t=ir(e);if(t&&"is"===or(t)){var n=ir(t);if(n&&"t"===or(n))return n.textContent}}(0,r)},getInlineStringXml:function(){return ar(r)},getStyleId:function(){return r.getAttribute("s")},styles:n,sharedStrings:t,epoch1904:o,options:i})}}function Wr(r,e,t,n,o){var i=function(r){var e=rr(r.documentElement,"sheetData"),t=[];return tr(e,"row",(function(r){tr(r,"c",(function(r){t.push(r)}))})),t}(r);return 0===i.length?[]:i.map((function(r){return Vr(r,0,e,t,n,o)}))}function Gr(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,i,a,u=[],f=!0,l=!1;try{if(i=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=i.call(t)).done)&&(u.push(n.value),u.length!==e);f=!0);}catch(r){l=!0,o=r}finally{try{if(!f&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(r,e)||function(r,e){if(!r)return;if("string"==typeof r)return _r(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);"Object"===t&&r.constructor&&(t=r.constructor.name);if("Map"===t||"Set"===t)return Array.from(r);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return _r(r,e)}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _r(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function qr(r){var e=function(r){var e=rr(r.documentElement,"dimension");if(e)return e.getAttribute("ref")}(r);if(e)return 1===(e=e.split(":").map(Rr).map((function(r){var e=Gr(r,2);return{row:e[0],column:e[1]}}))).length&&(e=[e[0],e[0]]),e}function Hr(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=function(r,e){if(!r)return;if("string"==typeof r)return Jr(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);"Object"===t&&r.constructor&&(t=r.constructor.name);if("Map"===t||"Set"===t)return Array.from(r);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Jr(r,e)}(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0;return function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Jr(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function Kr(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=function(r,e){if(!r)return;if("string"==typeof r)return Qr(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);"Object"===t&&r.constructor&&(t=r.constructor.name);if("Map"===t||"Set"===t)return Array.from(r);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Qr(r,e)}(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0;return function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Qr(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function Yr(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,i,a,u=[],f=!0,l=!1;try{if(i=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=i.call(t)).done)&&(u.push(n.value),u.length!==e);f=!0);}catch(r){l=!0,o=r}finally{try{if(!f&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(r,e)||Zr(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Zr(r,e){if(r){if("string"==typeof r)return re(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?re(r,e):void 0}}function re(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function ee(r,e){if(0===r.length)return[];var t=Yr(e,2);t[0];for(var n=t[1],o=n.column,i=n.row,a=new Array(i),u=0;u<i;){a[u]=new Array(o);for(var f=0;f<o;)a[u][f]=null,f++;u++}for(var l,c=function(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=Zr(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0;return function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(r);!(l=c()).done;){var s=l.value,m=s.row-1,d=s.column-1;d<o&&m<i&&(a[m][d]=s.value)}return a=function(r){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=e.rowIndexSourceMap,n=e.accessor,o=void 0===n?function(r){return r}:n,i=e.onlyTrimAtTheEnd,a=r.length-1;a>=0;){for(var u,f=!0,l=Hr(r[a]);!(u=l()).done;)if(null!==o(u.value)){f=!1;break}if(f)r.splice(a,1),t&&t.splice(a,1);else if(i)break;a--}return r}(function(r){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=e.accessor,n=void 0===t?function(r){return r}:t,o=e.onlyTrimAtTheEnd,i=r[0].length-1;i>=0;){for(var a,u=!0,f=Kr(r);!(a=f()).done;)if(null!==n(a.value[i])){u=!1;break}if(u)for(var l=0;l<r.length;)r[l].splice(i,1),l++;else if(o)break;i--}return r}(a,{onlyTrimAtTheEnd:!0}),{onlyTrimAtTheEnd:!0}),a}function te(r,e,t,n,o,i){var a=e.createDocument(r),u=Wr(a,t,n,o,i),f=qr(a)||function(r){var e=function(r,e){return r-e},t=r.map((function(r){return r.row})).sort(e),n=r.map((function(r){return r.column})).sort(e),o=t[0],i=t[t.length-1];return[{row:o,column:n[0]},{row:i,column:n[n.length-1]}]}(u);return ee(u,f)}function ne(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=function(r,e){if(!r)return;if("string"==typeof r)return oe(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);"Object"===t&&r.constructor&&(t=r.constructor.name);if("Map"===t||"Set"===t)return Array.from(r);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return oe(r,e)}(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0;return function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function oe(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function ie(r,e){for(var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=function(e){if(!r[e])throw new Error('"'.concat(e,'" file not found inside the *.xlsx file zip archive'));return r[e]},o=sr(n("xl/_rels/workbook.xml.rels"),e),i=o.sharedStrings?function(r,e){return r?ur(e.createDocument(r)):[]}(n(o.sharedStrings),e):[],a=o.styles?br(n(o.styles),e):{},u=cr(n("xl/workbook.xml"),e),f=u.sheets,l=u.epoch1904,c=t.sheets&&t.sheets.map((function(r){return function(r,e){if("string"==typeof r){for(var t,n=ne(e);!(t=n()).done;){var o=t.value;if(o.name===r)return o.relationId}throw new Error('Sheet "'.concat(r,'" not found. Available sheets: ').concat(e.map((function(r){var e=r.name;return'"'.concat(e,'"')})).join(", ")))}if(r<=e.length)return e[r-1].relationId;throw new Error("Sheet number out of bounds: ".concat(r,". Available sheets count: ").concat(e.length))}(r,f)})),s=[],m=0,d=Object.keys(o.sheets);m<d.length;m++){var v=d[m];c&&!c.includes(v)||s.push({sheet:ae(v,f),data:te(n(o.sheets[v]),e,i,a,l,t)})}return s}function ae(r,e){for(var t,n=ne(e);!(t=n()).done;){var o=t.value;if(o.relationId===r)return o.name}throw new Error("Sheet ID not found: ".concat(r))}return function(e,t){return function(r){return r instanceof File||r instanceof Blob?r.arrayBuffer().then(Z):Promise.resolve(r).then(Z)}(e).then((function(e){return ie(e,r,t)}))}}));
|
|
1
|
+
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).readXlsxFile=e()}(this,(function(){"use strict";var r=String.fromCharCode,e=Object.prototype.hasOwnProperty,t=/&#(\d+);|&#x([0-9a-f]+);|&(\w+);/gi,n={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'};function o(t,o,i,a){return a?e.call(n,a)?n[a]:"&"+a+";":r(o||parseInt(i,16))}function i(r){return r.length>3&&-1!==r.indexOf("&")?r.replace(t,o):r}Object.keys(n).forEach((function(r){n[r.toUpperCase()]=n[r]}));var a="non-whitespace outside of root node";function u(r){return new Error(r)}function f(r){return"missing namespace for prefix <"+r+">"}function l(r){return{get:r,enumerable:!0}}function s(r){var e,t={};for(e in r)t[e]=r[e];return t}function c(r){return r+"$uri"}function d(){return{line:0,column:0}}function m(r){throw r}function b(r){if(!this)return new b(r);var e,t,n,o,h,p,v,y,g,w=r&&r.proxy,S=m,O=d,x=!1,A=!1,j=null,k=!1;function I(r){r instanceof Error||(r=u(r)),j=r,S(r,O)}function E(r){h&&(r instanceof Error||(r=u(r)),h(r,O))}this.on=function(r,i){if("function"!=typeof i)throw u("required args <name, cb>");switch(r){case"openTag":t=i;break;case"text":e=i;break;case"closeTag":n=i;break;case"error":S=i;break;case"warn":h=i;break;case"cdata":o=i;break;case"attention":y=i;break;case"question":v=i;break;case"comment":p=i;break;default:throw u("unsupported event: "+r)}return this},this.ns=function(r){if(void 0===r&&(r={}),"object"!=typeof r)throw u("required args <nsMap={}>");var e,t={};for(e in r)t[e]=r[e];return A=!0,g=t,this},this.parse=function(r){if("string"!=typeof r)throw u("required args <xml=string>");return j=null,function(r){var u,d,m,b,h,S,j,P,T,C,N,D=A?[]:null,F=A?function(r){var e,t,n={};for(e in r)n[t=r[e]]=t,n[c(t)]=e;return n}(g):null,M=[],U=0,X=!1,$=!1,q=0,L=0,R="",_=0;function z(){if(null!==N)return N;var r,e,t,n,o,a,u,l,d,m,b,h=A&&F.xmlns,p=A&&x?[]:null,v=_,y=R,w=y.length,S={},O={};r:for(;v<w;v++)if(d=!1,!(32===(m=y.charCodeAt(v))||m<14&&m>8)){for((m<65||m>122||m>90&&m<97)&&95!==m&&58!==m&&(E("illegal first char attribute name"),d=!0),b=v+1;b<w;b++)if(!((m=y.charCodeAt(b))>96&&m<123||m>64&&m<91||m>47&&m<59||46===m||45===m||95===m)){if(32===m||m<14&&m>8){E("missing attribute value"),v=b;continue r}if(61===m)break;E("illegal attribute name char"),d=!0}if("xmlns:xmlns"===(l=y.substring(v,b))&&(E("illegal declaration of xmlns"),d=!0),34===(m=y.charCodeAt(b+1)))-1===(b=y.indexOf('"',v=b+2))&&-1!==(b=y.indexOf("'",v))&&(E("attribute value quote missmatch"),d=!0);else if(39===m)-1===(b=y.indexOf("'",v=b+2))&&-1!==(b=y.indexOf('"',v))&&(E("attribute value quote missmatch"),d=!0);else for(E("missing attribute value quotes"),d=!0,b+=1;b<w&&!(32===(m=y.charCodeAt(b+1))||m<14&&m>8);b++);for(-1===b&&(E("missing closing quotes"),b=w,d=!0),d||(a=y.substring(v,b)),v=b;b+1<w&&!(32===(m=y.charCodeAt(b+1))||m<14&&m>8);b++)v===b&&(E("illegal character after attribute end"),d=!0);if(v=b+1,!d)if(l in O)E("attribute <"+l+"> already defined");else if(O[l]=!0,A)if(x){if(null!==(o="xmlns"===l?"xmlns":120===l.charCodeAt(0)&&"xmlns:"===l.substr(0,6)?l.substr(6):null)){if(r=i(a),e=c(o),!(u=g[r])){if("xmlns"===o||e in F&&F[e]!==r)do{u="ns"+U++}while(void 0!==F[u]);else u=o;g[r]=u}F[o]!==u&&(n||(F=s(F),n=!0),F[o]=u,"xmlns"===o&&(F[c(u)]=r,h=u),F[e]=r),S[l]=a;continue}p.push(l,a)}else-1!==(m=l.indexOf(":"))?(t=F[l.substring(0,m)])?S[l=h===t?l.substr(m+1):t+l.substr(m)]=a:E(f(l.substring(0,m))):S[l]=a;else S[l]=a}if(x)for(v=0,w=p.length;v<w;v++){if(l=p[v++],a=p[v],-1!==(m=l.indexOf(":"))){if(!(t=F[l.substring(0,m)])){E(f(l.substring(0,m)));continue}l=h===t?l.substr(m+1):t+l.substr(m)}S[l]=a}return N=S}function B(){for(var e,t,n=/(\r\n|\r|\n)/g,o=0,i=0,a=0,u=L;q>=a&&(e=n.exec(r))&&!((u=e[0].length+e.index)>q);)o+=1,a=u;return-1==q?(i=u,t=r.substring(L)):0===L?t=r.substring(L,q):(i=q-a,t=-1==L?r.substring(q):r.substring(q,L+1)),{data:t,line:o,column:i}}O=B,w&&(C=Object.create({},{name:l((function(){return P})),originalName:l((function(){return T})),attrs:l(z),ns:l((function(){return F}))}));for(;-1!==L;){if(-1===(q=60===r.charCodeAt(L)?L:r.indexOf("<",L)))return M.length?I("unexpected end of file"):0===L?I("missing start tag"):void(L<r.length&&r.substring(L).trim()&&E(a));if(L!==q)if(M.length){if(e&&(e(r.substring(L,q),i,O),k))return}else if(r.substring(L,q).trim()&&(E(a),k))return;if(33===(h=r.charCodeAt(q+1))){if(91===(b=r.charCodeAt(q+2))&&"CDATA["===r.substr(q+3,6)){if(-1===(L=r.indexOf("]]>",q)))return I("unclosed cdata");if(o&&(o(r.substring(q+9,L),O),k))return;L+=3;continue}if(45===b&&45===r.charCodeAt(q+3)){if(-1===(L=r.indexOf("--\x3e",q)))return I("unclosed comment");if(p&&(p(r.substring(q+4,L),i,O),k))return;L+=3;continue}}if(63!==h){for(d=q+1;;d++){if(S=r.charCodeAt(d),isNaN(S))return L=-1,I("unclosed tag");if(34===S)d=-1!==(b=r.indexOf('"',d+1))?b:d;else if(39===S)d=-1!==(b=r.indexOf("'",d+1))?b:d;else if(62===S){L=d;break}}if(33!==h){if(N={},47===h){if(X=!1,$=!0,!M.length)return I("missing open tag");if(d=P=M.pop(),b=q+2+d.length,r.substring(q+2,b)!==d)return I("closing tag mismatch");for(;b<L;b++)if(!(32===(h=r.charCodeAt(b))||h>8&&h<14))return I("close tag")}else{if(47===r.charCodeAt(L-1)?(d=P=r.substring(q+1,L-1),X=!0,$=!0):(d=P=r.substring(q+1,L),X=!0,$=!1),!(h>96&&h<123||h>64&&h<91||95===h||58===h))return I("illegal first char nodeName");for(b=1,m=d.length;b<m;b++)if(!((h=d.charCodeAt(b))>96&&h<123||h>64&&h<91||h>47&&h<59||45===h||95===h||46==h)){if(32===h||h<14&&h>8){P=d.substring(0,b),N=null;break}return I("invalid nodeName")}$||M.push(P)}if(A){if(u=F,X&&($||D.push(u),null===N&&(x=-1!==d.indexOf("xmlns",b))&&(_=b,R=d,z(),x=!1)),T=P,-1!==(h=P.indexOf(":"))){if(!(j=F[P.substring(0,h)]))return I("missing namespace on <"+T+">");P=P.substr(h+1)}else j=F.xmlns;j&&(P=j+":"+P)}if(X&&(_=b,R=d,t&&(w?t(C,i,$,O):t(P,z,i,$,O),k)))return;if($){if(n&&(n(w?C:P,i,X,O),k))return;A&&(F=X?u:D.pop())}L+=1}else{if(y&&(y(r.substring(q,L+1),i,O),k))return;L+=1}}else{if(-1===(L=r.indexOf("?>",q)))return I("unclosed question");if(v&&(v(r.substring(q,L+2),O),k))return;L+=2}}}(r),O=d,k=!1,j},this.stop=function(){k=!0}}function h(r,e){var t=e.createInitialState,n=e.onOpenTag,o=e.onCloseTag,i=e.onText,a=/.+:/;function u(r){return r.replace(a,"")}return new Promise((function(e,a){var f=!1,l=t(),s=new b({proxy:!0});s.ns(),s.on("error",(function(r){f||(f=!0,a(r))})),s.on("text",(function(r){i&&i(r,l)})),s.on("openTag",(function(r,e,t,o){n&&n(u(r.originalName),r.attrs,l)})),s.on("closeTag",(function(r){if(o){var e=u(r.originalName);o(e,l)}})),s.parse(r),f||e(l)}))}var p={},v=Uint8Array,y=Uint16Array,g=Int32Array,w=new v([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),S=new v([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),O=new v([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),x=function(r,e){for(var t=new y(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];var o=new g(t[30]);for(n=1;n<30;++n)for(var i=t[n];i<t[n+1];++i)o[i]=i-t[n]<<5|n;return{b:t,r:o}},A=x(w,2),j=A.b,k=A.r;j[28]=258,k[258]=28;for(var I=x(S,0).b,E=new y(32768),P=0;P<32768;++P){var T=(43690&P)>>1|(21845&P)<<1;T=(61680&(T=(52428&T)>>2|(13107&T)<<2))>>4|(3855&T)<<4,E[P]=((65280&T)>>8|(255&T)<<8)>>1}var C=function(r,e,t){for(var n=r.length,o=0,i=new y(e);o<n;++o)r[o]&&++i[r[o]-1];var a,u=new y(e);for(o=1;o<e;++o)u[o]=u[o-1]+i[o-1]<<1;if(t){a=new y(1<<e);var f=15-e;for(o=0;o<n;++o)if(r[o])for(var l=o<<4|r[o],s=e-r[o],c=u[r[o]-1]++<<s,d=c|(1<<s)-1;c<=d;++c)a[E[c]>>f]=l}else for(a=new y(n),o=0;o<n;++o)r[o]&&(a[o]=E[u[r[o]-1]++]>>15-r[o]);return a},N=new v(288);for(P=0;P<144;++P)N[P]=8;for(P=144;P<256;++P)N[P]=9;for(P=256;P<280;++P)N[P]=7;for(P=280;P<288;++P)N[P]=8;var D=new v(32);for(P=0;P<32;++P)D[P]=5;var F=C(N,9,1),M=C(D,5,1),U=function(r){for(var e=r[0],t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},X=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(7&e)&t},$=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(7&e)},q=function(r){return(r+7)/8|0},L=function(r,e,t){return(null==e||e<0)&&(e=0),(null==t||t>r.length)&&(t=r.length),new v(r.subarray(e,t))},R=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],_=function(r,e,t){var n=new Error(e||R[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,_),!t)throw n;return n},z=function(r,e,t,n){var o=r.length,i=n?n.length:0;if(!o||e.f&&!e.l)return t||new v(0);var a=!t,u=a||2!=e.i,f=e.i;a&&(t=new v(3*o));var l=function(r){var e=t.length;if(r>e){var n=new v(Math.max(2*e,r));n.set(t),t=n}},s=e.f||0,c=e.p||0,d=e.b||0,m=e.l,b=e.d,h=e.m,p=e.n,y=8*o;do{if(!m){s=X(r,c,1);var g=X(r,c+1,3);if(c+=3,!g){var x=r[(W=q(c)+4)-4]|r[W-3]<<8,A=W+x;if(A>o){f&&_(0);break}u&&l(d+x),t.set(r.subarray(W,A),d),e.b=d+=x,e.p=c=8*A,e.f=s;continue}if(1==g)m=F,b=M,h=9,p=5;else if(2==g){var k=X(r,c,31)+257,E=X(r,c+10,15)+4,P=k+X(r,c+5,31)+1;c+=14;for(var T=new v(P),N=new v(19),D=0;D<E;++D)N[O[D]]=X(r,c+3*D,7);c+=3*E;var R=U(N),z=(1<<R)-1,B=C(N,R,1);for(D=0;D<P;){var W,G=B[X(r,c,z)];if(c+=15&G,(W=G>>4)<16)T[D++]=W;else{var H=0,J=0;for(16==W?(J=3+X(r,c,3),c+=2,H=T[D-1]):17==W?(J=3+X(r,c,7),c+=3):18==W&&(J=11+X(r,c,127),c+=7);J--;)T[D++]=H}}var K=T.subarray(0,k),V=T.subarray(k);h=U(K),p=U(V),m=C(K,h,1),b=C(V,p,1)}else _(1);if(c>y){f&&_(0);break}}u&&l(d+131072);for(var Q=(1<<h)-1,Y=(1<<p)-1,Z=c;;Z=c){var rr=(H=m[$(r,c)&Q])>>4;if((c+=15&H)>y){f&&_(0);break}if(H||_(2),rr<256)t[d++]=rr;else{if(256==rr){Z=c,m=null;break}var er=rr-254;if(rr>264){var tr=w[D=rr-257];er=X(r,c,(1<<tr)-1)+j[D],c+=tr}var nr=b[$(r,c)&Y],or=nr>>4;nr||_(3),c+=15&nr;V=I[or];if(or>3){tr=S[or];V+=$(r,c)&(1<<tr)-1,c+=tr}if(c>y){f&&_(0);break}u&&l(d+131072);var ir=d+er;if(d<V){var ar=i-V,ur=Math.min(V,ir);for(ar+d<0&&_(3);d<ur;++d)t[d]=n[ar+d]}for(;d<ir;++d)t[d]=t[d-V]}}e.l=m,e.p=Z,e.b=d,e.f=s,m&&(s=1,e.m=h,e.d=b,e.n=p)}while(!s);return d!=t.length&&a?L(t,0,d):t.subarray(0,d)},B=new v(0),W=function(r,e,t){for(var n=r(),o=r.toString(),i=o.slice(o.indexOf("[")+1,o.lastIndexOf("]")).replace(/\s+/g,"").split(","),a=0;a<n.length;++a){var u=n[a],f=i[a];if("function"==typeof u){e+=";"+f+"=";var l=u.toString();if(u.prototype)if(-1!=l.indexOf("[native code]")){var s=l.indexOf(" ",8)+1;e+=l.slice(s,l.indexOf("(",s))}else for(var c in e+=l,u.prototype)e+=";"+f+".prototype."+c+"="+u.prototype[c].toString();else e+=l}else t[f]=u}return e},G=[],H=function(r,e,t,n){if(!G[t]){for(var o="",i={},a=r.length-1,u=0;u<a;++u)o=W(r[u],o,i);G[t]={c:W(r[a],o,i),e:i}}var f=function(r,e){var t={};for(var n in r)t[n]=r[n];for(var n in e)t[n]=e[n];return t}({},G[t].e);return function(r,e,t,n,o){var i=new Worker(p[e]||(p[e]=URL.createObjectURL(new Blob([r+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return i.onmessage=function(r){var e=r.data,t=e.$e$;if(t){var n=new Error(t[0]);n.code=t[1],n.stack=t[2],o(n,null)}else o(null,e)},i.postMessage(t,n),i}(G[t].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",t,f,function(r){var e=[];for(var t in r)r[t].buffer&&e.push((r[t]=new r[t].constructor(r[t])).buffer);return e}(f),n)},J=function(){return[v,y,g,w,S,O,j,I,F,M,E,R,C,U,X,$,q,L,_,z,er,K,V]},K=function(r){return postMessage(r,[r.buffer])},V=function(r){return r&&{out:r.size&&new v(r.size),dictionary:r.dictionary}},Q=function(r,e,t,n,o,i){var a=H(t,n,o,(function(r,e){a.terminate(),i(r,e)}));return a.postMessage([r,e],e.consume?[r.buffer]:[]),function(){a.terminate()}},Y=function(r,e){return r[e]|r[e+1]<<8},Z=function(r,e){return(r[e]|r[e+1]<<8|r[e+2]<<16|r[e+3]<<24)>>>0},rr=function(r,e){return Z(r,e)+4294967296*Z(r,e+4)};function er(r,e){return z(r,{i:2},e&&e.out,e&&e.dictionary)}var tr="undefined"!=typeof TextDecoder&&new TextDecoder;try{tr.decode(B,{stream:!0}),1}catch(r){}var nr=function(r){for(var e="",t=0;;){var n=r[t++],o=(n>127)+(n>223)+(n>239);if(t+o>r.length)return{s:e,r:L(r,t-1)};o?3==o?(n=((15&n)<<18|(63&r[t++])<<12|(63&r[t++])<<6|63&r[t++])-65536,e+=String.fromCharCode(55296|n>>10,56320|1023&n)):e+=1&o?String.fromCharCode((31&n)<<6|63&r[t++]):String.fromCharCode((15&n)<<12|(63&r[t++])<<6|63&r[t++]):e+=String.fromCharCode(n)}};function or(r,e){if(e){for(var t="",n=0;n<r.length;n+=16384)t+=String.fromCharCode.apply(null,r.subarray(n,n+16384));return t}if(tr)return tr.decode(r);var o=nr(r),i=o.s;return(t=o.r).length&&_(8),i}var ir,ar=function(r,e){return e+30+Y(r,e+26)+Y(r,e+28)},ur=function(r,e,t){var n=Y(r,e+28),o=Y(r,e+30),i=or(r.subarray(e+46,e+46+n),!(2048&Y(r,e+8))),a=e+46+n,u=fr(r,a,o,t,Z(r,e+20),Z(r,e+24),Z(r,e+42)),f=u[0],l=u[1],s=u[2];return[Y(r,e+10),f,l,i,a+o+Y(r,e+32),s]},fr=function(r,e,t,n,o,i,a){var u=4294967295==o,f=4294967295==i,l=4294967295==a,s=e+t;if(n&&u+f+l){for(;e+4<s;e+=4+Y(r,e+2))if(1==Y(r,e))return[u?rr(r,e+4+8*f):o,f?rr(r,e+4):i,l?rr(r,e+4+8*(f+u)):a,1];n<2&&_(13)}return[o,i,a,0]},lr="function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout?setTimeout:function(r){r()};function sr(r,e,t){t||(t=e,e={}),"function"!=typeof t&&_(7);var n=[],o=function(){for(var r=0;r<n.length;++r)n[r]()},i={},a=function(r,e){lr((function(){t(r,e)}))};lr((function(){a=t}));for(var u=r.length-22;101010256!=Z(r,u);--u)if(!u||r.length-u>65558)return a(_(13,0,1),null),o;var f=Y(r,u+8);if(f){var l=f,s=Z(r,u+16),c=117853008==Z(r,u-20);if(c){var d=Z(r,u-12);(c=101075792==Z(r,d))&&(l=f=Z(r,d+32),s=Z(r,d+48))}for(var m=e&&e.filter,b=function(e){var t=ur(r,s,c),u=t[0],l=t[1],d=t[2],b=t[3],h=t[4],p=t[5],y=ar(r,p);s=h;var g=function(r,e){r?(o(),a(r,null)):(e&&(i[b]=e),--f||a(null,i))};if(!m||m({name:b,size:l,originalSize:d,compression:u}))if(u)if(8==u){var w=r.subarray(y,y+l);if(d<524288||l>.8*d)try{g(null,er(w,{out:new v(d)}))}catch(r){g(r,null)}else n.push(function(r,e,t){return t||(t=e,e={}),"function"!=typeof t&&_(7),Q(r,e,[J],(function(r){return K(er(r.data[0],V(r.data[1])))}),1,t)}(w,{size:d},g))}else g(_(14,"unknown compression type "+u,1),null);else g(null,L(r,y,y+l));else g(null,null)},h=0;h<l;++h)b()}else a(null,{});return o}function cr(r,e){return function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=e.filter,n=arguments.length>2?arguments[2]:void 0;return n(new Uint8Array(r),{filter:function(r){return!t||t({path:r.name})}})}(r,e,dr,!0)}function dr(r){return new Promise((function(e,t){sr(r,(function(r,n){r?t(r):e(n)}))}))}function mr(r){var e=Date.now();("undefined"!=typeof global?Boolean(global.READ_EXCEL_FILE_CHECKPOINTS):"undefined"!=typeof window&&Boolean(window.READ_EXCEL_FILE_CHECKPOINTS))&&(ir&&console.log(" -",e-ir,"ms"),console.log("*",r)),ir=e}function br(r){mr("convert files to strings");for(var e={},t=0,n=Object.keys(r);t<n.length;t++){var o=n[t];e[o]=or(r[o])}return e}function hr(r){var e=r.path;return e.endsWith(".xml")||e.endsWith(".xml.rels")}function pr(r){return ir=void 0,mr("unpack files"),r instanceof File||r instanceof Blob?r.arrayBuffer().then(vr):Promise.resolve(r).then(vr)}function vr(r){return cr(r,{filter:hr}).then(br)}function yr(r,e){return e(r,{createInitialState:gr,onOpenTag:wr}).then((function(r){return{epoch1904:!!r.workbookPr&&r.workbookPr.epoch1904,sheets:r.sheets}}))}function gr(){return{workbookPr:void 0,sheets:[]}}function wr(r,e,t){"workbookPr"===r?t.workbookPr||(t.workbookPr={epoch1904:"1"===e.date1904}):"sheet"===r&&e.name&&t.sheets.push({id:Number(e.sheetId),name:e.name,relationId:e["r:id"]})}function Sr(r,e){return e(r,{createInitialState:Or,onOpenTag:xr}).then((function(r){return r}))}function Or(){return{sheets:{},sharedStrings:void 0,styles:void 0}}function xr(r,e,t){"Relationship"===r&&function(r,e,t,n){switch(t){case"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles":r.styles=Ar(n);break;case"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings":r.sharedStrings=Ar(n);break;case"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet":r.sheets[e]=Ar(n)}}(t,e.Id,e.Type,e.Target)}function Ar(r){return"/"===r[0]?r.slice(1):"xl/"+r}function jr(r){return jr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},jr(r)}var kr=["xfId"];function Ir(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.push.apply(t,n)}return t}function Er(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?Ir(Object(t),!0).forEach((function(e){Pr(r,e,t[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Ir(Object(t)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))}))}return r}function Pr(r,e,t){return(e=function(r){var e=function(r,e){if("object"!==jr(r)||null===r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!==jr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"===jr(e)?e:String(e)}(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Tr(r,e){if(null==r)return{};var t,n,o=function(r,e){if(null==r)return{};var t,n,o={},i=Object.keys(r);for(n=0;n<i.length;n++)t=i[n],e.indexOf(t)>=0||(o[t]=r[t]);return o}(r,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(n=0;n<i.length;n++)t=i[n],e.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(r,t)&&(o[t]=r[t])}return o}function Cr(r,e){return e(r,{createInitialState:Nr,onOpenTag:Dr,onCloseTag:Fr}).then((function(r){return r.styles.map((function(e){if(e.xfId){var t=e.xfId,n=Tr(e,kr);return Er(Er({},r.baseStyles[t]),n)}return e}))}))}function Nr(){return{numberFormats:{},baseStyles:[],styles:[],cellStyleXfs:!1,cellXfs:!1}}function Dr(r,e,t){if("numFmt"===r)t.numberFormats[e.numFmtId]={id:Number(e.numFmtId),template:e.formatCode};else if("cellStyleXfs"===r)t.cellStyleXfs=!0;else if("cellXfs"===r)t.cellXfs=!0;else if("xf"===r)if(t.cellStyleXfs)t.baseStyles.push(Mr(e));else if(t.cellXfs){var n=Mr(e,t.numberFormats);e.xfId&&(n.xfId=Number(e.xfId)),t.styles.push(n)}}function Fr(r,e){"cellStyleXfs"===r?e.cellStyleXfs=!1:"cellXfs"===r&&(e.cellXfs=!1)}function Mr(r,e){var t={},n=r.numFmtId;return n&&(e&&e[n]?t.numberFormat=e[n]:t.numberFormat={id:Number(n)}),t}function Ur(r,e){return e(r,{createInitialState:Xr,onOpenTag:$r,onCloseTag:qr,onText:Lr}).then((function(r){return r.strings}))}function Xr(){return{si:void 0,strings:[]}}function $r(r,e,t){"si"===r?t.si={t:!1,r:!1,rPh:!1,string:""}:t.si&&function(r,e,t){"t"===r?t.t=!0:"r"===r?t.r=!0:"rPh"===r&&(t.rPh=!0)}(r,0,t.si)}function qr(r,e){"si"===r?(e.strings.push(e.si.string),e.si=void 0):e.si&&function(r,e){"t"===r?e.t=!1:"r"===r?e.r=!1:"rPh"===r&&(e.rPh=!1)}(r,e.si)}function Lr(r,e){e.si&&function(r,e){e.rPh||e.t&&(e.r?e.string+=r:e.string=r)}(r,e.si)}var Rr=17,_r=1,zr=1,Br=864e5,Wr=365;function Gr(r){var e=Number(r);if(isNaN(e))throw new Error("Couldn't parse number: ".concat(r));return e}function Hr(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=function(r,e){if(!r)return;if("string"==typeof r)return Jr(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);"Object"===t&&r.constructor&&(t=r.constructor.name);if("Map"===t||"Set"===t)return Array.from(r);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Jr(r,e)}(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0;return function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Jr(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}var Kr=/^\[\$-[^\]]+\]/,Vr=/;@$/,Qr={};function Yr(r){if(r in Qr)return Qr[r];var e=function(r){r=r.toLowerCase(),r=r.replace(Kr,""),r=r.replace(Vr,"");var e=r.split(/\W+/);if(e.length<0)return!1;for(var t,n=Hr(e);!(t=n()).done;){var o=t.value;if(Zr.indexOf(o)<0)return!1}return!0}(r);return Qr[r]=e,e}var Zr=["ss","mm","h","hh","am","pm","d","dd","m","mm","mmm","mmmm","yy","yyyy","e"];var re=[27,28,29,30,31,32,33,34,35,36,50,51,52,53,54,55,56,57,58],ee=[27,28,29,30,31,32,33,34,35,36,50,51,52,53,54,55,56,57,58],te=[14,15,16,17,18,19,20,21,22,45,46,47].concat(re).concat(ee.filter((function(r){return re.indexOf(r)<0}))).concat([71,72,73,74,75,76,77,78,79,80,81].filter((function(r){return re.indexOf(r)<0})).filter((function(r){return ee.indexOf(r)<0})));function ne(r,e,t){var n=t.inlineString,o=t.styleId,i=t.styles,a=t.sharedStrings,u=t.epoch1904,f=t.options;switch(e||(e="n"),e){case"str":r=oe(r,f);break;case"inlineStr":if(void 0===(r=n))throw new Error('Couldn\'t read "inline string" cell value');r=oe(r,f);break;case"s":var l=Number(r);if(isNaN(l))throw new Error('Invalid "shared" string index: '.concat(r));if(l>=a.length)throw new Error('An out-of-bounds "shared" string index: '.concat(r));r=oe(r=a[l],f);break;case"b":if("1"===r)r=!0;else{if("0"!==r)throw new Error('Unsupported "boolean" cell value: '.concat(r));r=!1}break;case"z":r=void 0;break;case"e":r=function(r){switch(r){case 0:return"#NULL!";case 7:return"#DIV/0!";case 15:return"#VALUE!";case 23:return"#REF!";case 29:return"#NAME?";case 36:return"#NUM!";case 42:return"#N/A";case 43:return"#GETTING_DATA";default:return"#ERROR_".concat(r)}}(r);break;case"d":if(void 0===r)break;var s=new Date(r);if(isNaN(s.valueOf()))throw new Error('Unsupported "date" cell value: '.concat(r));r=s;break;case"n":if(void 0===r)break;r=o&&function(r,e,t){if(void 0!==r){var n=e[r];if(!n)throw new Error("Cell style not found: ".concat(r));if(!n.numberFormat)return!1;if(te.indexOf(n.numberFormat.id)>=0||t.dateFormat&&n.numberFormat.template===t.dateFormat||!1!==t.smartDateParser&&n.numberFormat.template&&Yr(n.numberFormat.template))return!0}}(o,i,f)?function(r,e){e&&e.epoch1904&&(r+=4*Wr+_r+zr);var t=_r+zr+70*Wr+Rr;return new Date(Math.floor((r-t)*Br))}(r=Gr(r),{epoch1904:u}):(f.parseNumber||Gr)(r);break;default:throw new TypeError("Cell type not supported: ".concat(e))}return void 0===r&&(r=null),r}function oe(r,e){return!1!==e.trim&&(r=r.trim()),""===r&&(r=void 0),r}function ie(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,i,a,u=[],f=!0,l=!1;try{if(i=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=i.call(t)).done)&&(u.push(n.value),u.length!==e);f=!0);}catch(r){l=!0,o=r}finally{try{if(!f&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(r,e)||function(r,e){if(!r)return;if("string"==typeof r)return ae(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);"Object"===t&&r.constructor&&(t=r.constructor.name);if("Map"===t||"Set"===t)return Array.from(r);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ae(r,e)}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ae(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function ue(r){var e=ie(r.split(/(\d+)/),2),t=e[0],n=e[1];return[Number(n),le(t.trim())]}var fe=["","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"];function le(r){for(var e=0,t=0;t<r.length;)e*=26,e+=fe.indexOf(r[t]),t++;return e}function se(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,i,a,u=[],f=!0,l=!1;try{if(i=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=i.call(t)).done)&&(u.push(n.value),u.length!==e);f=!0);}catch(r){l=!0,o=r}finally{try{if(!f&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(r,e)||function(r,e){if(!r)return;if("string"==typeof r)return ce(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);"Object"===t&&r.constructor&&(t=r.constructor.name);if("Map"===t||"Set"===t)return Array.from(r);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ce(r,e)}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ce(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function de(r,e,t,n,o){return r.cells.map((function(r){return function(r,e,t,n,o,i,a){var u=se(ue(r.r),2);return{row:u[0],column:u[1],value:ne(e,r.t,{inlineString:t,styleId:r.s?Number(r.s):void 0,styles:o,sharedStrings:n,epoch1904:i,options:a})}}(r.attributes,r.value,r.inlineString,e,t,n,o)}))}function me(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=function(r,e){if(!r)return;if("string"==typeof r)return be(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);"Object"===t&&r.constructor&&(t=r.constructor.name);if("Map"===t||"Set"===t)return Array.from(r);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return be(r,e)}(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0;return function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function be(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function he(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=function(r,e){if(!r)return;if("string"==typeof r)return pe(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);"Object"===t&&r.constructor&&(t=r.constructor.name);if("Map"===t||"Set"===t)return Array.from(r);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return pe(r,e)}(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0;return function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function pe(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function ve(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,i,a,u=[],f=!0,l=!1;try{if(i=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=i.call(t)).done)&&(u.push(n.value),u.length!==e);f=!0);}catch(r){l=!0,o=r}finally{try{if(!f&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(r,e)||ye(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ye(r,e){if(r){if("string"==typeof r)return ge(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ge(r,e):void 0}}function ge(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function we(r,e){if(0===r.length)return[];var t=ve(e,2);t[0];for(var n=t[1],o=n.column,i=n.row,a=new Array(i),u=0;u<i;){a[u]=new Array(o);for(var f=0;f<o;)a[u][f]=null,f++;u++}for(var l,s=function(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=ye(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0;return function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(r);!(l=s()).done;){var c=l.value,d=c.row-1,m=c.column-1;m<o&&d<i&&(a[d][m]=c.value)}return a=function(r){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=e.rowIndexSourceMap,n=e.accessor,o=void 0===n?function(r){return r}:n,i=e.onlyTrimAtTheEnd,a=r.length-1;a>=0;){for(var u,f=!0,l=me(r[a]);!(u=l()).done;)if(null!==o(u.value)){f=!1;break}if(f)r.splice(a,1),t&&t.splice(a,1);else if(i)break;a--}return r}(function(r){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=e.accessor,n=void 0===t?function(r){return r}:t,o=e.onlyTrimAtTheEnd,i=r[0].length-1;i>=0;){for(var a,u=!0,f=he(r);!(a=f()).done;)if(null!==n(a.value[i])){u=!1;break}if(u)for(var l=0;l<r.length;)r[l].splice(i,1),l++;else if(o)break;i--}return r}(a,{onlyTrimAtTheEnd:!0}),{onlyTrimAtTheEnd:!0}),a}function Se(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,i,a,u=[],f=!0,l=!1;try{if(i=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=i.call(t)).done)&&(u.push(n.value),u.length!==e);f=!0);}catch(r){l=!0,o=r}finally{try{if(!f&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(r,e)||function(r,e){if(!r)return;if("string"==typeof r)return Oe(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);"Object"===t&&r.constructor&&(t=r.constructor.name);if("Map"===t||"Set"===t)return Array.from(r);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Oe(r,e)}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Oe(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function xe(r,e,t){var n=t.sharedStrings,o=t.styles,i=t.epoch1904,a=t.options,u=function(r){var e=de(r.sheetData,n,o,i,a),t=r.dimension?function(r){var e=r.split(":").map(ue).map((function(r){var e=Se(r,2);return{row:e[0],column:e[1]}}));1===e.length&&(e=[e[0],e[0]]);return e}(r.dimension):function(r){var e=function(r,e){return r-e},t=r.map((function(r){return r.row})).sort(e),n=r.map((function(r){return r.column})).sort(e),o=t[0],i=t[t.length-1];return[{row:o,column:n[0]},{row:i,column:n[n.length-1]}]}(e);return we(e,t)};return e(r,{createInitialState:Ae,onOpenTag:je,onCloseTag:ke,onText:Ie}).then((function(r){return u(r)}))}function Ae(){return{dimension:void 0,sheetData:void 0}}function je(r,e,t){"dimension"===r?t.dimension=e.ref:"sheetData"===r?t.sheetData={c:void 0,cells:[]}:t.sheetData&&function(r,e,t){"c"===r?(t.c={v:!1,is:!1,t:!1,r:!1,rPh:!1,value:void 0,inlineString:void 0,attributes:void 0},t.c.attributes=e):t.c&&function(r,e,t){"v"===r?t.v=!0:"is"===r?(t.is=!0,t.inlineString=""):"t"===r?t.t=!0:"r"===r?t.r=!0:"rPh"===r&&(t.rPh=!0)}(r,0,t.c)}(r,e,t.sheetData)}function ke(r,e){e.sheetData&&function(r,e){"c"===r?(e.cells.push({attributes:e.c.attributes,value:e.c.value,inlineString:e.c.inlineString}),e.c=void 0):e.c&&function(r,e){"v"===r?e.v=!1:"is"===r?e.is=!1:"t"===r?e.t=!1:"r"===r?e.r=!1:"rPh"===r&&(e.rPh=!1)}(r,e.c)}(r,e.sheetData)}function Ie(r,e){e.sheetData&&function(r,e){e.c&&function(r,e){e.v?e.value=r:e.is&&(e.rPh||e.t&&(e.r?e.inlineString+=r:e.inlineString=r))}(r,e.c)}(r,e.sheetData)}function Ee(r){return Ee="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ee(r)}function Pe(r){return"object"===Ee(r)&&"function"==typeof r.then}var Te=["parseNumber"];function Ce(r){return Ce="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ce(r)}function Ne(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=function(r,e){if(!r)return;if("string"==typeof r)return De(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);"Object"===t&&r.constructor&&(t=r.constructor.name);if("Map"===t||"Set"===t)return Array.from(r);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return De(r,e)}(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0;return function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function De(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function Fe(r,e){if(null==r)return{};var t,n,o=function(r,e){if(null==r)return{};var t,n,o={},i=Object.keys(r);for(n=0;n<i.length;n++)t=i[n],e.indexOf(t)>=0||(o[t]=r[t]);return o}(r,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(n=0;n<i.length;n++)t=i[n],e.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(r,t)&&(o[t]=r[t])}return o}function Me(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.push.apply(t,n)}return t}function Ue(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?Me(Object(t),!0).forEach((function(e){Xe(r,e,t[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Me(Object(t)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))}))}return r}function Xe(r,e,t){return(e=function(r){var e=function(r,e){if("object"!==Ce(r)||null===r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!==Ce(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"===Ce(e)?e:String(e)}(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function $e(r,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return mr("parse spreadsheet info and file paths"),Be(Re(),e,r).then((function(n){var o=n.spreadsheetInfo,i=n.filePaths;return mr('parse "shared strings" and "styles"'),Be(_e(i),e,r).then((function(n){var a=n.sharedStrings,u=n.styles,f=t.sheets?t.sheets.map((function(r){return qe(r,o.sheets)})):o.sheets.map((function(r){return r.relationId}));return mr("parse sheet".concat(1===f.length?"":"s"," data")),Be(ze(i,f,{sharedStrings:a,styles:u,epoch1904:o.epoch1904,options:t}),e,r).then((function(r){return mr("end"),f.map((function(e){return{sheet:Le(e,o.sheets),data:r[e]}}))}))}))}))}function qe(r,e){if("string"==typeof r){for(var t,n=Ne(e);!(t=n()).done;){var o=t.value;if(o.name===r)return o.relationId}throw new Error('Sheet "'.concat(r,'" not found. Available sheets: ').concat(e.map((function(r){var e=r.name;return'"'.concat(e,'"')})).join(", ")))}if(r<=e.length)return e[r-1].relationId;throw new Error("Sheet number out of bounds: ".concat(r,". Available sheets count: ").concat(e.length))}function Le(r,e){for(var t,n=Ne(e);!(t=n()).done;){var o=t.value;if(o.relationId===r)return o.name}throw new Error("Sheet relation ID not found: ".concat(r))}function Re(){return{"xl/_rels/workbook.xml.rels":{name:"filePaths",parse:Sr},"xl/workbook.xml":{name:"spreadsheetInfo",parse:yr}}}function _e(r){var e;return Xe(e={},r.sharedStrings||"xl/sharedStrings.xml",{name:"sharedStrings",parse:Ur,fallback:[]}),Xe(e,r.styles||"xl/styles.xml",{name:"styles",parse:Cr,fallback:{}}),e}function ze(r,e,t){return Object.keys(r.sheets).filter((function(r){return e.includes(r)})).reduce((function(e,n){return Ue(Ue({},e),{},Xe({},r.sheets[n],{name:n,parse:function(r,e){return xe(r,e,t)}}))}),{})}function Be(r,e,t){for(var n,o,i={},a=0,u=Object.keys(r);a<u.length;a++)n=void 0,o=void 0,n=u[a],o=r[n],i[o.name]=void 0===e[n]?void 0===o.fallback?function(){throw new Error('"'.concat(n,'" file not found inside the `.xlsx` file'))}():o.fallback:o.parse(e[n],t);for(var f=[],l=function(){var r=c[s];Pe(i[r])&&f.push(i[r].then((function(e){i[r]=e})))},s=0,c=Object.keys(i);s<c.length;s++)l();return f.length>0?Promise.all(f).then((function(){return i})):i}return function(r,e){return pr(r).then((function(r){return function(r,e,t,n){if(n&&n.parseNumber||(n=Ue(Ue({},n),{},{parseNumber:Gr})),!r)return $e(e,t,n);var o=n,i=o.parseNumber,a=Fe(o,Te),u=r((function(r){var t=Ue(Ue({},r.optionsJson),{},{parseNumber:i});return $e(e,r.contents,t)}));return u.addDependencies((function(){return[e,i,$e,qe,Le,Re,_e,ze,Be,mr,ir,Pe]})),u.callOnce({optionsJson:a,contents:t})}(undefined,h,r,e)}))}}));
|
|
2
2
|
//# sourceMappingURL=read-excel-file.min.js.map
|