var tab = document.getElementById("__xmlview1--Html5AppList_AppTable-listUl");
tab.rows
function downloadexcel() {
var tab_text = "<table border='2px'><tr bgcolor='#87AFC6'>";
var textRange;
var j = 0;
tables = document.getElementById('__xmlview0--Html5AppList_AppTable-listUl');
for (j = 0; j < tab.rows.length; j++) {
tab_text = tab_text + tab.rows[j].innerHTML + "</tr>";
}
tab_text = tab_text + "</table>";
tab_text = tab_text.replace(/<A[^>]*>|<\/A>/g, "");
tab_text = tab_text.replace(/<img[^>]*>/gi, "");
tab_text = tab_text.replace(/<input[^>]*>|<\/input>/gi, "");
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
txtArea1.document.open("txt/html", "replace");
txtArea1.document.write(tab_text);
txtArea1.document.close();
txtArea1.focus();
} else
sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text));
return (sa);
}
tables = document.getElementsByTagName("table");
function downloadexcel() {
tables = document.getElementsByTagName("table");
console.log(tables);
for (i = 0; i < tables.length; i++) {
tab = document.getElementById(tables[i].id);
// logic for tables with name of header and data or listUl.
// You can add your own table id if further somenew id's are found.
substringTwoTable = ["-header"];
substringOneTable = ["-listUl"];
foundOneTable = substringOneTable.some(function(v) {
return tables[i].id.indexOf(v) >= 0;
});
if (foundOneTable) {
var tab_text = "<table border='2px'><tr bgcolor='#87AFC6'>";
var textRange;
var j = 0;
for (j = 0; j < tab.rows.length; j++) {
tab_text = tab_text + tab.rows[j].innerHTML + "</tr>";
}
tab_text = tab_text + "</table>";
tab_text = tab_text.replace(/<A[^>]*>|<\/A>/g, "");
tab_text = tab_text.replace(/<img[^>]*>/gi, "");
tab_text = tab_text.replace(/<input[^>]*>|<\/input>/gi, "");
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
txtArea1.document.open("txt/html", "replace");
txtArea1.document.write(tab_text);
txtArea1.document.close();
txtArea1.focus();
sa = txtArea1.document.execCommand("SaveAs", true, "Say Thanks to Sumit.xls");
} else
sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text));
} else {
found = substringTwoTable.some(function(v) {
return tables[i].id.indexOf(v) >= 0;
});
if (found) {
var tab_text = "<table border='2px'><tr bgcolor='#87AFC6'>";
var textRange;
var j = 0;
for (j = 0; j < tab.rows.length; j++) {
tab_text = tab_text + tab.rows[j].innerHTML + "</tr>";
}
} else {
for (j = 0; j < tab.rows.length; j++) {
tab_text = tab_text + tab.rows[j].innerHTML + "</tr>";
}
tab_text = tab_text + "</table>";
tab_text = tab_text.replace(/<A[^>]*>|<\/A>/g, "");
tab_text = tab_text.replace(/<img[^>]*>/gi, "");
tab_text = tab_text.replace(/<input[^>]*>|<\/input>/gi, "");
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
txtArea1.document.open("txt/html", "replace");
txtArea1.document.write(tab_text);
txtArea1.document.close();
txtArea1.focus();
} else
sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text));
}
}
}
}
javascript:(function(){tables = document.getElementsByTagName("table");console.log(tables); for(i = 0 ; i < tables.length ; i++) { tab = document.getElementById(tables[i].id);alert(tables[i].id); substringTwoTable = ["-header"]; substringOneTable = ["-listUl"]; foundOneTable = substringOneTable.some(function(v) { return tables[i].id.indexOf(v) >= 0; }); console.log("found"+foundOneTable); if(foundOneTable){ var tab_text="<table border='2px'><tr bgcolor='#87AFC6'>";var textRange; var j=0; for(j = 0 ; j < tab.rows.length ; j++) {tab_text=tab_text+tab.rows[j].innerHTML+"</tr>";} tab_text=tab_text+"</table>"; tab_text= tab_text.replace(/<A[^>]*>|<\/A>/g, ""); tab_text= tab_text.replace(/<img[^>]*>/gi,""); tab_text= tab_text.replace(/<input[^>]*>|<\/input>/gi, ""); var ua = window.navigator.userAgent; var msie = ua.indexOf("MSIE "); if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) { txtArea1.document.open("txt/html","replace"); txtArea1.document.write(tab_text); txtArea1.document.close(); txtArea1.focus(); sa=txtArea1.document.execCommand("SaveAs",true,"Say Thanks to Sumit.xls"); } else sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text)); }else{ found = substringTwoTable.some(function(v) { return tables[i].id.indexOf(v) >= 0; }); if(found){ var tab_text="<table border='2px'><tr bgcolor='#87AFC6'>";var textRange; var j=0; for(j = 0 ; j < tab.rows.length ; j++) {tab_text=tab_text+tab.rows[j].innerHTML+"</tr>";} }else{ for(j = 0 ; j < tab.rows.length ; j++) {tab_text=tab_text+tab.rows[j].innerHTML+"</tr>";} tab_text=tab_text+"</table>"; tab_text= tab_text.replace(/<A[^>]*>|<\/A>/g, ""); tab_text= tab_text.replace(/<img[^>]*>/gi,""); tab_text= tab_text.replace(/<input[^>]*>|<\/input>/gi, ""); var ua = window.navigator.userAgent; var msie = ua.indexOf("MSIE "); if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) { txtArea1.document.open("txt/html","replace"); txtArea1.document.write(tab_text); txtArea1.document.close(); txtArea1.focus(); } else sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text)); }} }})();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 |