Open Jevuska opened 9 years ago
Any tr tag you add class=".noExl" will be excluded. I haven't tried it for th though, why don't you try and see if it works?
col and col group were deprecated in HTML 4.01 and the reality is there aren't "columns" in an html table which makes manipulating them very tricky.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/colgroup
As ferman2147 suggested, the plugin already supports row exclusion using the .noExl class. It wouldn't be hard to add individual cell exclusion and then it would be up to you to ensure all the cells in a "column" were marked and then you could implicitly exclude them.
TODO: Add individual cell exclusion using .noExl
ya @ferman2147 , i've try before but no luck, and @rainabba I add individual cell exclusion using .noExl in the same column not work too, so I create another code outside like this one to remove a column.
$('table').delegate('td,th', 'click', function() {
var index = this.cellIndex;
$(this).closest('table').find('tr').each(function() {
this.removeChild(this.cells[ index ]);
});
});
any suggestion how to include in this plugin?
What you need to do is pretty simple. Here is a screenshot for you. Note that you should give the id attribute to your table like < table id="myTable". (Looking at the the screenshot I realised that I forgot to do so.;) )
To remove columns i am using this
$(o).find("tr").not(e.settings.exclude).each(function (i, o) { var cloneRow = $(o).clone(); $(cloneRow).find(e.settings.exclude).remove(); var html = $(cloneRow).html(); tempRows += "<tr>" + html + "</tr>"; });
Thanks https://github.com/nshah31 (nshah31)..
Above Solution works perfectly when we comment the following code and add above code in jquery.table2excel.js -->>
// $(o).find("tr").not(e.settings.exclude).each(function (i,o) {
// tempRows += "<tr>" + $(o).html() + "</tr>";
// });
Thank you once again
Can you explain me please what have you done? I've added nshah31's code and i've commented the one you mentioned, but when i try to add the noExl class to a
@Kalemstorm94 on line #54 or near by you would find following code
$(o).find("tr").not(e.settings.exclude).each(function (i,o) {
tempRows += "<tr>" + $(o).html() + "</tr>";
}); //comment this code
and just after this add this following code
//To Exclude the columns
$(o).find("tr").not(e.settings.exclude).each(function (i, o) { var cloneRow = $(o).clone(); $(cloneRow).find(e.settings.exclude).remove(); var html = $(cloneRow).html(); tempRows += "<tr>" + html + "</tr>"; });
e.tableRows.push(tempRows);
That's it it will work fine. Hope this helps
Hello rainabba, It's great simple plugin. But is there any option to exclude a column base on 'colgroup' or 'th' ?