var tableToExcel = (function () {/n var uri = 'data:application/vnd.ms-excel;base64,';/n 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/'>

{table}
';/n var base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) };/n var format = function (s, c) { return s.replace(/{(/w+)}/g, function (m, p) { return c[p]; }) };/n return function (table, name) {/n if (!table.nodeType) table = document.getElementById(table);/n var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML };/n window.location.href = uri + base64(format(template, ctx));/n };/n})();

JavaScript 使用 HTML 表格导出 Excel 文件

原文地址: https://www.cveoy.top/t/topic/ll49 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录