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

clear-excel

v1.0.5

Published

Safely remove drawings, comments, and embedded objects from XLS, XLSX, and XLSM workbooks.

Readme

clear-excel

Remove images, drawings, comments, controls, and embedded objects from .xls, .xlsx, and .xlsm workbooks. Cell values, formulas, merged cells, worksheets, and used styles are preserved. Unused styles are also removed from .xlsx and .xlsm workbooks.

Install

npm install clear-excel

Requires Node.js 22 or newer. ESM only; TypeScript declarations are included.

Usage

Files

import { sanitizeExcelFile } from "clear-excel";

await sanitizeExcelFile("report.xlsx", "report.cleaned.xlsx");

sanitizeExcelFile(inputPath, outputPath, options?) returns Promise<void>. Input and output must refer to different files and use the same supported extension (.xls, .xlsx, or .xlsm, case-insensitive). The output directory must already exist. To replace an existing output file, set overwrite: true.

Buffers

import { readFile, writeFile } from "node:fs/promises";
import { sanitizeExcel } from "clear-excel";

const input = await readFile("report.xlsx");
const output = await sanitizeExcel(input);
await writeFile("report.cleaned.xlsx", output);

sanitizeExcel(buffer, options?) accepts a Node.js Buffer and returns Promise<Buffer>. The input buffer is not modified; the output keeps the original workbook format.

Filename checks

The package also exports isExcelFilename(name) for .xls, .xlsx, and .xlsm, and isXlsxFilename(name) for .xlsx only. Both return a boolean, ignore case, and check the extension without reading the file.

Options

| Option | Default | Description | | ------------------------ | ---------------- | ------------------------------------------------------- | | requireSingleWorksheet | false | Reject workbooks that do not contain exactly one sheet. | | limits | DEFAULT_LIMITS | Override individual size and entry-count limits. | | overwrite | false | Replace an existing output; sanitizeExcelFile only. |

import { sanitizeExcelFile } from "clear-excel";

await sanitizeExcelFile("report.xlsx", "report.cleaned.xlsx", {
  overwrite: true,
  requireSingleWorksheet: true,
  limits: {
    maxUncompressedBytes: 128 * 1024 * 1024,
  },
});

Limits

The exported DEFAULT_LIMITS contains these defaults. Only specified values are overridden; each must be a positive safe integer. Sizes are in bytes.

| Limit | Default | | -------------------------- | ---------------------------: | | maxEntryCount | 10,000 entries | | maxUncompressedBytes | 512 MiB | | maxXmlBytes | 512 MiB aggregate XML reads | | maxWorksheetXmlBytes | 256 MiB per worksheet | | maxStylesXmlBytes | 64 MiB | | maxMetadataXmlBytes | 16 MiB per metadata part | | maxRelationshipsXmlBytes | 8 MiB per relationships part |

For .xls, only maxEntryCount and maxUncompressedBytes apply. XML limits apply to .xlsx and .xlsm.

Errors

Both sanitizing functions reject with ExcelSanitizationError. Check code instead of matching the error message. details contains additional context when available, and cause holds the original error when one exists.

import { ExcelSanitizationError, sanitizeExcelFile } from "clear-excel";

try {
  await sanitizeExcelFile("report.xlsx", "report.cleaned.xlsx");
} catch (error) {
  if (error instanceof ExcelSanitizationError) {
    console.error(error.code, error.details);
  }
  throw error;
}

| Code | Meaning | | --------------------------- | ---------------------------------------------------- | | ERR_INVALID_ARGUMENT | An argument or option has an invalid type or value. | | ERR_UNSUPPORTED_EXTENSION | Paths use an unsupported or mismatched extension. | | ERR_INVALID_XLS | The XLS workbook is malformed or unsupported. | | ERR_INVALID_XLSX | The XLSX/XLSM workbook is malformed or unsupported. | | ERR_LIMIT_EXCEEDED | A configured size or entry-count limit was exceeded. | | ERR_WORKSHEET_COUNT | Exactly one worksheet was required. | | ERR_SAME_PATH | Input and output refer to the same file. | | ERR_OUTPUT_EXISTS | Output exists and overwrite is false. | | ERR_FILE_READ | The input could not be read. | | ERR_FILE_WRITE | The output could not be written. |

Limitations

  • .xls input must use Excel 97–2003 BIFF8. Encrypted .xls files are not supported.
  • VBA macros are preserved. The library does not execute macros or evaluate formulas.
  • Workbooks are processed in memory. Memory usage can exceed the input size, especially when increasing limits.

License

MIT