Hi, with a link you've posted doesn't actually generates excel file, there just forms html file with the following head: code<html xmlns:o="urn:schemas-microsoft-com
office" xmlns:x="urn:schemas-microsoft-com
excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>W3C Example Table</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head>/code
so you can't use this code as while maping it generates several tables. You would need to modify your code:
codevar tableToExcel = (function() {
var uri = 'data:application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com
office" xmlns:x="urn:schemas-microsoft-com
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: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) {
var output = '';
//gt(0) - to skip first table. it is hidden table, used for mapping
$("[name=" + table + "]:gt(0)").each(function(){
output += $(this).find("tbody").html();
});
var ctx = {worksheet: name || 'Worksheet', table: output}
Code: Select all
window.location.href = uri + base64(format(template, ctx))
}
})()/code
to call that function you should pass table name
codetableToExcel('mobilegridName', 'W3C Example Table');/code