mazdik / ng-mazdik

Angular UI component library
https://mazdik.github.io/ng-mazdik
MIT License
89 stars 34 forks source link

This project is very good , can you add function for export to xls ? #10

Closed huangwei16800 closed 5 years ago

huangwei16800 commented 5 years ago

this data table is so nice, i like it, i will use in my project (MIS SYSTEM), but how can export to Excel . because My user always export data to Excel

mazdik commented 5 years ago

Try js-xlsx demo npm install xlsx

export

const ws: XLSX.WorkSheet = XLSX.utils.json_to_sheet(this.dataManager.rows);

import

let data = <any[][]>(XLSX.utils.sheet_to_json(ws, {header: 1}));
const labels = data[0]
const output = data.slice(1).map(item => item.reduce((obj, val, index) => {
obj[labels[index]] = val
return obj
}, {}));
this.dataManager.rows = output;
huangwei16800 commented 5 years ago

thank your!