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 🙏

© 2024 – Pkg Stats / Ryan Hefner

xlsx-plus

v0.3.0

Published

A wrapper for js-xlsx with an improved API

Downloads

5

Readme

xlsx-plus

A wrapper for js-xlsx with a simpler API. Can be used as a dropin.

npm install xlsx-plus

Versions for the browser are in the dist folder. There is the core version, which is a smaller file, and the full version, which includes ODS and international support.

It supports Promise-based I/O. Bring your own Promise (assumes the presence of a correctly-implemented Promise global).

Changes

Top-level API

The entire XLSX top-level API is copied, with some changed and additions:

read(data, [options])

Returns a Workbook object; each sheet is a Worksheet object

readFile(filename, [options], [cb])

Supports an asynchronous signature while retaining support for operating synchronously

readFileAsync(filename, [options], [cb]) (added v0.3.0)

Explicitly asynchronous version. If the callback is not supplied it returns a Promise (requires Promise global).

writeFileAsync(filename, wb, [options], [cb])

writeFileAsync(wb, filename, [options], [cb]) (added v0.3.0)

Returns a Promise if callback is not passed. Also supports passing a Workbook object as the first parameter, to match the built-in writeFile(wb, filename, [options]).

Utils

utils is duplicated as util.

  • extra function cell_in_range

  • encode_cell accepts an object with string keys as well

Worksheet API

Exported as XLSX.Worksheet.

constructor(data, name, workbook)

Accepts data as an XLSX-style object (with a !ref property), an array of arrays, or an array of objects.

getCell(address)

Returns the cell object with that address.

getRow(row)

Returns a Row object.

getCol(col)

Returns a Column object.

getRange(range)

Returns a subset Worksheet. Keeps references to the original workbook and name.

toJSON(opts)

Exports the sheet as JSON. The default format is to use the first row as a header. To use column names as a header, pass {header: 'A'}. To use custom values, pass {header: ['col1 header', 'col2 header']}. The exported format is: [{'col1 header': B1Value, 'col2 header': B2Value}, ...]. For an object of arrays ({col1: [B1, C1, ...], col2: [...]}), pass {array: false} (any falsey value).

It automatically transforms values to their primitive formats. To disable this, pass {raw: false}.

toArray(opts)

Like toJSON, but returns an array of arrays instead of an array of objects. So: [[A1Value, A2Value], [B1Value, B2Value], ...].

toCSV(opts)

Returns a CSV string of the worksheet. Default delimiter is a comma; default row ending is a newline. You can change this by passing {delimiter: '\t', line: '\r\n'} (for example).

Workbook API

Not much. Only contains wrappers for toJSON and toArray. toJSON gives an object with the sheet names as keys; toArray gives an array of sheets. The values are the result of calling toJSON or toArray on the sheet object.

getSheet(nameOrIndex) (added v0.3.0)

Return the sheet with the given name or index. So you can do getSheet(0) to get the first one.

addSheet(sheet) (added v0.1.2)

Adds a Worksheet object to the workbook.

As of v0.3.0, if the sheet does not have a name, it will be given a default name (SheetN).

Row and Column object API

Both are subclasses of a Data class; neither are exported.

get(address)

Returns the cell object at the given row or column (depending on datatype) if address is a string. If address is a number, treat it as a numerical index.

getValues()

Returns an array of cell values.

License

MIT

Maintenance Notes

This is just the bare bones of the library now. I needed this much for a project, and don't have time to continue working on it past this. Pull requests are appreciated.

Credits

Made by Eyal Schachter (Scimonster).

Developed for David Burg, PhD at the Shamir Research Institute.