How generate "Excel File Report" download in Meteor?

I would like to generate excel report from excel template.
Please help me…

I think Excel files are pretty complicated. Maybe you could make a .csv (comma separated values) file instead? That’s a super simple file format that Excel can read too. XML could also be an option if you want formatting options.

Otherwise you can probably find a package on NPM that handles Excel files

1 Like

@herteby, Very thanks for your quick reply.
But my user need to print the report with format (Ex: header, body, footer).
Could you advice which one for NPM Package?

Example Format

we do reports with HTML/CSS

2 Likes

Here’s a professional solution:

1 Like

@rhywden, It is free or not?

@theara you can see the documents here https://www.syncfusion.com/products/communitylicense

NPM has lots of packages to solve this on both Client and Server side.
We have used node-xlsx to parse/generate XLS files on Server to Buffer, and .write() method of FilesCollection to save it and make it downloadable by users.

1 Like

@dr.dimitru, Thanks
Could you example?

import xlsx from 'node-xlsx';
import { FilesCollection } from 'meteor/ostrio:files';

const dataSheetsCollection = new FilesCollection({collectionName: 'dataSheets'});

const data = [['col1', 'col2', 'col3', 'col4'], [true, false, null, 'sheetjs'], ['foo', 'bar', new Date('2014-02-19T14:30Z'), '0.3'], ['baz', null, 'qux']];
const buffer = xlsx.build([{name: "sheetName", data: data}]);

dataSheetsCollection.write(buffer, {
  fileName: 'file.xls',
  type: 'application/vnd.ms-excel'
});

My guess if you need to use a template, you can parse XLS to Array with xlsx.parse(), then add data and generate file with xlsx.build().

1 Like

https://www.npmjs.com/package/xlsx

Thanks for all, now I tried https://github.com/SheetJS/js-xlsx.
but I have problem with Style when generate excel file from existing template (don’t have style generate)
:blush:

i use nicolaslopezj:excel-export

@kemnep, can generate from template file? and work with style and format?

https://atmospherejs.com/nicolaslopezj/excel-export

I am also using this package and getting an error. Can you help me ?