0

I populate data in table through jquery now i want to export that data in pdf /excel For this I try this link export data link

I try this work successfully then i this code add in my file

    <a href="#" onclick="$('#tabledata').tableExport({ type: 'excel', escape: 'false' });">XLS</a>

<a href="#" onclick="$('#tabledata').tableExport({ type: 'pdf', escape: 'false' });">PDF</a>

I create table with the help pf jquery

 success: function (result) {
             var final = JSON.parse(result.d).response;

             console.log(JSON.parse(result.d).response);
             $("#tabledata").empty();

             if (final.length > 0) {
                 $("#tabledata").append(
          "<tr><th>ID</th><th>Owner</th><th>RegNo</th></tr>");

                 for (var i = 0; i < final.length; i++) {

                     if (final[i] !== null) {
                         $("#tabledata").append("<tbody><tr><td>" +
                                             final[i][0] + "</td> <td>" +
                                             final[i][1] + "</td> <td>" +
                                             final[i][2] + "</td></tr></tbody>");

                     }
                 }
                 $("#tabledata tr:first").addClass('GridviewScrollHeader');
                 $("#tabledata tr").addClass('GridviewScrollItem');
                 $("#tabledata").addClass('GridviewScrollPager');

             }

ok now this get data with header also but now the problem is there is only two columns display in pdf third column is not display i think because of formatting check image image

so how i done this

Any solution

user6628729
  • 323
  • 1
  • 7
  • 25

1 Answers1

0

If you are allowed to use plugin , please use datatable plugin. Its is quite easy to use and allows us to export html table data into pdf , txt, xls

below is the sample for reference from the original link :

$(document).ready(function() {
    $('#example').DataTable( {
        dom: 'Bfrtip',
        buttons: [
            'copyHtml5',
            'excelHtml5',
            'csvHtml5',
            'pdfHtml5'
        ]
    } );
} );

Reference site with complete example can be found here: https://datatables.net/extensions/buttons/examples/html5/simple.html

Aditya
  • 2,385
  • 18
  • 25
  • how button is generate i create the button or created by js files? and second thing is when i try this conflict occur i put shieldui date-picker so these js files on head and PDF export files are on body at the bottom but conflict occur when i check f12 shows WebForm1.aspx:432 Uncaught TypeError: $(...).shieldDatePicker is not a function – user6628729 Aug 04 '16 at 07:33