Open khamarzama opened 8 years ago
@khamarzama Check out the index.html under demo folder. Instead of using the table id you can assign a css class to all of the tables you want to export and call the table2excel with that css class. I haven't tested it personally but based on the demo source and the change log, I hope that will work.
Just tried to use a class name to select multiple tables and it's not working. Even the demo is not working as expected, anymore.
No answer for this question, i have the same issue :(
I had the same issue. I tried going around it by wrapping another table around my tables which didn't work as expected. So I manually added a bit of code into jquery.table2excel.min.js
.
From:
...
$(e.element).each(function (i, o) {
var tempRows = "";
$(o).find("tr").not(e.settings.exclude).each(function (i, p) {
...
to:
...
$(e.element).each(function (i, o) {
var tempRows = "";
var $tableRow = $(o).find("tr");
if($(o).find("table").length) {
$tableRow = $(o).find("table").find("tr");
}
$tableRow.not(e.settings.exclude).each(function (i, p) {
...
It's not very pretty but enough in my case.
@mueller90 Your solution worked PERFECTLY! I also had a page with multiple tables on it and decided to wrap them all in a single table so I could get them all to export. But it did some weird things and duplicated data. I implemented your solution and it worked exactly as I needed it to. You are a life-saver! Can't tell you how many hours I wasted struggling with this until I came across your solution. THANK YOU!!!!
@mueller90 If you go to the original file (not the resulting min.js) on this site (here), then hit "edit", GitHub will make it dead easy for you to "submit a PR" (pull request) with the proposed changes and you'll never leave the browser. Of course, you would ideally fork to your account, clone to a workspace (GitPod is awesome), make the change, test, build, commit, push, then come back to your fork of the project on GitHub and hit the button to "Submit a PR" and finish that quick process.
If nobody is interested, I'll see about integrating this later. I wish someone had told me the above years sooner, which is why I took the time to share it :)
@mueller90, I have another issue where I have a table that I want to export but as soon as the user added embedded tables within a cell, the resulting Excel file appears blank. As soon as we remove the embedded table it is fine. I tried adding the noExl class to the rows in the embedded table, but it didn't seem to work. Anyone have any insight into this issue?
I have different tables on the same page. How can I make both the tables exported into the same excel file on the click of a single button? I also have another constraint. The page is dynamic so I wouldn't know how many tables would appear on my page.