+ 3
Export table to excel using jquery
i will add button for export table in html page to excel file using jquery. please help me.
4 Respuestas
+ 12
there's this option
convert table element into a csv file
https://jsfiddle.net/terryyounghk/KPEGU/
and this
http://www.jqueryscript.net/table/jQuery-Plugin-To-Convert-HTML-Table-To-CSV-tabletoCSV.html
many options here:
http://www.jqueryscript.net/tags.php?/CSV/
+ 6
please help me.
+ 3
not correct.
this codes not display correct for table with rowspan and colspan.
i find below code that is correct display. but this occur "field- network error" when table rows is larger of 2000 rows.
var tableToExcel = (function () {
var uri = 'data:application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines></x:DisplayGridlines></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
, base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function (s, c) { return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; }) }
return function (table, name, filename) {
if (!table.nodeType) table = document.getElementById(table)
var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML }
document.getElementById("exel").href = uri + base64(format(template, ctx));
document.getElementById("exel").download = filename;
document.getElementById("exel").click();
}
})()
+ 2
I don't know about jQuery, but there's a free to use script in php which creates/reads excel files.
https://blog.mayflower.de/561-Import-and-export-data-using-PHPExcel.html