read-excel-file 5.3.1 → 5.3.4
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/CHANGELOG.md +10 -0
- package/README.md +29 -14
- package/bundle/read-excel-file.min.js +1 -1
- package/bundle/read-excel-file.min.js.map +1 -1
- package/commonjs/package.json +5 -1
- package/commonjs/read/isDateTimestamp.js +112 -0
- package/commonjs/read/isDateTimestamp.js.map +1 -0
- package/commonjs/read/parseCell.js +5 -0
- package/commonjs/read/parseCell.js.map +1 -1
- package/commonjs/read/parseCellValue.js +78 -93
- package/commonjs/read/parseCellValue.js.map +1 -1
- package/commonjs/read/parseDate.js.map +1 -1
- package/commonjs/read/schema/convertToJson.js +87 -26
- package/commonjs/read/schema/convertToJson.js.map +1 -1
- package/commonjs/read/schema/convertToJson.test.js.map +1 -1
- package/commonjs/xml/dom.js +29 -0
- package/commonjs/xml/dom.js.map +1 -1
- package/commonjs/xml/xlsx.js.map +1 -1
- package/commonjs/xml/xml.js +2 -4
- package/commonjs/xml/xml.js.map +1 -1
- package/commonjs/xml/{xlsx-xpath.js → xpath/xlsx-xpath.js} +1 -0
- package/commonjs/xml/xpath/xlsx-xpath.js.map +1 -0
- package/commonjs/xml/{xpathBrowser.js → xpath/xpathBrowser.js} +1 -0
- package/commonjs/xml/xpath/xpathBrowser.js.map +1 -0
- package/commonjs/xml/{xpathNode.js → xpath/xpathNode.js} +1 -1
- package/commonjs/xml/xpath/xpathNode.js.map +1 -0
- package/modules/read/isDateTimestamp.js +104 -0
- package/modules/read/isDateTimestamp.js.map +1 -0
- package/modules/read/parseCell.js +5 -1
- package/modules/read/parseCell.js.map +1 -1
- package/modules/read/parseCellValue.js +76 -91
- package/modules/read/parseCellValue.js.map +1 -1
- package/modules/read/parseDate.js.map +1 -1
- package/modules/read/schema/convertToJson.js +87 -26
- package/modules/read/schema/convertToJson.js.map +1 -1
- package/modules/read/schema/convertToJson.test.js.map +1 -1
- package/modules/xml/dom.js +27 -0
- package/modules/xml/dom.js.map +1 -1
- package/modules/xml/xlsx.js.map +1 -1
- package/modules/xml/xml.js +2 -2
- package/modules/xml/xml.js.map +1 -1
- package/modules/xml/{xlsx-xpath.js → xpath/xlsx-xpath.js} +1 -0
- package/modules/xml/xpath/xlsx-xpath.js.map +1 -0
- package/modules/xml/{xpathBrowser.js → xpath/xpathBrowser.js} +1 -0
- package/modules/xml/xpath/xpathBrowser.js.map +1 -0
- package/modules/xml/{xpathNode.js → xpath/xpathNode.js} +1 -1
- package/modules/xml/xpath/xpathNode.js.map +1 -0
- package/package.json +3 -2
- package/runnable/create-commonjs-package-json.js +1 -1
- package/types.d.ts +11 -6
- package/commonjs/xml/xlsx-xpath.js.map +0 -1
- package/commonjs/xml/xpathBrowser.js.map +0 -1
- package/commonjs/xml/xpathNode.js.map +0 -1
- package/modules/xml/xlsx-xpath.js.map +0 -1
- package/modules/xml/xpathBrowser.js.map +0 -1
- package/modules/xml/xpathNode.js.map +0 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -157,7 +157,7 @@ const schema = {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
readXlsxFile(file, { schema }).then(({ rows, errors }) => {
|
|
160
|
-
// `errors` list items have shape: `{ row, column, error, value }`.
|
|
160
|
+
// `errors` list items have shape: `{ row, column, error, reason?, value?, type? }`.
|
|
161
161
|
errors.length === 0
|
|
162
162
|
|
|
163
163
|
rows === [{
|
|
@@ -241,27 +241,34 @@ const { rows, errors } = convertToJson(data, schema)
|
|
|
241
241
|
```js
|
|
242
242
|
import { parseExcelDate } from 'read-excel-file'
|
|
243
243
|
|
|
244
|
-
function ParseExcelError({ children
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
value = parseExcelDate(value).toString()
|
|
249
|
-
}
|
|
250
|
-
// Render error summary.
|
|
244
|
+
function ParseExcelError({ children }) {
|
|
245
|
+
const { type, value, error, reason, row, column } = children
|
|
246
|
+
|
|
247
|
+
// Error summary.
|
|
251
248
|
return (
|
|
252
249
|
<div>
|
|
253
|
-
<code>"{error
|
|
250
|
+
<code>"{error}"</code>
|
|
251
|
+
{reason && ' '}
|
|
252
|
+
{reason && <code>("{reason}")</code>}
|
|
254
253
|
{' for value '}
|
|
255
|
-
<code>
|
|
254
|
+
<code>{stringifyValue(value)}</code>
|
|
256
255
|
{' in column '}
|
|
257
|
-
<code>"{
|
|
258
|
-
{
|
|
259
|
-
{
|
|
256
|
+
<code>"{column}"</code>
|
|
257
|
+
{type && type.name && ' of type '}
|
|
258
|
+
{type && type.name && <code>"{type.name}"</code>}
|
|
260
259
|
{' in row '}
|
|
261
|
-
<code>
|
|
260
|
+
<code>{row}</code>
|
|
262
261
|
</div>
|
|
263
262
|
)
|
|
264
263
|
}
|
|
264
|
+
|
|
265
|
+
function stringifyValue(value) {
|
|
266
|
+
// Wrap strings in quotes.
|
|
267
|
+
if (typeof value === 'string') {
|
|
268
|
+
return '"' + value + '"'
|
|
269
|
+
}
|
|
270
|
+
return String(value)
|
|
271
|
+
}
|
|
265
272
|
```
|
|
266
273
|
</details>
|
|
267
274
|
|
|
@@ -338,6 +345,14 @@ When using `readXlsx()` with a `schema` parameter, all schema columns having typ
|
|
|
338
345
|
readXlsxFile(file, { dateFormat: 'mm/dd/yyyy' })
|
|
339
346
|
```
|
|
340
347
|
|
|
348
|
+
## Trim
|
|
349
|
+
|
|
350
|
+
By default, it automatically trims all string values. To disable this feature, pass `trim: false` option.
|
|
351
|
+
|
|
352
|
+
```js
|
|
353
|
+
readXlsxFile(file, { trim: false })
|
|
354
|
+
```
|
|
355
|
+
|
|
341
356
|
## Limitations
|
|
342
357
|
|
|
343
358
|
### Performance
|