TableExport
TableExport copied to clipboard
Output files should be generated at download time, rather than at render time
Unless I am mistaken, the contents of the download files are generated at render time (i.e. at the time that the buttons are shown), rather than when the download buttons are clicked.
This makes very little difference for little demos, but seems very wasteful if the tables are large.
I think it would be better to generate the data on-demand, in case it is not needed.
I'll see if I have time to make a PR to fix.
It would be great to have especially for dynamically created tables as mentioned in #101.
Create a new instance when you click on export button:
var test = document.getElementById('export');
test.onclick = function() {
var instance = $("#table").tableExport({
formats: ['xlsx'],
exportButtons: false,
ignoreCols: 0,
filename: filename,
});
var exportData = instance.getExportData()['table']['xlsx'];
instance.reset();
instance.export2file(exportData.data, exportData.mimeType, exportData.filename, exportData.fileExtension);
}