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

html-to-xlsx-styled

v1.0.0

Published

Export HTML <table> elements to styled .xlsx workbooks (merges, CSS styles) using xlsx-js-style.

Readme

html-to-xlsx-styled

Convert an HTML <table> into a styled .xlsx workbook. Cell merges (rowspan / colspan), text content, and CSS-derived cell styles are mapped to Excel using xlsx-js-style.

Install

npm install html-to-xlsx-styled

Peer expectation: use this in environments where you can obtain a real HTMLTableElement (browser DOM, or a DOM implementation such as jsdom in Node).

Quick start (browser)

<table id="data">
  <tr><th>Name</th><th>Score</th></tr>
  <tr><td>Ada</td><td>100</td></tr>
</table>
import { exportHtmlTableToExcel } from 'html-to-xlsx-styled';

const table = document.getElementById('data');

// Get a Blob (default in browsers) and optionally trigger download
const blob = exportHtmlTableToExcel(table, {
  sheetName: 'Results',
  download: true,
  fileName: 'results.xlsx',
});

API

exportHtmlTableToExcel(table, options?)

Serializes the table to .xlsx bytes.

  • Returns — By default: a Blob when Blob exists (typical browser), otherwise Uint8Array. Override with outputType.
  • Options (ExportOptions):
    • sheetName — Excel sheet name (invalid characters are sanitized; max length enforced).
    • fileName — Used when download is true (default file name: export.xlsx).
    • download — If true, starts a browser download via a temporary object URL. Requires document and URL.createObjectURL; otherwise throws ExcelTableExportError with code DOM_REQUIRED. The function still returns the same binary result as when download is false.
    • useComputedStyles — When true (default), styles are taken from computed CSS. Set to false to rely on inline styles only (faster, fewer dependencies on full layout).
    • includeEmptyCellsStyles — When true, cells with no text but with visible styling may be written so formatting is preserved. Default false.
    • outputType'blob' | 'arrayBuffer' | 'uint8Array'. If you need bytes in Node or without Blob, use 'uint8Array' or 'arrayBuffer'.

createWorkbookFromTable(table, options?)

Builds an xlsx-js-style WorkBook from the table. Use this when you want to merge sheets, post-process cells, or write the file yourself instead of using exportHtmlTableToExcel.

import * as XLSX from 'xlsx-js-style';
import { createWorkbookFromTable } from 'html-to-xlsx-styled';

const wb = createWorkbookFromTable(table, { sheetName: 'Sheet1' });
const buf = XLSX.write(wb, { bookType: 'xlsx', type: 'array', cellStyles: true });

ExcelTableExportError

Thrown for invalid input or unsupported environment behavior. Inspect error.code:

| Code | Meaning | |-------------------|---------| | INVALID_TABLE | Value is not an HTML table element. | | DOM_REQUIRED | Operation needs a browser DOM (e.g. download: true without document / URL). | | NOT_IMPLEMENTED | Reserved. | | UNKNOWN | Other errors (e.g. unsupported outputType). |

Node / tests

Provide a HTMLTableElement from your DOM library of choice (for example jsdom):

import { JSDOM } from 'jsdom';
import { exportHtmlTableToExcel } from 'html-to-xlsx-styled';

const { window } = new JSDOM(`<table><tr><td>hi</td></tr></table>`);
const table = window.document.querySelector('table');

const bytes = exportHtmlTableToExcel(table, {
  outputType: 'uint8Array',
  useComputedStyles: false,
});

License

ISC