import XLSX from 'xlsx'
exportExcel() {
let exportTableData = []
let tmpCon = []
let propList = []
this.columnData.forEach(column => {
tmpCon.push(column.label)
propList.push(column.prop)
})
exportTableData.push(tmpCon)
this.tableData.forEach( (item, index) => {
let rowData = []
propList.forEach( prop => {
rowData.push(item[prop])
})
exportTableData.push(rowData)
})
let columns = []
let ws = XLSX.utils.aoa_to_sheet(exportTableData)
let wb = XLSX.utils.book_new()
let wscols = [
{ wch: 12 },
{ wch: 26 },
{ wch: 12 },
{ wch: 12 },
{ wch: 14 },
{ wch: 12 },
{ wch: 12 },
{ wch: 15 },
];
ws["!cols"] = wscols;
let wsrows = [{ hpx: 20 }];
for (let i = 0; i <= this.tableData.length; i++) {
wsrows.push({ hpx: 20 });
}
ws["!rows"] = wsrows;
XLSX.utils.book_append_sheet(wb, ws, `${this.title}`)
XLSX.writeFile(wb, `${this.title}.xlsx`)
},