table-exporter

0.0.12 • Public • Published

table-exporter

Export HTML Table (Table Tag, Table CSS) to a file (JSON, CSV, etc.)

Usage

node bin/export_table table.html 

Examples

 
var exporter = require('table-exporter');
 
/**
 *  exporter = function (html, tableSelector, targetSelector, callback)
 */
 var html = `<html>
                <body>
                    <table>
                        <tr>
                            <th>Column One</th>
                            <th>Column Two</th>
                            <th>Column Three</th>
                        </tr>
                        <tr>
                            <td>Row 1 Col 1</td>
                            <td>Row 1 Col 2</td>
                            <td>Row 1 Col 3 </td>
                        </tr>
                        <tr>
                            <td>Row 2 Col 1</td>
                            <td>Row 2 Col 2</td>
                            <td>Row 2 Col 3</td>
                        </tr>
                        <tr>
                            <td>Row 3 Col 1</td>
                            <td>Row 3 Col 2</td>
                            <td>Row 3 Col 3</td>
                        </tr>
                    </table>
                </body>
                </html>`
 
 var tables = exporter.export(html);
 
// output is an array of table that are found
// for example
// tables === [{"headers":["Column One","Column Two","Column Three"],"rows":[["Row 1 Col 1","Row 1 Col 2","Row 1 Col 3 "],["Row 2 Col 1","Row 2 Col 2","Row 2 Col 3"],["Row 3 Col 1","Row 3 Col 2","Row 3 Col 3"]]}]
 

Use in a brower

Install Browserify

npm install --global browserify

Produce Table Exporter Javascript Bundle

browserify web.js -o web/te.js
<!DOCTYPE>
<html>
    <head>
    <script src="../te.js"></script> 
    </head>
    <body>
    </body>
</html>

Chrome Extension

Maintainer

Eric Tang @ TYO Lab

Package Sidebar

Install

npm i table-exporter

Weekly Downloads

2

Version

0.0.12

License

MIT

Unpacked Size

900 kB

Total Files

15

Last publish

Collaborators

  • e_tang