jquery-table2excel icon indicating copy to clipboard operation
jquery-table2excel copied to clipboard

Exlude Column?

Open Jevuska opened this issue 9 years ago • 8 comments

Hello rainabba, It's great simple plugin. But is there any option to exclude a column base on 'colgroup' or 'th' ?

Jevuska avatar Apr 21 '15 14:04 Jevuska

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?

ferman2147 avatar Apr 22 '15 14:04 ferman2147

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

rainabba avatar Apr 22 '15 14:04 rainabba

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?

Jevuska avatar Apr 26 '15 17:04 Jevuska

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.;) ) adsiz

ferman2147 avatar Apr 28 '15 07:04 ferman2147

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>"; });

nshah31 avatar Aug 04 '15 17:08 nshah31

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

jaydeepgiri avatar Oct 23 '15 07:10 jaydeepgiri

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

or element, it's still not working...

Kalemstorm94 avatar Feb 24 '17 08:02 Kalemstorm94

@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

jaydeepgiri avatar Apr 14 '17 06:04 jaydeepgiri