Turns XLSX into a readable stream.

Overview

Build Status codecov npm

xlstream

Memory-efficiently turns XLSX file into a transform stream with all its benefits.

  • Stream is pausable.
  • Emits all default events (data, end, etc.)
  • Returns header, raw and formatted row data in just one data event.
  • Maintains desirable behavior of merged cells.
  • Supports files created by OpenXML.
  • Supports standard, Excel and custom number formats.

Installation

npm install xlstream

Example

source.xlsx contents:

A B
hello 123

Where 123 is a 123.123 number formatted to be rounded to integer.

Script:

const { getXlsxStream } = require('xlstream');

(async () => {
    const stream = await getXlsxStream({
        filePath: './source.xlsx',
        sheet: 0,
    });
    stream.on('data', x => console.log(x));
})();

Result:

{ 
    "raw": { 
        "obj": { "A": "hello", "B": 123.123 }, 
        "arr": [ "hello", 123.123 ] 
    },
    "formatted": { 
        "obj": { "A": "hello", "B": 123 }, 
        "arr": [ "hello", 123 ] 
    },
    "header": []
}

getXlsxStream

Returns transform stream of the sheet.

Options

option type description
filePath string Path to the XLSX file
sheet string or number If string is passed, finds sheet by it's name. If number, finds sheet by it's index.
withHeader boolean or number If true, column names will be taken from the first sheet row. If duplicated header name is found, column name will be prepended with column letter to maintain uniqueness. 0-based row location can be passed to this option if header is not located on the first row.
ignoreEmpty boolean If true, empty rows won't be emitted.
fillMergedCells boolean If true, merged cells will have the same value (by default, only the first cell of merged cells is filled with value). Warning! Enabling this feature may increase streaming time because file must be processed to detect merged cells before actual stream.
numberFormat standard or excel or object By default standard format is used. Excel implementation of number formatting differs from standard (can be read here) so excel option can be used to match this difference. If custom formatting is needed, a dictionary object can be passed to this option.

getXlsxStreams

Async generator which yields transform streams of the sheets.

Options

Option Type Description
filePath string Path to the XLSX file
sheets array of sheet objects Options of sheet object can be found below.

Sheet object

option type description
id string or number If string is passed, finds sheet by it's name. If number, finds sheet by it's index.
withHeader boolean If true, column names will be taken from the first sheet row. If duplicated header name is found, column name will be prepended with column letter to maintain uniqueness. 0-based row location can be passed to this option if header is not located on the first row.
ignoreEmpty boolean If true, empty rows won't be emitted.
fillMergedCells boolean If true, merged cells will have the same value (by default, only the first cell of merged cells is filled with value). Warning! Enabling this feature may increase streaming time because file must be processed to detect merged cells before actual stream.
numberFormat standard or excel or object By default standard format is used. Excel implementation of number formatting differs from standard (can be read here) so excel option can be used to match this difference. If custom formatting is needed, a dictionary object can be passed to this option.

getWorksheets

Returns array of sheets with name and hidden info.

Options

Option Type Description
filePath string Path to the XLSX file

Building

You can build js source by using npm run build command.

Testing

Tests can be run by using npm test command.

You might also like...

🌍📖 A readable, automated, and optimized (5 kb) internationalization for JavaScript

Linguijs 🌍 📖 A readable, automated, and optimized (5 kb) internationalization for JavaScript Documentation · Documentation 2.x · Quickstart · Exampl

Jan 2, 2023

Send encrypted and decrypted messages with verifiable keys and human readable names.

Send encrypted and decrypted messages with verifiable keys and human readable names.

zooko-msg Encrypt and decrypt messages using AES with a preshared ECDH key generated using keys associated with Handshake names. I noticed that there

Jul 27, 2022

Convert JSON to human readable HTML

json.human.js: Json Formatting for Human Beings A small library to convert a JSON object into a human readable HTML representation that is easy to sty

Dec 3, 2022

Render readable & responsive tables in the terminal

terminal-columns Readable tables for the terminal. Tables can be automatically responsive! Features Content wrapped to fit column width Column widths

Oct 28, 2022

⏱ Simple Alpine.js plugin to display the human-readable distance between a date and now.

