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

xlr

v0.5.1

Published

Simple data set export to Excel xlsx file

Downloads

24

Readme

XLR

Code Climate

A simple node module for exporting a data set to an Excel xlsx file.

Heavily inspired by Node-Excel-Export

Using XLR

Example of a config object to generate a Excel worksheet

{
  name: 'name.xlsx',
  columns: [
    {
      type: 'string',
      width: 10,
    }
  ],
  rows: [],
  merge: []
  stylesXmlFile: 'styles.xml'
}
  • name: Specify worksheet name
  • columns: Array of column definitions
    • type: string / date / bool / number
    • width: (optional) total characters in cell
  • rows: Array of data to be exported. Data needs to be a 2D-Array and should be the same length as the columns array.
  • merge: Array of merge cell objects.
    • row: row index (starting at 1)
    • fromColumn: start the merge from column index (starting at 1)
    • toColumn: end the merge at column index (starting at 1)
  • stylesXmlFile: Absolute path to Excel styles.xml file. An easy way to get a styles.xml file is to unzip an existing xlsx file which has the desired styles and copy the styles.xml file.

Example usage with Express

const express = require('express');
const xlr = require('xlr');
const app = express();

app.get('/', function (req, res) {
  const conf = {
    stylesXmlFile: __dirname + '/styles.xml',
    name: 'report-is-a-thing',
    cols: [
      {
        caption: '',
        type: 'string',
        width: 15
      },
      {
        caption: '',
        type: 'string',
        width: 25
      },
      {
        caption: '',
        type: 'string',
        width: 30
      }
    ],
    rows: [
      [{ value: 'First Name', style: 1 }, { value: 'Last Name', style: 1 }, { value: 'Email', style: 1 }],
      ['Bruce', 'Wayne', '[email protected]'],
      ['Clark', 'Kent', '[email protected]'],
      ['This cell is going to be merged', '', '[email protected]'],
      ['Peter', 'Parker', '[email protected]']
    ],
     merge: [
      { row: 4, fromColumn: 1, toColumn: 2 } 
    ]
  };

  const result = xlr(conf);
  res.setHeader('Content-Type', 'application/vnd.openxmlformats');
  res.setHeader('Content-Disposition', 'attachment; filename=Report.xlsx');
  res.send(new Buffer(result, 'binary'));
});

app.listen(3001, function () {
  console.log('listening on port 3001');
});

License

XLR is © 2017 MADE Code PTY Ltd. It is free software, and may be redistributed under the terms specified in the LICENSE file.

Maintained by

madeagency

XLR was created and is maintained MADE Agency PTY Ltd. The names and logos for MADE Code are trademarks of MADE Code PTY Ltd.

We love open source software. See our Github Profile for more.

We're always looking for talented people who love programming. Get in touch with us.