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

typesexcel

v1.0.1

Published

TypeScript library for reading and writing Excel (.xlsx) files

Downloads

154

Readme

TypesExcel

npm version npm license TypeScript

TypesExcel is a TypeScript / Node.js library for reading and writing Excel (.xlsx) files. It works directly with the OOXML ZIP structure — no native bindings, no external spreadsheet engine.

The library is built on TypesXML for XML parsing and exposes a simple, strongly typed API for extracting sheet data or generating new workbooks from code, with typed cell values (strings, numbers, booleans, dates) and support for multi-sheet workbooks.

Quick example

Read every sheet from an existing workbook:

import { ExcelReader, ExcelSheetData } from 'typesexcel';

const reader = new ExcelReader('en');
const sheets: ExcelSheetData[] = reader.readSheets('data.xlsx');

for (const sheet of sheets) {
    console.log('Sheet:', sheet.name);
    for (const row of sheet.rows) {
        console.log(row.join('\t'));
    }
}

Or work with a typed ExcelWorkbook (headers separated from data rows):

import { ExcelReader, ExcelWorkbook, ExcelSheet } from 'typesexcel';

const reader = new ExcelReader('en');
const workbook: ExcelWorkbook = reader.readWorkbook('data.xlsx');

for (const sheet of workbook.getSheets()) {
    console.log('Sheet:', sheet.getName());
    console.log('Headers:', sheet.getHeaders());
    for (const row of sheet.getRows()) {
        console.log(row);
    }
}

Write a workbook with multiple sheets and mixed cell types:

import { ExcelSheet, ExcelWorkbook, ExcelWriter } from 'typesexcel';

const employees = new ExcelSheet(
    'Employees',
    ['Name', 'Department', 'Hired', 'Active'],
    [
        ['Alice', 'Engineering', new Date('2021-03-15'), true],
        ['Bob',   'Marketing',   new Date('2022-07-01'), false]
    ]
);

const offices = new ExcelSheet(
    'Offices',
    ['City', 'Headcount'],
    [
        ['Madrid', 12],
        ['Berlin', 7]
    ]
);

const workbook = new ExcelWorkbook([employees, offices]);

const writer = new ExcelWriter('en');
writer.writeFile('output.xlsx', workbook);

ExcelWriter.writeFile() also accepts a single ExcelSheet directly when only one sheet is needed.

Why TypesExcel

  • No native bindings — runs anywhere Node.js runs
  • Lightweight: reads only what is needed from the ZIP (shared strings, sheet XML, relationships, styles)
  • Strongly typed API — cell values are string | number | boolean | Date | null
  • Full multi-sheet support for both reading and writing
  • Built on TypesXML, a strict, W3C-validated XML parser
  • Designed for automation and tooling scenarios (data extraction, report generation, localization pipelines)

Features

  • Read sheets — Extract all worksheets from an .xlsx file, by name, or as a typed ExcelWorkbook
  • Write workbooks — Generate a new .xlsx file from one ExcelSheet or a multi-sheet ExcelWorkbook
  • Typed cell values — Strings, numbers, booleans, and dates are read and written with their native type, not just as strings
  • Hidden sheets skipped — Sheets marked hidden or veryHidden are excluded when reading
  • Column utilities — Convert between column letters (A, B, AA) and zero-based indices
  • Localized error messages — Built-in i18n support for en, es, and fr

Installation

npm install typesexcel

API

ExcelReader

new ExcelReader(language: string)

language selects the locale (en, es, or fr) used for error messages thrown by the reader; it has no effect on the data that is read.

| Method | Description | | ------ | ----------- | | readSheets(filePath: string): ExcelSheetData[] | Reads all worksheets from the given .xlsx file. Returns an array of ExcelSheetData objects, one per sheet. | | readSheet(filePath: string, sheetName: string): ExcelSheetData | Reads a single worksheet by name. Throws if the sheet does not exist. | | readWorkbook(filePath: string): ExcelWorkbook | Reads all worksheets and returns them as a typed ExcelWorkbook, with the first row of each sheet used as headers. | | listSheets(filePath: string): string[] | Returns the names of all visible worksheets without parsing their data. |

Hidden and very-hidden sheets are skipped by all of the methods above.

ExcelSheetData

interface ExcelSheetData {
    name: string;        // worksheet name as it appears in the workbook
    rows: CellValue[][]; // all rows including the header row, each cell typed
}

CellValue

type CellValue = string | number | boolean | Date | null;

Dates are recognized from the cell's number format (built-in and custom date formats) and converted to Date instances; empty cells are null.

ExcelSheet

new ExcelSheet(name: string, headers: string[], rows: CellValue[][])

| Method | Description | | ------ | ----------- | | getName(): string | Returns the sheet name. | | getHeaders(): string[] | Returns the header row. | | getRows(): CellValue[][] | Returns the data rows (not including the header). |

ExcelWorkbook

new ExcelWorkbook(sheets: ExcelSheet[] = [])

| Method | Description | | ------ | ----------- | | addSheet(sheet: ExcelSheet): void | Appends a sheet to the workbook. | | removeSheet(name: string): void | Removes the sheet with the given name, if present. | | getSheet(name: string): ExcelSheet \| undefined | Returns the sheet with the given name. | | getSheets(): ExcelSheet[] | Returns all sheets in the workbook. |

ExcelWriter

new ExcelWriter(language: string)

language selects the locale (en, es, or fr) used for error messages thrown by the writer; it has no effect on the workbook that is generated.

| Method | Description | | ------ | ----------- | | writeFile(filePath: string, data: ExcelSheet \| ExcelWorkbook): void | Writes a workbook to filePath. Accepts either a single ExcelSheet or a multi-sheet ExcelWorkbook. |

Strings, numbers, booleans, and dates are written with the correct cell type and, for dates, a date number format.

ColumnUtils

| Method | Description | | ------ | ----------- | | columnName(index: number): string | Converts a zero-based column index to a column letter (0A, 26AA). | | columnIndex(name: string): number | Converts a column letter to a zero-based index (A0, AA26). |

License

Eclipse Public License 1.0