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

export-to-excel.js

v2.0.5

Published

An easy to use package to export your data into nice xls file.

Downloads

188

Readme

Excel Export Service Package

An easy to use package to export your data into nice xls file. Be aware that this package send axios requests to an external server so you must be connected to the net, and it might take few seconds.

Install

npm install export-to-excel.js

Usage

First of all you need to wake up the external server, like this:

import ExcelService from 'export-to-excel.js';
ExcelService.wakeUp();

Put this code immediately after your application is up (it takes faw seconds to wake up the external server).

Simple export to excel

import ExcelService from 'export-to-excel.js';
const data = [{ "id": 5, "name": "John", "grade": 90, "age": 15 }, { "id": 7, "name": "Nick", "grade": 70, "age": 17 }];
ExcelService.export(data);

The excel file that will be downloaded looks like - alt text

Excel with headings If you want to control the excel headings you can do it easily by sending list of headings to the function:

import ExcelService from 'export-to-excel.js';
const data = [{ "id": 5, "name": "John", "grade": 90, "age": 15 }, { "id": 7, "name": "Nick", "grade": 70, "age": 17 }];
const headings = ["Student ID", "Student Name", "Test Grade", "Student Age"];
ExcelService.export(data, { headings });

The excel file that will be downloaded looks like - alt text

Name the file Currently the excel file name is 'excel'. You can override it:

const data = [{ "id": 5, "name": "John", "grade": 90, "age": 15 }, { "id": 7, "name": "Nick", "grade": 70, "age": 17 }];
const headings = ["Student ID", "Student Name", "Test Grade", "Student Age"];
const fileName = 'StudentsGrades';
ExcelService.export(data, { headings, fileName });

Async/Await

The method 'export' is promise based, so you can use it with async/await syntax:

const onExport = async () => {
    await ExcelService.export(this.data, { fileName: this.excelName });
    alert('Your excel file has been exported!'); // or some nicer ui indication...
}

Options

| option | description | default value | | ------ | ------ | ------ | | fileName | the name of the excel file to be exported | excel | | headings | the headings for the excel file, if not presented the headings will be the object keys | - |

License

MIT