export html table data to an Excel file? Yes today I m going to share this topic with you by providing a very intracting idea to export html table data into Excel sheet.
It is a plugin name “table2excel” it is very handy to use or integrate with any project written in html. By using this jQuery to exporting data from html table to excel sheet will be very easy and just one click away.
How to use it:
You have to include jQuery library and the jQuery table2excel plugin with your web project or website.
1 2 |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="../dist/jquery.table2excel.min.js"></script> |
After that create a button to click to “Export” html table data to excel sheet.
1 |
<button>Export</button> |
Call the plugin on the table and done.
1 2 3 4 5 6 7 8 |
$(function() { $("button").click(function(){ $("#table2excel").table2excel({ exclude: ".noExl", name: "Excel Document Name" }); }); }); |
You can add the CSS class ‘noExl’ to any tr tags to ignore the specified table data while exporting.
1 2 3 4 5 6 |
<tr class="noExl"> <th>#</th> <th>Column heading</th> <th>Column heading</th> <th>Column heading</th> </tr> |