0

I have a sample fiddle here where i can print the html table to pdf format as,

function printpage() {
    var data = '<table border="1" cellspacing="0"><tr><td colspan="4">Sample Report</td></tr>' + document.getElementsByTagName('table')[0].innerHTML + '</table>';
    data += '<br/><button onclick="window.print()"  class="noprint">Print the Report</button>';
    data += '<style type="text/css" media="print"> .noprint {visibility: hidden;} </style>';
    myWindow = window.open('', '', 'width=800,height=600');
    myWindow.innerWidth = screen.width;
    myWindow.innerHeight = screen.height;
    myWindow.screenX = 0;
    myWindow.screenY = 0;
    myWindow.document.write(data);
    myWindow.document.close();
    myWindow.focus();
}

how can i add one more button inside the print preview page using which i can export the same table in csv/xls format?

mpsbhat
  • 2,733
  • 12
  • 49
  • 105
  • Possible duplicate of [Export to CSV using jQuery and html](https://stackoverflow.com/questions/16078544/export-to-csv-using-jquery-and-html) – Dave Jarvis Apr 21 '18 at 00:55

1 Answers1

0

Go through below link . You will get the solution

  `http://jsfiddle.net/terryyounghk/KPEGU/`  
Chirag
  • 455
  • 1
  • 4
  • 18