rainabba / jquery-table2excel

jQuery Plugin to export HTML tabled to Excel Spreadsheet Compatible Files
593 stars 666 forks source link

EXCLUDE doesn't need to be whole row Feature (with simple code change) #40

Closed SeanDevoy closed 8 years ago

SeanDevoy commented 8 years ago

FYI: I love this add-in!

Currently, the "exclude" filter only ignores complete s (rows) with the matching class on them. I had a need to export a table and NOT export "controls" like Buttons and dropbox items into the spreadsheet.

With a very simple change to the code, individual s can have there content ignored. Code does not display well here, but the idea is simple. Step through the item's s. If the contains something with the exclude class, send an empty , otherwise send its contents. There is probably a cleaner way to do this, jQuery tips will be welcomed.

I changed: // get contents of table except for exclude $(e.element).each( function(i,o) { var tempRows = ""; $(o).find("tr").not(e.settings.exclude).each(function (i,o) { tempRows += "<tr>" + $(o).html() + "</tr>"; }); e.tableRows.push(tempRows); });

to: ` // get contents of table except for exclude $(e.element).each( function(i,o) { var tempRows = ""; $(o).find("tr").not(e.settings.exclude).each(function (i,p) { tempRows += ""; $(p).find("td").not(e.settings.exclude).each(function (i,q) { var flag = $(q).find(e.settings.exclude) // does this have an exclude item if(flag.length >= 1) { tempRows += " " // exclude it!! } else { tempRows += "" + $(q).html() + "" } })

                tempRows += "</tr>";
            });
            e.tableRows.push(tempRows);
        });

` Now I my "controls" are excluded from the spreadsheet.

Hope that helps someone out. Sean

rainabba commented 8 years ago

Thanks @SeanDevoy . If you know how to submit a PR, go for it and get the contribution! :) If not, just fork the repo, make the change, the find the "Submit Pull Request" button and it should be clear where to go from there. You can even make the change right in the web interface in your repo so you don't need to leave the browser.

SeanDevoy commented 8 years ago

Did I do it correctly? Am I supposed to [cid:image001.png@01D1BD7F.4F390C10] ?

From: rainabba [mailto:notifications@github.com] Sent: Thursday, June 02, 2016 3:55 PM To: rainabba/jquery-table2excel jquery-table2excel@noreply.github.com Cc: Sean Devoy sdevoy@bizfocused.com; Mention mention@noreply.github.com Subject: Re: [rainabba/jquery-table2excel] EXCLUDE doesn't need to be whole row Feature (with simple code change) (#40)

Thanks @SeanDevoyhttps://github.com/SeanDevoy . If you know how to submit a PR, go for it and get the contribution! :) If not, just fork the repo, make the change, the find the "Submit Pull Request" button and it should be clear where to go from there. You can even make the change right in the web interface in your repo so you don't need to leave the browser.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/rainabba/jquery-table2excel/issues/40#issuecomment-223403398, or mute the threadhttps://github.com/notifications/unsubscribe/ABO44TJFA1rWkhypcASx5U0484TE4S5tks5qHzUogaJpZM4IsvWI.

rainabba commented 8 years ago

You did it correctly and have now officially contributed to another repo :) Thanks for the help.