Here is a simple JavaScript to convert HTML table to CSV.
function createCSV(tableId) {var tbl = document.getElementById(tableId);if (tbl == null) return;var trs = tbl.getElementsByTagName("tr");var csv = '';for (var j = 0; j < trs.length ; j++ ) {var c = trs[j].cells;for(var i= 1; i < c.length ; i++ ) {if (i > 1) csv = csv + ',';csv = csv + '"' + c[i].innerText + '"';}csv = csv + '\n';}document.getElementById('debug').value = csv;}
No comments:
Post a Comment