xlsxtream
v2.0.0
Published
Reading .xlsx worksheets as object streams
Downloads
3,111
Readme
xlsxtream
is a module for reading tabulated data from .xlsx
(and, in general, OOXML) workbooks using node.js streams API.
Only common workbook data (including the shared strings list) are kept in memory; worksheets contents is read row by row using a chain of transform streams.
Basically, rows read are Arrays of Strings. Dates are presented in YYYY-MM-DD
format, time in HH:MI:SS
. No effort is made to properly map scalar values to javaScript objects as the module is presumed to transform .xlsx
data into CSV and other text formats for further bulk load into databases and similar operations.
Advanced users may prefer to alter the output format by accessing some lower level internals (see the reference below).
Installation
npm install xlsxtream
Usage
const xlsx = require ('xlsxtream')
const workbook = xlsx.open ('/path/to/book.xlsx')
const worksheet = workbook.sheetByName.Sheet1
// const worksheet = workbook.sheets [0]
// worksheet.toObject = function (xmlNode) {return ...}
const rows = await ws.getObjectStream ()
/*
for await (const [A, B, C] of rows) {
console.log (`A=${A}, B=${B}, C=${C}`)
console.log (` (read ${worksheet.position} of ${worksheet.size} bytes)`)
}
*/
See the project's wiki docs for more information.