TableExport icon indicating copy to clipboard operation
TableExport copied to clipboard

Output files should be generated at download time, rather than at render time

Open RichardBradley opened this issue 7 years ago • 2 comments

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.

RichardBradley avatar Dec 07 '17 17:12 RichardBradley

It would be great to have especially for dynamically created tables as mentioned in #101.

fretchen avatar May 30 '18 17:05 fretchen

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); 
}

qwe900 avatar Jul 26 '18 08:07 qwe900