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

easy-spreadsheet-write

v3.0.4

Published

Easily create spreadsheet files, json to xlsx.

Readme

easy-spreadsheet-write TypeScript heart icon

npm version npm downloads Codecov Bundlejs TypeDoc

Overview

easy-spreadsheet-write's main goal is to help you easily create spreadsheet files, with modern DX and type safety.

This package currently wraps on top of sheetjs to provide the functionalities.

Features

  • 👌 TypeScript

Usage

Install package

# npm
npm install easy-spreadsheet-write

# bun
bun add easy-spreadsheet-write

# pnpm
pnpm install easy-spreadsheet-write

Import and use

Basic usage:

import { constructWorkbook, writeFile } from 'easy-spreadsheet-write'

writeFile(
  constructWorkbook([{
    content: [{ id: 1, regExp: /a/ }],
    columns: [
      ['ID', 'id'],
      ['RegExp string', e => e.regExp.toString()],
    ],
  }]),
  {
    fileName: `Some-Magic-RegExps`,
  },
)

A more detailed sample:

// ESM
import { constructWorkbook, ESWOptions, write, writeFile } from 'easy-spreadsheet-write'

const options = {
  fileName: 'MyODS', // extension will be added automatically if not provided
  cellPadding: 3, // In formats that support styling, this is the padding between the cell contents and the cell border.
  RTL: undefined, // Display the columns from right-to-left (defaults `false`)

  // ...sheetjsOptions, // Write options of sheetjs: https://docs.sheetjs.com/docs/api/write-options
  bookType: 'ods', // Defaults to 'xlsx'
} satisfies ESWOptions

const workbook = constructWorkbook(
  [
    {
      sheet: 'Sheet1',
      content: [
        { user: 'Luis', ghUsername: 'LuisEnMarroquin', likes: 99 },
      ],
      // The resolver function `row => ...` will automatically infer the type from `content`
      columns: [
        ['User name', 'user'], // Array syntax
        ['User name (lowercase)', row => row.user.toLowerCase()],
        { label: 'Likes count', value: 'likes' }, // Object syntax
        { label: 'GitHub URL', value: row => `https://github.com/${row.ghUsername}` },
      ],
    },
  ],
  options
)

// Similar to SheetJS's writeFile, this will write the file to disk / trigger a browser download
writeFile(data, options)

// There is a `browserDownloadFile` helper in case you need to defer the download:
const ssData = write(data, options)
// You'll have to construct a File object and provide the fileName with extension.
browserDownloadFile(new File([ssData], 'fileName.ext'))

More details

You can check the TypeDoc, or simply just hover around the functions and read the hint in your IDE.

Notes

Sheets type inference constraining / limitation

If you use multiple sheets, or you want to constraint the type of the sheet, follow this example:

// Set `<any>` for constructWorkbook to allow different types for the sheets
const workbook = constructWorkbook<any>(
  [
    // Use `defineJsonSheet` to define the sheets
    defineJsonSheet({
      sheet: 'Sheet1',
      content: [
        { what: 'wut' },
      ],
      columns: [
        ['What', 'what'],
      ],
    }),
    // Constrain the type of the sheet to `string` content
    defineJsonSheet<string>({
      sheet: 'Sheet2',
      content: [
        '{"encoded":"sample"}',
      ],
      columns: [
        ['Subject type', row => JSON.parse(row).type],
      ],
    }),
  ],
)

Fork notice and credit

easy-spreadsheet-write is a fork of json-as-xlsx, which I've been using for a while, but it is a bit outdated and the DX isn't as modern as it could be, so I clicked the fork button, heavily rewrite it, updating the toolchain to modern standards, improving the types, adding features, and a new package name which better describes it.

Shoutout to Luis for the original work, I'd love to get this merged to upstream, will open a PR but idk if it would be accepted.

Sample for migration from json-as-xlsx:

// `json-as-xlsx`
xlsx(
  [{
    sheet: 'Main',
    // @ts-expect-error signature error
    content: [{ id: 1, regExp: /a/ }],
    columns: [
      { label: 'ID', value: e => e.id! },
      { label: 'RegExp string', value: (e: any) => e.regExp.toString() },
    ],
  }],
  {
    fileName: `${t('file.seatsReport.name')}`,
    writeOptions: {
      compression: true,
    },
  },
)

// `easy-spreadsheet-write`
// Type casting hacks and ignores are no longer needed and you get correct type inference DX
// compression is also enabled by default to not catch you off-guard and bloat your (client)'s disk
writeFile(
  constructWorkbook([{
    content: [{ id: 1, regExp: /a/ }],
    columns: [
      { label: 'ID', value: e => e.id },
      { label: 'RegExp string', value: e => e.regExp.toString() },
    ],
  }]),
  {
    fileName: `${t('file.seatsReport.name')}`,
  },
)

License

License