方法一、通过标签(可定义文件名称):
导出到excel方法:
var tabletoexcel2 = (function () {
var uri = 'data:applicati...
方法一、通过标签(可定义文件名称):
导出到excel方法:
var tabletoexcel2 = (function () {
var uri = 'data:application/vnd.ms-excel;base64,',
template = '
{c}{table}
';
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, filename) {
if (!table.nodetype) table = document.getelementbyid(table)
var ctx = { worksheet: name || 'worksheet', table: table.innerhtml }
document.getelementbyid("dlink").href = uri + base64(format(template, ctx));
document.getelementbyid("dlink").download = filename + ".xls";
document.getelementbyid("dlink").click();
}
})();
方法二、直接使用
{c}