js-export

0.1.0 • Public • Published

js-export

Build Status

Utilities to export js data into different acceptable format for nodejs

Installation

$ npm install --save js-export

Usage

var JSExport = require('js-export');
var jsexport = new JSExport(data, options);
 
//export data as excel file
jsexport.writeExcel(`<file>`, done);
 
//download data as excel through http requests
app.get('/exports', function(request, response){
   jsexport.downloadExcel(response, options); 
});

Export Engine

Additional export engines can be added as a plugins. It should implement write and download methods for it to be valid export engine.

var JSExport = require('js-export');
var jsexport = new JSExport(data, options);
 
//buffer engine
var bufferEngine = {
    write: function(path, done){
        //codes
        ...
    },
 
    download:function(response, options){
        //codes
        ...
    }
}
 
//use export engine
jsexport.use('buffer', bufferEngine);
 
//then use buffer export engine
jsexport.writeBuffer(path, done);
 

Options

  • missing value to set if object to write does not have the given property. default to NA

Engines

excel

Export data to excel format

Options

  • sheet:String default sheet name to use. default to Sheet
  • multi:Boolean will put inner plain objects into their own sheet. default to false
  • flat:Boolean will flat inner plain object. default to true

Note!: You may choose flat or multi but not both

csv(WIP)

Export data to csv format

text(WIP)

Export data to text format

json(WIP)

Export data into json format

Readme

Keywords

Package Sidebar

Install

npm i js-export

Weekly Downloads

2

Version

0.1.0

License

MIT

Last publish

Collaborators

  • lykmapipo