Following on this question on stack, and this stackblitz, it seems that the material table does not fully exported to excel if the pagination is not showing all data.
So instead, I will export the array as a whole, but the problem is that the main field names is showing the indexes instead of the names:
So instead of:
exportTable()
{
//let data = Object.values(this.dataSource);
const ws: xlsx.WorkSheet=xlsx.utils.table_to_sheet(data);
const wb: xlsx.WorkBook = xlsx.utils.book_new();
xlsx.utils.book_append_sheet(wb, ws, 'All Ind. Searched Data Export');
/* save to file */
xlsx.writeFile(wb, 'ExportAllData_Ind.xlsx');
}
I changed to:
exportTable()
{
let data = Object.values(this.dataSource);
const ws: xlsx.WorkSheet=xlsx.utils.json_to_sheet(data);
const wb: xlsx.WorkBook = xlsx.utils.book_new();
xlsx.utils.book_append_sheet(wb, ws, 'All Ind. Searched Data Export');
/* save to file */
xlsx.writeFile(wb, 'ExportAllData_Ind.xlsx');
}
The problem is that the exported excel is setting the field names into indexes and then add at the end, the real field names:
I know it is something related to arrays, but how can I export the array with only the field name part.