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

easy-excel-exporter

v1.0.1

Published

This NodeJS module can be used to create an Excel spreadsheets with set of header row and data rows.

Downloads

12

Readme

About

This NodeJS module can be used to create Excel spreadsheets. Every cell has its own datatype associated with it, and a value assigned for that cell.

Initialization

var EasyExcelExporter = require('easy-excel-exporter');
var excelAdapter      = EasyExcelExporter(options);

options will be used to re-initialize default option values used to create Excel Spreadsheet.

options : {
  sheetName : 'sheet-name', // String value for assigning your own Sheet Name.
  fileName  : 'test-file', // String value for assigning a name for the Excel file created.
  autoCast  : true // Boolean value that will indicate whether to type cast values for cells or not(Default : false).
  path : '/<<file-path>>/' // String value to define your own storage path where the excel file will be saved.
}

Methods

easy-excel-exporter provides three methods. All these return a promise.

createColumns(excelHeaders)

This function creates a row in your Excel spreadsheet which contains the values of the column names as specified in excelHeaders.

excelAdapter.createColumns(excelHeaders);

excelHeaders is an array of objects with name of column specified as "columnName" and its associated dataType specified as "dataType".E.g.:

var excelHeaders = [{
  columnName: 'Name',
  dataType: EasyExcelExporter.dataType.String
}, {
  columnName: 'Age',
  dataType: EasyExcelExporter.dataType.Number
}, {
  columnName: 'Profile',
  dataType: EasyExcelExporter.dataType.Object
}]

supported datatypes

easy-excel-exporter provides static method EasyExcelExporter.dataType and supports these below mentioned types:object, string, number, boolean, date.

EasyExcelExporter.dataType.String  // for string dataType
EasyExcelExporter.dataType.Object  // for object dataType
EasyExcelExporter.dataType.Boolean // for boolean dataType
EasyExcelExporter.dataType.Number  // for number dataType
EasyExcelExporter.dataType.Date    // for date dataType

Once your columns have been set in the Excel spreadsheet, it will return a Promise.

addObjects(rows)

This function iterates through rows, which is an array of objects provided as an argument. Each object will be treated as a row in the Excel Spreadsheet.

rows = [{
  Name : "abc",
  Age : 22,
  Profile : {}
}]

excelAdapter.addObjects(rows);

This function will return an index of the last row created in the Excel Spreadsheet.

NOTE: Objects are always stringified when they are added to cells.

downloadFile()

This function will return a downloadable stream of the Excel spreadsheet, created at the default storage path or, the path specified in options while creating an instance of easy-excel-exporter.

excelAdapter.downloadFile();

Features

autocast option

If you set autocast option as true while creating easy-excel-exporter instance, value for that cell will be typecasted to the dataType of the column mentioned while creating spreadsheet columns.If typecast fails, then the cell will contain a null value. Default value for autocast is false which means that the dataType provided while creating columns will be ignored when Excel cell is being added for that corresponding column.