Reputation: 31
I have HTML tables with data. There are some columns which are hidden, based on report generation.
I am generating an Excel file from these table. For generating the Excel file, I have to provide the innerHTML
data to the Excel function. The issue is that, innerHTML
data contains hidden tags as well.
This results in Excel file showing the hidden column data. Is there a way I can remove the hidden tags' data?
Upvotes: 2
Views: 287
Reputation: 1738
Using JQuery, you can do something like this:
var htmlString = '<<your innerHTML string>>';
var obj = jQuery(htmlString);
var jQ = jQuery("<p>").append(obj);
jQ.children(":hidden").html("");
var newHtml = jQ.html();
Now use the newHtml
in your code.
Upvotes: 2