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
@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
Here’s a professional solution:
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.
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()
.
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)
i use nicolaslopezj:excel-export
I am also using this package and getting an error. Can you help me ?