I have used the JavaScript function from this question and tried to adapt it to my app. It works but it also could be improved and I hope, you will help me to do it
This is the function
function exportExcelReport(tblId) {
var tab_text = "<table border='2px'><tr>";
var table = document.getElementById(tblId);
var style;
for (var j = 0; j < table.rows.length; j++) {
style = table.rows[j].className.split(" ");
if (style.length < 2)
tab_text = tab_text + table.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, "");
return window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text));
}
This is how the table looks like
This is what I get as a result after export
As you can see, the exported excel file does not have a grid in the backround what actually looks strange. Do you have any idea, why is this happening?
Also I would like to remove the last column, that one after YTD. Is it somehow possible to adjust tab_text.replace(...) in the code abowe, so it that it could be ignored while exporting.
The column looks like this in html
</td><td width='20px'>
<a class='infobox' href=''>
<img src='img/info.jpg' alt='info' width='18' height='18'>
<span>
Service Engineer: ... <br>
Datasource: ...
</span>
</a>
</tr>
Thx in advance!