How to export a table to excel with JavaScript? -
i've feeling more simpler imagine be...
i'm trying create button on webpage exports table ms excel or other spreadsheet software. well, it's not strictly table ul of list items (in place of rows) contain divs (in place of table data cells).
tried several things. solutions i've used far don't error per se, , seem retrieve data want them retrieve. don't work d:
$('.export-to-excel').click(_.bind(function(e){ var = $('<a/>').appendto('.contents'); var table = $('mytable'); var table_rows = $('mytable').find('li.rows'); var data_type = 'data:application/csv;charset=utf-8'; a.href = data_type + ', ' + table_rows; a.download = 'exported_table_' + '.xls'; a.click(); e.preventdefault(); }, this));
and several other things. shortest far.
you can't create file javascript. well, can read , manipulate it, it's not crossbrowser (http://www.html5rocks.com/en/tutorials/file/dndfiles/). need server backend make file , make downloadable.
you can use php that's easy install-configure-development. has xls object play it. recommend this: https://phpexcel.codeplex.com/
good luck
Comments
Post a Comment