Utilities to export js data into different acceptable format for nodejs
$ npm install --save js-export
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);
});
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);
missing
value to set if object to write does not have the given property. default toNA
Export data to excel format
sheet:String
default sheet name to use. default toSheet
multi:Boolean
will put inner plain objects into their own sheet. default tofalse
flat:Boolean
will flat inner plain object. default totrue
Note!: You may choose flat or multi but not both
Export data to csv format
Export data to text format
Export data into json format