1

I am trying to export an HTML Table to Ms Excel Using This Demo but it is exporting a file called "download" (without excel file extensions)and when I double click on that it opens like a text file. Can you please let me know why this is happening?

$("#btnExport").click(function(e) {
    window.open('data:application/vnd.ms-excel,' + $('#dvData').html());
    e.preventDefault();
});

Thanks

Suffii
  • 5,694
  • 15
  • 55
  • 92
  • Most likely because your "download" button is inside your "dvData" `div`. Move your download button outside that `div`. – Dave Sep 29 '14 at 22:16
  • Thanks dave I moved the button on the top page before the div element but still gettong a file with no extension! – Suffii Sep 29 '14 at 22:24
  • For the filename you are at the mercy of the browser. See [here](http://stackoverflow.com/questions/7034754/how-to-set-a-file-name-using-window-open) and [here](http://stackoverflow.com/questions/283956/is-there-any-way-to-specify-a-suggested-filename-when-using-data-uri) – Dave Sep 29 '14 at 22:31

0 Answers0