Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to do dynamic data table to export excel , pdf using jQuery in .net

function ExportExcel() {
$("#btnExportExcel").click(function (e) {
window.open('data:application/vnd.ms-
Posted
Updated 1-Aug-14 1:24am

first of all you have to retrive datatable in form of json or xml an client side using ajax.
after that use this..

JavaScript
window.open('data:application/vnd.ms-excel,' + your data(in json or xml format));



Another way create html table as per your datatable formate (hidden).

JavaScript
window.open('data:application/vnd.ms-excel,' + $('#yourDivData').html());
 
Share this answer
 
For more better way checkout this....


HTML
<a href="http://ngiriraj.com/pages/htmltable_export/demo.php">http://ngiriraj.com/pages/htmltable_export/demo.php</a>[<a href="http://ngiriraj.com/pages/htmltable_export/demo.php" target="_blank" title="New Window">^</a>]
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900