npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

xlsb-parser

v1.0.0-rc.2

Published

Pure-JS XLSB (Excel Binary Workbook) parser. No native addons. Works in browsers and Node.js 20+.

Readme

xlsb-parser

Pure-JS XLSB (Excel Binary Workbook) parser. No native addons. Works in browsers and Node.js 20+.

Install

npm install xlsb-parser

Quick start

import { parseXlsb } from 'xlsb-parser';

const buffer = await file.arrayBuffer();
const wb = await parseXlsb(buffer);

console.log(wb.sheets[0].name);                 // → 'Sheet1'
console.log(wb.sheets[0].rows[0].cols[0]);      // → { t: 's', v: 'Hello' }

API

parseXlsb(data, options?)

function parseXlsb(
  data: ArrayBuffer | Uint8Array,
  options?: ParseOptions,
): Promise<ParsedXlsb>;

interface ParseOptions {
  onProgress?: (msg: string, pct: number) => void;
  maxZipBytes?: number;          // throw XlsbSizeError if decompressed > N
  maxRowsPerSheet?: number;      // stop a sheet after N rows
  dumpBinaries?: boolean;         // default false. Populate binaryDumps.
  readXml?: boolean;              // default false. Populate xmlFiles.
  parsePivotCaches?: boolean;    // default false. Spec-driven pivot cache decoder.
}

Backwards compat (deprecated 1.x only): passing a function as the 2nd arg is treated as onProgress. This form will be removed at 2.0.

Returns ParsedXlsb:

| Field | Type | Description | |-------|------|-------------| | sheets | Sheet[] | Worksheets (parsed lazily when using openXlsb) | | sharedStrings | string[] | All shared strings | | styles | StylesTable \| null | Cell style table (since 1.0) | | pivotCaches | PivotCacheTable[] | Pivot caches (opt-in via parsePivotCaches: true). Each entry has .name, .fieldNames (deprecated), .rows, .fields (PivotCacheField[] with correct kind/sharedItems), .summary. | | binaryDumps | BinaryDump[] | Debug record dumps (opt-in via dumpBinaries: true) | | xmlFiles | Record<string, string> | Raw XML/rels content (opt-in via readXml: true) | | summary | { fileCount, totalRecords } | Counts |

openXlsb(data, options?) — streaming handle

For huge sheets, use the streaming API to iterate rows lazily without buffering the whole sheet:

import { openXlsb } from 'xlsb-parser';

const handle = await openXlsb(buffer);
console.log(handle.sheetNames);             // ['Sheet1', 'Sheet2']

for await (const row of handle.iterSheetRows(0)) {
  // Process one row at a time. Memory: O(cells per row), not O(total rows).
  console.log(row.row, Object.keys(row.cols).length);
  if (row.row > 1000) break;                  // stop early if you want
}

// Or drain an entire sheet (still streams internally):
const sheet = await handle.collectSheet(0);

iterSheetRows(index, { maxRows?, onProgress? }) accepts an optional cap.

When parsePivotCaches: true was passed at open time, the handle also exposes pivot cache metadata and streaming:

  • handle.pivotCachesPivotCacheSummary[] with eager field definitions.
  • handle.iterPivotCacheRows(indexOrName, { maxRows?, onProgress? }) — async generator yielding PivotCacheCell[] rows, O(cells-per-row) memory.
  • handle.collectPivotCache(indexOrName) — drain the full cache into a PivotCacheTable.

Cell type

interface Cell {
  t: 'n' | 's' | 'b' | 'e' | 'blank' | 'f';
  v?: number | string | boolean;
  err?: string;                  // present when t === 'e'
  ixf?: number;                  // signed iStyleRef into the cellXfs table
  numFmtId?: number;             // numeric format ID (since 1.0)
  isDate?: boolean;              // true when numFmtId is a date/time format
  dateValue?: string;            // ISO 8601 string when isDate && t === 'n'
}

| t | Meaning | v type | |-----|---------|----------| | n | Number | number | | s | String | string | | b | Boolean | boolean | | e | Error | err: string | | blank | Empty | undefined |

When xl/styles.bin is present, numeric cells whose style is a date format get numFmtId, isDate: true, and dateValue (ISO 8601). The raw serial number is preserved in v — no silent type coercion.

const cell = wb.sheets[0].rows[0].cols[0];
// cell = { t: 'n', v: 44927, numFmtId: 14, isDate: true, dateValue: '2023-01-01T00:00:00.000Z' }

XlsbSizeError

Thrown when maxZipBytes or maxRowsPerSheet caps are exceeded. Subclass of Error with .limit and .actual fields so callers can differentiate "too big" from "broken".

Browser

<script type="module">
import { parseXlsb } from './node_modules/xlsb-parser/dist/index.js';
</script>

A pre-built demo bundle lives in examples/browser-demo/. Run it with npm run dev.

CLI (quick inspection)

node -e "import { parseXlsb } from 'xlsb-parser'; import { readFileSync } from 'fs';
const w = await parseXlsb(readFileSync(process.argv[2]));
w.sheets.forEach(s => console.log(s.name, s.rows.length + ' rows'));" file.xlsb

Limitations

  • Pivot caches (opt-in): now spec-driven (MS-XLSB §2.1.7.38/§2.1.7.39) for non-OLAP caches. OLAP/slicer/timeline/server-formatting caches remain best-effort.
  • No streaming unzip: openXlsb() streams rows, but the ZIP step itself is buffered. For files >1 GB consider pre-decompressing. Use maxZipBytes to refuse oversized inputs.
  • Rich-text formatting runs: cell strings decode correctly but formatting runs (italic, bold, color) are discarded — only the text is returned.
  • Date detection is heuristic: built-in date format IDs (14–22, 27–36, 45–47, 50–58, 78–81) plus custom format strings containing d/m/y/ h/s outside escapes. Edge cases with unusual custom formats may be missed.

Commands

npm install              # install dependencies
npm run build            # compile TypeScript → dist/
npm run build:browser    # rebuild the browser demo bundle
npm test                 # run tests (vitest)
npm run test:coverage    # tests + coverage gate (90% stmts, 100% funcs)
npm run test:types       # compile-time type assertions
npm run lint             # eslint
npm run format           # biome format (write)
npm run dev              # build browser bundle + serve demo on :8080

License

MIT