clarketm / TableExport

The simple, easy-to-implement library to export HTML tables to xlsx, xls, csv, and txt files.
https://tableexport.travismclarke.com/
Apache License 2.0
888 stars 289 forks source link

How to download the excel file without adding to DOM? #182

Open TheInvoker opened 5 years ago

TheInvoker commented 5 years ago

I'm using this right now to force the download automatically. How can I do this in the more cleaner intended way? (because it feels like a hack right now)

        exportToExcel : function(table, filename, sheetname) {
            var g = $(table).hide();
            $("body").append(g);
            $(g).tableExport({
                filename: filename,
                formats: ["xlsx"],
                sheetname : sheetname
            });
            g.find("caption button").click();
            g.remove();
        },