Search code examples
javascriptexport-to-excel

I'm using calrketm/TableExport , why xlsx button not showing up?


i need to export html table data to xlsx. i am using calrketm/TableExport on github... but, i can't see Export to Xlsx button. What should i do? here is the output


Solution

  • This is because by default "xlsx" is not included. See the default below:

    $("table").tableExport({
        headings: true,                     // (Boolean), display table headings (th/td elements) in the <thead>
        footers: true,                      // (Boolean), display table footers (th/td elements) in the <tfoot>
        formats: ["xls", "csv", "txt"],     // (String[]), filetype(s) for the export
        fileName: "id",                     // (id, String), filename for the downloaded file
        bootstrap: true,                    // (Boolean), style buttons using bootstrap
        position: "bottom",                 // (top, bottom), position of the caption element relative to table
        ignoreRows: null,                   // (Number, Number[]), row indices to exclude from the exported file
        ignoreCols: null,                   // (Number, Number[]), column indices to exclude from the exported file
        ignoreCSS: ".tableexport-ignore",   // (selector, selector[]), selector(s) to exclude cells from the exported file
        emptyCSS: ".tableexport-empty",     // (selector, selector[]), selector(s) to replace cells with an empty string in the exported file
        trimWhitespace: false               // (Boolean), remove all leading/trailing newlines, spaces (including non-breaking spaces), and tabs from cell text
    });
    

    To include "xlsx" you should supply the following config.

    $("table").tableExport({
        formats: ["xls", "csv", "txt", "xlsx"]
    });