Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Tables #39

Open
khamarzama opened this issue May 28, 2016 · 7 comments
Open

Multiple Tables #39

khamarzama opened this issue May 28, 2016 · 7 comments

Comments

@khamarzama
Copy link

khamarzama commented May 28, 2016

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.

@misvijay
Copy link

@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.

@macieljr
Copy link
Contributor

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.

@vietnguyen1992
Copy link

No answer for this question, i have the same issue :(

@mueller90
Copy link

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.

@ghost
Copy link

ghost commented Jun 9, 2021

@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!!!!

@rainabba
Copy link
Owner

rainabba commented Jun 9, 2021

@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 :)

@ghost
Copy link

ghost commented Sep 24, 2021

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants