Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
183
rated 0 times [  187] [ 4]  / answers: 1 / hits: 23627  / 8 Years ago, fri, january 22, 2016, 12:00:00

I've been looking into some jQuery plugins that are capable of doing this. I decided to use the one at http://www.jqueryscript.net/table/Export-Html-Table-To-Excel-Spreadsheet-using-jQuery-table2excel.html and I've followed its instructions as closely as possible. I've been testing this plugin but every time I click the button to export, nothing happens. The table is populated using PHP (which is pulling data from a MySQL server) and the following is the script I currently have in place.



<script>
$(document).ready(function() {

//activate footable jquery plugin (this is the dynamic table on the report page with search and sorting functions)
$('.footable').footable();


});

//Prepare table2excel plugin (clicking the export button will send the main table to an Excel spreadsheet)
$(button).click(function(){
$(.footable).table2excel({
//Exclude CSS class specific to this plugin
exclude: .noExl,
name: Excel Document Name
});
});

</script>


The footable display hasn't changed at all after I added the new code. What can I do? I keep thinking I've just misplaced the table2excel block but even when I had it inside the ready(function(){}) block, nothing happened.


More From » jquery

 Answers
12

Managed to fix it. I initially suspected that not putting it inside the ready function would be a problem and thought it would fix the issue, but that was only part of the problem. I also forgot a comma. The finished result is as follows.



<script>
$(document).ready(function() {

//activate footable jquery plugin (this is the dynamic table on the report page with search and sorting functions)
$('.footable').footable();

//Prepare table2excel plugin (clicking the export button will send the main table to an Excel spreadsheet)
$(button.excelexport).click(function(){
$(#footable).table2excel({
//Exclude CSS class specific to this plugin
exclude: .noExl,
name: Merchandising Report,
filename: merchReportTable
});
});

});

</script>

[#63598] Thursday, January 21, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kiyam

Total Points: 448
Total Questions: 96
Total Answers: 92

Location: Philippines
Member since Sat, Jul 11, 2020
4 Years ago
;