Home > Web Front-end > JS Tutorial > body text

jquery uses jxl plug-in to export excel example_jquery

WBOY
Release: 2016-05-16 16:52:27
Original
1147 people have browsed it
复制代码 代码如下:

function formattable(tableHtml, sheetName) {
var template = '{table}
';
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];
});
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template