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

@onparallel/write-excel-file-hide-sheets

v0.1.0

Published

Hide sheets custom feature for write-excel-file

Readme

@onparallel/write-excel-file-hide-sheets

Hide-sheets custom feature for write-excel-file.

Adds support for marking entire sheets as hidden in the generated .xlsx, without requiring a fork of the base package. Hidden sheets are preserved in the file (Excel users can right-click the tab strip → "Unhide" to reveal them); they are not deleted.

Install

npm install write-excel-file @onparallel/write-excel-file-hide-sheets

write-excel-file is a peer dependency (^4.0.0). The package is published publicly under the @onparallel scope — no authentication required to install.

Usage

Register the feature when calling writeXlsxFile(). write-excel-file/node's built-in Sheet type does not know about hidden, so intersect it with the HideSheetsSheetOptions type exported by this package:

import writeXlsxFile, { type Sheet } from "write-excel-file/node";
import hideSheets, { type HideSheetsSheetOptions } from "@onparallel/write-excel-file-hide-sheets";

const sheets: (Sheet<any> & HideSheetsSheetOptions)[] = [
  { sheet: "Visible", data: [["shown"]] },
  { sheet: "Hidden", data: [["not shown"]], hidden: true },
];

await writeXlsxFile(sheets, { features: [hideSheets] }).toFile("out.xlsx");

If you use the intersection in many places, alias it locally: type MySheet = Sheet<any> & HideSheetsSheetOptions.

Why not module augmentation? write-excel-file/node re-exports its types with export type { ... }, which TypeScript does not allow downstream packages to augment.

API

export interface HideSheetsSheetOptions {
  hidden?: boolean;
}

Set hidden: true on any sheet you want hidden in the resulting workbook. The default is false (visible).

Limitations

  • At least one sheet must remain visible. Excel requires this — a workbook with every sheet hidden either fails to open or shows a recovery error. If the caller marks every sheet as hidden, this feature does nothing rather than producing a broken file. The base library's output (all sheets visible) is kept as a safe fallback. Validate caller input upstream if you want to surface a clearer error.
  • Browser bundle. Not yet tested against write-excel-file/browser. The feature only patches xl/workbook.xml (a string), so it should work identically — but the examples here only exercise the Node entry point.

How it works

The feature subscribes to the files.write.files hook, which write-excel-file invokes after all worksheet XMLs have been generated. The hook:

  1. Reads xl/workbook.xml via the read callback the library provides.
  2. Adds state="hidden" to each <sheet/> element whose corresponding sheetOptions.hidden is truthy.
  3. When the first sheet is hidden, rewrites <workbookView/> with firstSheet="N" activeTab="N" pointing at the first visible sheet's index. Without this, Excel opens the file targeting a hidden tab and refuses to render it.
  4. Returns the patched XML, which the library writes back over the original.

This stateless, single-hook approach avoids any closure or factory state across calls.

See src/hideSheets.ts for the implementation.

Examples

The examples/ folder contains runnable TypeScript scripts that emit .xlsx files next to themselves. Open the generated files in Excel/Numbers/LibreOffice to confirm the hidden sheets behave as expected.

npm install
npx tsx examples/hide-second-sheet.ts   # run a single example
npm run examples                          # run them all

See examples/README.md for the full list.

Development

npm install
npm test          # vitest
npm run typecheck # tsc --noEmit
npm run build     # emit dist/ via tsc

License

MIT