Skip to content Skip to sidebar Skip to footer

Export To Excel Using Javascript

I want to use javascript, to export the html table to excel. I used below script. Its working fine. Since few cells have special characters, I have escaped them. However, rows and

Solution 1:

Think this is what you want: http://jsfiddle.net/9zaH7/

  1. takes table html, wraps in new table - this part seems not to be needed, but maybe you need to remove the styling/class?

  2. escapes the complete table to the form text field.

    $(document).ready(function(){
    $("#exportToExcel").click(function() {

        var data='<table border="1" class="csstable">'+$("#myTable").html()+'</table>';
        data=escape(data);
                $('body').prepend("<form method='post' action='exporttoexcel.php' style='display:block' id='ReportTableData'><input type='text' name='tableData' value='"+data+"'></form>");
    
         return false;
    });});
    

Post a Comment for "Export To Excel Using Javascript"