首页 > 代码库 > JS 将表格table导出excel

JS 将表格table导出excel

function tableToExcel(id){    var tb = document.getElementById(id);    var html = ‘<html><head><meta charset="UTF-8"></head><body><table>‘ + tb.innerHTML + ‘</table></body></html>‘;        html = window.btoa(unescape(encodeURIComponent(html)));        var uri = ‘data:application/vnd.ms-excel;base64,‘ + html;    window.location.href = uri;}

 

JS 将表格table导出excel