Export all instances of data table on page to one Excel file

Export all instances of data table on page to one Excel file

asifdataasifdata Posts: 1Questions: 1Answers: 0
edited May 2020 in Free community support

I would like to export all instances of data tables on one page to one excel file. Below is my JSP code where a data table is shown for every company.I am using a Jquery plugin called "table2Excel" which works great but only the first data table is exported in excel file. Could someone please help how all data tables can be exported in one excel file.

<button>Export</button>

 <c:forEach items="${companyForm.companies}" var="company" varStatus="status">


                <table   class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                //data here                         
                </table>

</c:forEach>
<script>

    $('button').click(function() {

            $('table.table-bordered').table2excel({

            exclude: ".noExl",
            name: "somename",
            filename: "somefilename",
            preserveColors:true


        });
    })

 </script>

Edited by Kevin:  Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

Answers

  • kthorngrenkthorngren Posts: 20,299Questions: 26Answers: 4,769

    It doesn't look like you are using any Datatable functionality for this process. Seems like all you need to do is loop through all of the tables with a specific class. Here is a SO thread that may help.

    You will need to look through the docs for table2excel to determine how to combine the data from multiple tables into one export.

    Kevin

This discussion has been closed.