kayalshri / tableExport.jquery.plugin

"table2JSON", "table2XML", "table2PNG","table2CSV","table2Excel","table2Word","table2Powerpoint","table2txt","table2PDF"
1.26k stars 583 forks source link

Export To Excel #25

Open woniel123mx opened 9 years ago

woniel123mx commented 9 years ago

Hi good evening, i make a change when export to excel, is better make a Blob object :)

var ext = "doc"; if(defaults.type == "excel"){ ext = ".xls"; }

var blob = new Blob([excelFile], { type: 'text/plain' }); var a = document.createElement('a'); a.href = window.URL.createObjectURL(blob); a.download = defaults.tableName + ext; a.click();

//window.open('data:application/vnd.ms-'+defaults.type+';filename=otro.doc;' + base64data);

ngreis commented 9 years ago

Can you please explain where you edited the code?

tafs7 commented 9 years ago

@woniel123mx that doesn't seem to do anything on IE11...but it works in Chrome.

tafs7 commented 9 years ago

@woniel123mx also doesn't work in Firefox (latest). In fact neither the original solution (window.open) nor the Blob API solution above work in Firefox or IE11

tmorehouse commented 9 years ago

I just use the following,rather than window.open:

    window.location.href = 'data:application/vnd.ms-'+defaults.type+';filename=otro.doc;'+base64data;

Appears to work well and doesn't pen up another window temporarily.