手机
当前位置:查字典教程网 >编程开发 >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任意位置浮动固定层插件用法实例

jquery中map函数遍历数组用法实例

JavaScript使用addEventListener添加事件监听用法实例

javaScript中with函数用法实例分析

jQuery插件制作之参数用法实例分析

jquery实现弹出层效果实例

JQuery中Text方法用法实例分析

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

jQuery异步上传文件插件ajaxFileUpload详细介绍

jQuery使用zTree插件实现树形菜单和异步加载

精品推荐
分类导航