We will learn here how how to export data to excel using JQuery , In this article you can export Gridview data or html table data into excel.
Let's start now
Step 1: Design basic HTML table as in the following snippet to make sure that table should be present under DIV element and provide an ID to that DIV element.
- <div id="content" style="width: 1200px; margin: 30px auto;">
- <table style="width:100%">
- <tr>
- <td>Jill</td>
- <td>Smith</td>
- <td>50</td>
- </tr>
- <tr>
- <td>Eve</td>
- <td>Jackson</td>
- <td>94</td>
- </tr>
- </table>
- </div>
- <input type="button" id="btn_excel" value="exportexcel"/>
- $("#btn_excel").click(function(e) {
- window.open('data:application/vnd.ms- excel,' + encodeURIComponent($('#content').html())); // content is the id of the DIV element
- e.preventDefault();
- });
I hope this helps u.
Happy coding!

Balasubramanian RPosted Nov 25, 2021, 1:38 PM
Export with iso format css for numbers how to do
kamlesh batkiPosted Sep 10, 2020, 5:01 AM
It's not working
taqi uddinPosted Oct 25, 2018, 12:41 PM
I need only visible rows to be exported, any solution?
srinivas prabhuPosted Aug 1, 2018, 4:07 AM
It's not working