function base64(content) {
return window.btoa(unescape(encodeURIComponent(content)));
}
function tableToExcel(tableID, fileName) {
var excelContent = $("#" + tableID).html();
var excelFile = "";
excelFile += "";
excelFile += "";
excelFile += excelContent;
excelFile += "";
excelFile += "";
var link = "data:application/vnd.ms-excel;base64," + base64(excelFile);
var a = document.createElement("a");
a.download = fileName + ".xls";
a.href = link;
a.click();
}
htmlコード
data : dataList) {
%>
js
table Class excel
var tableClass = document.getElementsByClassName('ant-table-fixed');
tableClass[0].id = 'tableExcel';
var tableItem = document.getElementById('tableExcel');
var excelContent = tableItem.innerHTML;
var excelFile = "";
excelFile += "";
excelFile += "";
excelFile += excelContent;
excelFile += "";
excelFile += "";
var link = "data:application/vnd.ms-excel;base64," + window.btoa(unescape(encodeURIComponent(excelFile)));
var a = document.createElement("a");
a.download = " .xls";
a.href = link;
a.click();