1

I have a HTML table that I want to export to Excel using the table2excel plugin. Unfortunately when I download it, the generated Excel file has an error. How can I fix that?

I have created a JSFiddle.

Basically to call the plugin you just need to do this:

$("#downloadIntermidiate").click(function(){

                        $("#intermediateTable").table2excel({
                              exclude: ".noExl",
                        name: "Excel Document intermediateTable"
                        }); 

                         });

Here #intermediateTable is the id of the table that has to be printed.

Anders
  • 8,307
  • 9
  • 56
  • 88
Vikram Anand Bhushan
  • 4,836
  • 15
  • 68
  • 130
  • 1
    If I change the file name from `.xlsx` to `.xls` I get a warning message, but the file opens and looks OK. – Anders Oct 09 '15 at 07:01

1 Answers1

4

You fiddle works Fine, Just Changed .xlsx to .xls , it exports

function getFileName(settings) {
    return ( settings.filename ? settings.filename : "table2excel") + ".xls";
 }

Check this fiddle-> https://jsfiddle.net/t8tegrad/8/

Anoop B.K
  • 1,484
  • 2
  • 17
  • 31
  • 2
    I get a warning message saying that the file extension do not match the content when I open the file downloaded from the fiddle. It opens and looks OK, though. – Anders Oct 09 '15 at 07:03
  • @Anirudh Well I am very new to this plugin , I have been using PHP2Excel till now , But I am gonna except your answer , Feel free to update it in case you find out the problem .about warning . – Vikram Anand Bhushan Oct 09 '15 at 07:05
  • yea, because the format is different. if u click ok, it opens because u have called.xls whcih is an excel format. – Anoop B.K Oct 09 '15 at 07:06
  • .xlsx format can be used if u are using excel version above 2007. – Anoop B.K Oct 09 '15 at 07:14
  • When we open the excel file it through error of corrupt file and extension error any solution for this? – sunakshi verma Jun 20 '17 at 11:54