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 🙏

© 2025 – Pkg Stats / Ryan Hefner

wasm-xlsxwriter

v0.6.2

Published

The `wasm-xlsxwriter` library is a lightweight wrapper around the write API of Rust's [`rust_xlsxwriter`](https://crates.io/crates/rust_xlsxwriter), compiled to WebAssembly (Wasm) with minimal setup to make it easily usable from JavaScript or Node.js.

Downloads

1,891

Readme

wasm-xlsxwriter NPM Version

The wasm-xlsxwriter library is a lightweight wrapper around the write API of Rust's rust_xlsxwriter, compiled to WebAssembly (Wasm) with minimal setup to make it easily usable from JavaScript or Node.js.

With this library, you can generate Excel files in the browser or Node.js using JavaScript, complete with support for custom formatting, formulas, links, images, and more.

Getting Started

To get started, install the library via npm:

npm install wasm-xlsxwriter

Usage Web

Here’s an example of how to use wasm-xlsxwriter to create an Excel file:

import xlsxInit, {
  Format,
  FormatAlign,
  FormatBorder,
  Formula,
  Workbook,
  Image,
  Url,
} from "wasm-xlsxwriter/web";

// Load the WebAssembly module and initialize the library.
await xlsxInit();

// Create a new Excel file object.
const workbook = new Workbook();

// Create some formats to use in the worksheet.
const boldFormat = new Format().setBold();
const decimalFormat = new Format().setNumFormat("0.000");
const dateFormat = new Format().setNumFormat("yyyy-mm-dd");
const mergeFormat = new Format()
  .setBorder(FormatBorder.Thin)
  .setAlign(FormatAlign.Center);

// Add a worksheet to the workbook.
const worksheet = workbook.addWorksheet();

// Set the column width for clarity.
worksheet.setColumnWidth(0, 22);

// Write a string without formatting.
worksheet.write(0, 0, "Hello");

// Write a string with the bold format defined above.
worksheet.writeWithFormat(1, 0, "World", boldFormat);

// Write some numbers.
worksheet.write(2, 0, 1);
worksheet.write(3, 0, 2.34);

// Write a number with formatting.
worksheet.writeWithFormat(4, 0, 3.0, decimalFormat);

// Write a formula.
worksheet.write(5, 0, new Formula("=SIN(PI()/4)"));

// Write a date.
const date = new Date(2023, 1, 25);
worksheet.writeWithFormat(6, 0, date, dateFormat);

// Write some links.
worksheet.write(7, 0, new Url("https://www.rust-lang.org"));
worksheet.write(8, 0, new Url("https://www.rust-lang.org").setText("Rust"));

// Write some merged cells.
worksheet.mergeRange(9, 0, 9, 1, "Merged cells", mergeFormat);

// Insert an image (ensure `imageBuffer` contains the image data).
const image = new Image(imageBuffer);
worksheet.insertImage(1, 2, image);

// Save the file to a buffer.
const buf = workbook.saveToBufferSync();

Usage Node.js

import {
  Color,
  DocProperties,
  Format,
  FormatAlign,
  Workbook,
} from "wasm-xlsxwriter";

/**
 * Demo function that create a xlsx buffer from a header array and data rows
 *
 * @param {string[]} header - Sheet header strings
 * @param {(string | number)[][]} rows - Array of arrays containing sheet rows
 * @returns {Buffer} Excel file data
 */
function writeExcel(header: string[], rows: (string | number)[][]): Buffer {
  // Create a new Excel file object.
  const workbook = new Workbook();

  // Set a doc property
  const props = new DocProperties().setCompany("Test, Inc.");
  workbook.setProperties(props);

  // Add a worksheet with name to the workbook.
  const worksheet = workbook.addWorksheet();
  worksheet.setName("Export");

  // Create some formats to use in the worksheet.
  const headerStyle = new Format();
  headerStyle
    .setAlign(FormatAlign.Top)
    .setTextWrap()
    .setBackgroundColor(Color.red());

  // Write sheet header
  worksheet.writeRowWithFormat(0, 0, header, headerStyle);

  // Write sheet data
  worksheet.writeRowMatrix(1, 0, rows);

  // Autofit columns
  worksheet.autofit();

  // Freeze header
  worksheet.setFreezePanes(1, 0);

  // Add autofilter to header
  worksheet.autofilter(0, 0, rows.length, header.length - 1);

  // Return buffer with xlsx data
  const uint8Array = workbook.saveToBufferSync();
  return Buffer.from(uint8Array);
}

License

MIT