simple-xlsx-reader
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "simple-xlsx-reader", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -18,3 +18,3 @@ | ||
const fs = require('fs') | ||
const xmlParser = require('simple-xlsx-reader') | ||
const { xlsxParser } = require('simple-xlsx-reader') | ||
@@ -32,6 +32,30 @@ const write = (fn) => { | ||
fs.createReadStream('path to xlsx file')) | ||
.pipe(xmlParser()) | ||
.pipe(xlsxParser()) | ||
.pipe(write((row) => { | ||
console.log('XLSX Row', row) | ||
})) | ||
``` | ||
To return in array of arrays format, you can use `onlyCellValues` function that get only values of cells. | ||
```javascript | ||
const { Writable } = require('stream') | ||
const fs = require('fs') | ||
const { xlsxParser, onlyCellValues } = require('simple-xlsx-reader') | ||
const write = (fn) => { | ||
return new Writable({ | ||
objectMode: true, | ||
write (chunk, _, callback) { | ||
fn(chunk) | ||
callback() | ||
} | ||
}) | ||
} | ||
fs.createReadStream('path to xlsx file')) | ||
.pipe(xlsxParser(onlyCellValues())) | ||
.pipe(write((row) => { | ||
console.log('XLSX Row', row) | ||
})) | ||
``` |
@@ -234,7 +234,7 @@ const unzipper = require('unzipper'); | ||
const asArray = (opts = {}) => Object.assign({ mapCol: (col) => col.value }, opts || {}) | ||
const onlyCellValues = (opts = {}) => Object.assign({ mapCol: (col) => col.value }, opts || {}) | ||
module.exports = { | ||
xlsxParser, | ||
asArray | ||
onlyCellValues | ||
} |
/* eslint-disable no-undef */ | ||
const { xlsxParser, asArray } = require('../src/') | ||
const { xlsxParser, onlyCellValues } = require('../src/') | ||
const expect = require('chai').expect | ||
@@ -26,3 +26,3 @@ const fs = require('fs') | ||
fs.createReadStream(path.resolve(__dirname, './assets/sample1.xlsx')) | ||
.pipe(xlsxParser(asArray())) | ||
.pipe(xlsxParser(onlyCellValues())) | ||
.pipe(write((chunk) => { | ||
@@ -29,0 +29,0 @@ expect(chunk).to.be.a('array').that.is.not.empty |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28606
59