首頁 >web前端 >js教程 >jquery使用jxl外掛匯出excel範例_jquery

jquery使用jxl外掛匯出excel範例_jquery

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-05-16 16:52:271201瀏覽
複製程式碼如下程式碼:

function formattable(tableHtml,sheetName) {
var template = {table}
';
var ctx = {
工作表:名稱,
表:tableHtml
};
var downloadLink = document.createElement("a");
downloadLink.href = 'data:application/vnd.ms-excel;base64,' base64(format(
template, ctx));
downloadLink.download = SheetName ".xls";
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
// window.open('data:application/vnd.ms-excel;base64,'
// base64(format(template, ctx)));
}


function base64(s) {
return $.base64.btoa(unescape(encodeURIComponent(s)));
}


var format = function(s, c) {
return s.replace(/{(w )}/g, function(m, p) {
返回c[p]
});
}
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn