Skip to content

Utilities to export js data into different acceptable format

Notifications You must be signed in to change notification settings

byteskode/js-export

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Utilities to export js data into different acceptable format

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%