Skip to content

The most straightforward XLS export I can think of

License

Notifications You must be signed in to change notification settings

marseille/SimpleXLS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SimpleXLS

NPM url here

npm install simple-xls

Simple XLS exporter in NodeJS.

Simple XLS has one function: SimpleXLS.write_to_xls = function(columns, datas)

Columns have the structure:

{
  'label': 'my infinitely expressive column name',
  'name':'my_boring_database_semantic_name'
}

Rows (datas) have the structure:

{
  'my_boring_database_semantic_name': 'foo',
  'my_other_semantic_name': 'bar'
}

The return is a WritableStream from the memory-streams npm package.

Now all you have to do to return this as an attachment in ExpressJS is:

var SimpleXLS = require('SimpleXLS');
var xls_buffer = SimpleXLS.write_to_xls(columns, rows).toBuffer();
resp.setHeader('Content-Type', 'application/vnd.openxmlformats');
resp.setHeader("Content-Disposition", "attachment; filename=" + "example.xls");
resp.setHeader('Content-Length', xls_buffer.length);
resp.end(xls_buffer);

About

The most straightforward XLS export I can think of

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published