⏱ Alpine TimeAgo ⏱ An Alpine.js plugin to return the distance between a given date and now in words (like "3 months ago", "about 2 hours ago" or "in a

Dec 22, 2022

A typography stylesheet for readable content

A typography stylesheet for readable content

yue.css yue.css is a typography stylesheet for readable content. It was created for my blog at first since I always designed a new theme for my blog.

Dec 22, 2022

A compiled-away, type-safe, readable RegExp alternative

🦄 magic-regexp A compiled-away, type-safe, readable RegExp alternative ✨ Changelog 📖 Documentation ▶️ Online playground Features Runtime is zero-dep

Jan 8, 2023

Enhanced interval features for Node.js, such as promisified interval and human readable time parsing.

Interval-next Interval-next is a package that extends Javascript's built-in setInterval() capabilities. You have a plain and promisified interval meth

Jul 28, 2022

Library for readable and manageable Next.js middleware

🧵 Next Compose Middleware This is a library for building Next.js complex middleware declaratively. You can create highly readable and manageable midd

Dec 19, 2022

parses human-readable strings for JavaScript's Temporal API

🕑 temporal-parse What is the temporal-parse? Temporal is the next generation of JavaScript's standard Date API. It's currently proposed to TC39 (see:

Jan 2, 2023

Minimalistic configuration for TS to only extend JS with types. No TS features, no bundling. Readable maintainable code after compilation.

Minimalistic configuration for TS to only extend JS with types. No TS features, no bundling. Readable maintainable code after compilation.

ts-guideline Minimalistic configuration for TS to only extend JS with types. No TS-scpecific features, no bundling. Readable maintainable code after c

Dec 22, 2022

Wrap zod validation errors in user-friendly readable messages

zod-validation-error Wrap zod validation errors in user-friendly readable messages. Features User-friendly readable messages, configurable via options

Dec 23, 2022

Svelte component to display time distances in a human readable format.

Time Distance Display time distances in a human readable format. Based on date-fns Updates every 60 seconds View demo Usage Install package: pnpm i -D

Nov 2, 2022

easier than regex string matching patterns for urls and other strings. turn strings into data or data into strings.

url-pattern easier than regex string matching patterns for urls and other strings. turn strings into data or data into strings. This is a great little

Jan 5, 2023

Home Assistant custom component for viewing IP cameras RTSP stream in real time using WebRTC technology

Home Assistant custom component for viewing IP cameras RTSP stream in real time using WebRTC technology

Home Assistant custom component for viewing IP cameras RTSP stream in real time using WebRTC technology

Jan 4, 2023

tar-stream is a streaming tar parser and generator.

tar-stream tar-stream is a streaming tar parser and generator and nothing else. It is streams2 and operates purely using streams which means you can e

Jan 3, 2023

Highly performant JavaScript data stream ETL engine.

bellboy Highly performant JavaScript data stream ETL engine. How it works? Bellboy streams input data row by row. Every row, in turn, goes through use

Dec 16, 2022

torrent-stream + chromecast

peercast torrent-stream + chromecast npm install -g peercast Usage Be on the same wifi as your chromecast and do peercast magnet:?xt=urn:btih:99feae0

Dec 15, 2022
Comments
  • Bump decode-uri-component from 0.2.0 to 0.2.2

    Bump decode-uri-component from 0.2.0 to 0.2.2

    Bumps decode-uri-component from 0.2.0 to 0.2.2.

    Release notes

    Sourced from decode-uri-component's releases.

    v0.2.2

    • Prevent overwriting previously decoded tokens 980e0bf

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.1...v0.2.2

    v0.2.1

    • Switch to GitHub workflows 76abc93
    • Fix issue where decode throws - fixes #6 746ca5d
    • Update license (#1) 486d7e2
    • Tidelift tasks a650457
    • Meta tweaks 66e1c28

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.1

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
Releases(v.2.5.2)
  • v.2.5.2(Apr 8, 2022)

  • v.2.5.1(Dec 1, 2021)

  • v.2.5.0(Nov 24, 2021)

  • v.2.4.0(Jul 16, 2021)

  • v.2.3.4(Jun 7, 2021)

  • v.2.3.3(May 27, 2021)

    • Fixed header containing undefined values not being correctly parsed. Now if withHeader option is enabled and undefined values in header are found, column will be named by it's letter.
    Source code(tar.gz)
    Source code(zip)
  • v.2.3.2(Dec 17, 2020)

  • v.2.3.1(Nov 22, 2020)

  • v.2.3.0(Oct 20, 2020)

    • Added numberFormat option which allows to choose which number formatting to use:
      • standard - used by default;
      • excel - number formatting used by Excel;
      • Custom dictionary object where key is the format that needs to be overriden and value is the new format to use.
    Source code(tar.gz)
    Source code(zip)
  • v.2.2.0(Sep 23, 2020)

    • Support files created by OpenXML (where tags are prefixed with x namespace) #27.
    • Fix incorrect mapping of sheets. Now they are mapped by internal XLSX rId.
    • Fix exception if styles.xml is missing.
    Source code(tar.gz)
    Source code(zip)
  • v.2.1.2(Sep 10, 2020)

  • v.2.1.1(Aug 14, 2020)

    • Fix incorrect parsing of cell with leading zeroes #21.

    Having this table 0000 | 0 -- | --

    before fix resulted in:

    {
      raw: { obj: { A: 0, B: 0 }, arr: [ 0, 0 ] },
      formatted: { obj: { A: 0, B: 0 }, arr: [ 0, 0 ] },
      header: []
    }
    

    and after:

    {
      raw: { obj: { A: '0000', B: 0 }, arr: [ '0000', 0 ] },
      formatted: { obj: { A: '0000', B: 0 }, arr: [ '0000', 0 ] },
      header: []
    }
    
    Source code(tar.gz)
    Source code(zip)
  • v.2.1.0(Jul 28, 2020)

  • v.2.0.1(Jun 13, 2020)

  • v.2.0.0(May 22, 2020)

    BREAKING CHANGES

    • getWorksheets emits now object with name and hidden fields instead of simple string.

    Before:

    const sheets = await getWorksheets({
        filePath: './sheet.xlsx',
    });
    console.log(sheets); // ["Sheet1", "Sheet2"]
    

    After:

    const sheets = await getWorksheets({
        filePath: './sheet.xlsx',
    });
    console.log(sheets); // [{ "name": "Sheet1", "hidden": false }, { "name": "Sheet2", "hidden": false }]
    
    Source code(tar.gz)
    Source code(zip)
  • v1.3.0(Apr 10, 2020)

  • v1.2.0(Apr 9, 2020)

    • Header uniqueness. Now, if duplicated header name is found, column name will be prepended with column letter to maintain uniqueness.
    • Added fillMergedCells option. If true, merged cells will have the same value (by default, only the first cell of merged cells is filled with value). Warning! Enabling this feature may increase streaming time because file must be processed to detect merged cells before actual stream.
    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Feb 21, 2020)

Owner
Claviz
Claviz
Creates a button that turns into a progress bar with a elastic effect. Based on the Dribbble shot "Download" by xjw

Elastic Progress Creates a button that turns into a progress bar with a elastic effect. Based on a Dribbble shot by xjw. By Lucas Bebber. Article on C

Codrops 876 Jan 1, 2023
curtains.js is a lightweight vanilla WebGL javascript library that turns HTML DOM elements into interactive textured planes.

What is it ? Shaders are the new front-end web developpment big thing, with the ability to create very powerful 3D interactions and animations. A lot

Martin Laxenaire 1.4k Jan 1, 2023
An extension that scraps a khan academy unit and turns it into a notion todo.

The K-N Extension What is this? This extension injects a javascript file to the Khan academy website, and it adds a "Copy" button to every Khan academ

Abdulrhman Jalal 2 Jun 2, 2022
jsonrawtoxlsx is library to convert json raw (array) into xlsx file

Welcome to jsonrawtoxlsx ?? ✨ What is jsonrawtoxlsx? jsonrawtoxlsx is library to convert json raw (array) into xlsx file ⚡️ Installation using npm npm

M Arie Syukron 17 Dec 23, 2022
Tooling to automate converting .xlsx localisation to in-game compatible .json files for Vampire Survivors

vampire-survivors-localisation This tooling is used to automate converting .xlsx localisation to in-game compatible .json files for the game Vampire S

null 17 Dec 8, 2022
Import flow for Excel (.xlsx) and CSV file with automated column matching and validation.

RSI react-spreadsheet-import ⚡️ A component used for importing XLS / XLSX / CSV documents built with Chakra UI. Import flow combines: ?? Uploader ⚙️ P

Ugnis 123 Dec 24, 2022
🐥 A very simple way to transform antd table to xlsx

antd-table-2-xlsx antd-table-2-xlsx A very simple way to transform antd table to xlsx . Get Start! Install pnpm add @sudongyuer/antd-table-2-xlsx Usa

Frozen FIsh 18 Aug 15, 2022
This is a Tic Tac Toe game built with HTML, CSS, and JavaScript. It is a simple and fun game where two players take turns marking X and O on a 3x3 grid.

Tic Tac Toe Game This is a Tic Tac Toe game built with HTML, CSS, and JavaScript. It is a simple and fun game where two players take turns marking X a

Andrew Tsegaye 4 Mar 4, 2023
Turn your ES5 code into readable ES6. Lebab does the opposite of what Babel does.

Lebab Lebab transpiles your ES5 code to ES6/ES7. It does exactly the opposite of what Babel does. If you want to understand what Lebab exactly does, t

Lebab 5.5k Dec 31, 2022
⛲ Sort import declarations into a pleasing and readable cascade.

⛲ eslint-plugin-cascading-imports This plugin allows to automatically enforce a visual "cascading" order for import declarations. Imports in each bloc

Florent 1 Jan 20, 2022