UNPKG

tableexport

Version:

The simple, easy-to-implement library to export HTML tables to xlsx, xls, csv, and txt files

124 lines (113 loc) 4.81 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Defaults</title> <link href="../dist/css/tableexport.min.css" rel="stylesheet"> <link href="./examples.css" rel="stylesheet"> </head> <body id="default"> <h1>Defaults</h1> <main> <article> <pre> headers: true, footers: true, formats: ['xlsx', 'csv', 'txt'], filename: 'id', bootstrap: false, exportButtons: true, position: 'bottom', ignoreRows: null, ignoreCols: null, trimWhitespace: true, RTL: false, sheetname: 'id' </pre> </article> <article> <table id="default-table" width="50%"> <thead> <tr> <th> Name </th> <th>Position</th> <th>Age</th> <th>Salary</th> </tr> </thead> <tbody> <tr> <td>Thor Walton</td> <td>Regional Director</td> <td>45</td> <td>$98,540</td> </tr> <tr> <td>Travis Clarke</td> <td>Software Engineer</td> <td>30</td> <td>$275,000</td> </tr> <tr> <td>Suki Burks</td> <td>Office Manager</td> <td>22</td> <td>$67,670</td> </tr> </tbody> <tfoot> <tr> <td class="disabled"></td> <td class="disabled"></td> <td class="disabled"></td> <th>$441,210</th> </tr> </tfoot> </table> </article> </main> <hr> <script type="text/javascript" src="../bower_components/js-xlsx/dist/xlsx.core.min.js"></script> <script type="text/javascript" src="../bower_components/blobjs/Blob.min.js"></script> <script type="text/javascript" src="../bower_components/file-saverjs/FileSaver.min.js"></script> <script type="text/javascript" src="../dist/js/tableexport.min.js"></script> <script type="text/javascript" src="../assets/js/analytics.js"></script> <script> var DefaultTable = document.getElementById('default-table'); new TableExport(DefaultTable, { headers: true, // (Boolean), display table headers (th or td elements) in the <thead>, (default: true) footers: true, // (Boolean), display table footers (th or td elements) in the <tfoot>, (default: false) formats: ['xlsx', 'csv', 'txt'], // (String[]), filetype(s) for the export, (default: ['xlsx', 'csv', 'txt']) filename: 'id', // (id, String), filename for the downloaded file, (default: 'id') bootstrap: false, // (Boolean), style buttons using bootstrap, (default: false) position: 'bottom', // (top, bottom), position of the caption element relative to table, (default: 'bottom') ignoreRows: null, // (Number, Number[]), row indices to exclude from the exported file(s) (default: null) ignoreCols: null, // (Number, Number[]), column indices to exclude from the exported file(s) (default: null) ignoreCSS: '.tableexport-ignore', // (selector, selector[]), selector(s) to exclude cells from the exported file(s) (default: '.tableexport-ignore') emptyCSS: '.tableexport-empty', // (selector, selector[]), selector(s) to replace cells with an empty string in the exported file(s) (default: '.tableexport-empty') trimWhitespace: true, // (Boolean), remove all leading/trailing newlines, spaces, and tabs from cell text in the exported file(s) (default: true) RTL: false, // (Boolean), set direction of the worksheet to right-to-left (default: false) sheetname: 'id' // (id, String), sheet name for the exported spreadsheet, (default: 'id') }); // **** jQuery ************************** // $(DefaultTable).tableExport({ // headers: true, // footers: true, // formats: ['xlsx', 'csv', 'txt'], // filename: 'id', // bootstrap: true, // position: 'bottom', // ignoreRows: null, // ignoreCols: null, // ignoreCSS: '.tableexport-ignore', // emptyCSS: '.tableexport-empty', // trimWhitespace: false, // RTL: false, // sheetname: 'id' // }); // ************************************** </script> </body> </html>