手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >jquery使用jxl插件导出excel示例
jquery使用jxl插件导出excel示例
摘要:复制代码代码如下:functionformattable(tableHtml,sheetName){vartemplate='{table}...

复制代码 代码如下:

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><><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];

});

}

【jquery使用jxl插件导出excel示例】相关文章:

Jquery使用css方法改变样式实例

jQuery获取字符串中出现最多的数

jquery使用经验小结

jQuery插件datepicker 日期连续选择

jquery实现弹出层效果实例

使用node+vue.js实现SPA应用

微信WeixinJSBridge API使用实例

基于jQuery插件实现环形图标菜单旋转切换特效

JQuery boxy插件在IE中边角图片不显示问题的解决

jquery 构造函数在表单提交过程中修改数据

精品推荐
分类导航