Skip to content

furstenheim/js-excel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

excel-export

A simple node.js module for exporting data set to Excel xlsx file.

Using excel-export

Setup configuration object before passing in the execute method. cols is an array for column definition. Column definition should have caption and type properties. Supported valid types are string, date, bool and number. rows is the data to be export. It is an Array of Array (row). Each row should be the same length of cols.

var express = require('express');
var nodeExcel = require('excel-export');
var app = express();

app.get('/Excel', function(req, res){
  	var conf ={};
  	conf.cols = [
		{caption:'string', type:'string'},
		{caption:'date', type:'date'},
		{caption:'bool', type:'bool'},
		{caption:'number', type:'number'}				
  	];
  	conf.rows = [
 		['pi', (new Date(Date.UTC(2013, 4, 1))).oaDate(), true, 3.14],
 		["e", (new Date(2012, 4, 1)).oaDate(), false, 2.7182],
 		["M&M<>'", (new Date(Date.UTC(2013, 6, 9))).oaDate(), false, 1.2]   
  	];
  	var result = nodeExcel.execute(conf);
  	res.setHeader('Content-Type', 'application/vnd.openxmlformats');
  	res.setHeader("Content-Disposition", "attachment; filename=" + "Report.xlsx");
  	res.end(result, 'binary');
});

app.listen(3000);
console.log('Listening on port 3000');

About

A simple node.js module for exporting data set to Excel xlsx file.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%