I can export excel from html table .but could not avoid last row (tr),which row is for pagination on screen.so this row also shows in result of excel file?
function DownloadToExcel(table){
debugger;
var t = document.getElementById(table);
t.border = 1;
var html = t.outerHTML;
html = encodeURIComponent(html);
var uri = 'data:application/vnd.ms-excel,' + html;
var downloadLink = document.createElement("a");
downloadLink.href = uri;
downloadLink.download = "sauberkeit.xlsx";
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
}
Simply remove the last row before serialising the HTML, then add it back again.
var t = document.getElementById(table);
t.border = 1;
var last = t.lastElementChild;
t.removeChild(last);
var html = t.outerHTML;
t.appendChild(last);
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.