// 导出Excel方法 let idTmr export function getExplorer() { const explorer = window.navigator.userAgent if (explorer.indexOf('Firefox') >= 0) { // firefox return 'Firefox' } else if (explorer.indexOf('Chrome') >= 0) { // Chrome return 'Chrome' } else if (explorer.indexOf('Opera') >= 0) { // Opera return 'Opera' } else if (explorer.indexOf('Safari') >= 0) { // Safari return 'Safari' } } const tableToExcel = (function() { const uri = 'data:application/vnd.ms-excel;base64,' const template = `{worksheet}{table}
` const base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) } const format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p] } ) } return function(table) { if (!table.nodeType) table = document.getElementById(table) const ctx = { worksheet: 'Worksheet', table: table.innerHTML } window.location.href = uri + base64(format(template, ctx)) console.log(ctx) } })() export function method5(tableid) { tableToExcel(tableid) } export function Cleanup() { window.clearInterval(idTmr) }