Last post Dec 09, 2019 10:07 AM by Yongqing Yu
Member
6 Points
87 Posts
Dec 09, 2019 09:11 AM|Ravindranath M|LINK
How to export html table data to excel / csv using jquery.
Contributor
3710 Points
1043 Posts
Dec 09, 2019 10:07 AM|Yongqing Yu|LINK
Hi SaiRam,
To implement this function, you can download Table2excel jquery plugin ,here is the link you can refer and download it :
Exporting HTML Table To Excel Using jQuery
You can also refer to the following code:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="../Scripts/jquery-3.0.0.min.js"></script> <script src="../Table2excel/jquery.table2excel.js"></script> <script type="text/javascript"> $(function () { $("#btnExport").click(function () { $("#tblData").table2excel({ name: "Table2Excel", filename: "myFileName", fileext: ".xls" }); }) }) </script> </head> <body> <form id="form1" runat="server"> <div> <table id="tblData"> <tr> <td>ID</td> <td>Name</td> <td>Age</td> </tr> <tr> <td>1</td> <td>AAA</td> <td>21</td> </tr> <tr> <td>2</td> <td>BBB</td> <td>22</td> </tr> <tr> <td>3</td> <td>CCC</td> <td>21</td> </tr> <tr> <td>4</td> <td>DDD</td> <td>21</td> </tr> </table> <button id="btnExport">EXPORT </button> </div> </form> </body> </html>
Here is the result :
Best Regards,
YongQing.
Member
6 Points
87 Posts
Export HTML to excel
Dec 09, 2019 09:11 AM|Ravindranath M|LINK
How to export html table data to excel / csv using jquery.
Contributor
3710 Points
1043 Posts
Re: Export HTML to excel
Dec 09, 2019 10:07 AM|Yongqing Yu|LINK
Hi SaiRam,
To implement this function, you can download Table2excel jquery plugin ,here is the link you can refer and download it :
Exporting HTML Table To Excel Using jQuery
You can also refer to the following code:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="../Scripts/jquery-3.0.0.min.js"></script> <script src="../Table2excel/jquery.table2excel.js"></script> <script type="text/javascript"> $(function () { $("#btnExport").click(function () { $("#tblData").table2excel({ name: "Table2Excel", filename: "myFileName", fileext: ".xls" }); }) }) </script> </head> <body> <form id="form1" runat="server"> <div> <table id="tblData"> <tr> <td>ID</td> <td>Name</td> <td>Age</td> </tr> <tr> <td>1</td> <td>AAA</td> <td>21</td> </tr> <tr> <td>2</td> <td>BBB</td> <td>22</td> </tr> <tr> <td>3</td> <td>CCC</td> <td>21</td> </tr> <tr> <td>4</td> <td>DDD</td> <td>21</td> </tr> </table> <button id="btnExport">EXPORT </button> </div> </form> </body> </html>
Here is the result :
Best Regards,
YongQing.
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.