jquery使用jxl插件導(dǎo)出excel示例
更新時(shí)間:2014年04月14日 15:42:50 作者:
這篇文章主要介紹了jquery使用jxl插件導(dǎo)出excel的具體實(shí)現(xiàn)步驟,需要的朋友可以參考下
復(fù)制代碼 代碼如下:
function formattable(tableHtml, sheetName) {
var 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:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta http-equiv="content-type" content="text/plain; charset=UTF-8"/></head><body><table>{table}</table></body></html>';
var ctx = {
worksheet : name,
table : 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) {
return c[p];
});
}
相關(guān)文章
使用jquery組件qrcode生成二維碼及應(yīng)用指南
這篇文章主要介紹了使用jquery組件qrcode生成二維碼及應(yīng)用指南,非常全面實(shí)用,需要的朋友可以參考下2015-02-02Jquery Uploadify上傳帶進(jìn)度條的簡單實(shí)例
本篇文章主要是對(duì)Jquery Uploadify上傳帶進(jìn)度條的簡單實(shí)例進(jìn)行了介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助2014-02-02Jquery知識(shí)點(diǎn)一 Jquery的ready和Dom的onload的區(qū)別
onload是所有dom元素創(chuàng)建完畢,圖片、css等都加在完畢后才觸發(fā) ready則是dom元素創(chuàng)建完畢后就被觸發(fā)2011-01-01jQuery插件FusionCharts實(shí)現(xiàn)的2D餅狀圖效果【附demo源碼下載】
這篇文章主要介紹了jQuery插件FusionCharts實(shí)現(xiàn)的2D餅狀圖效果,結(jié)合完整實(shí)例形式分析了FusionCharts插件2D餅狀圖繪制相關(guān)實(shí)現(xiàn)技巧,并附帶demo源碼供讀者下載參考,需要的朋友可以參考下2017-03-03jQuery plugin animsition使用小結(jié)
本文通過實(shí)例代碼給大家分享了jQuery plugin animsition用法,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧2017-09-09jQuery實(shí)現(xiàn)在列表的首行添加數(shù)據(jù)
這篇文章主要介紹了jQuery實(shí)現(xiàn)在列表的首行添加數(shù)據(jù)的方法,十分的簡單,有需要的小伙伴可以參考下。2015-05-05