jQuery TableHTMLExport Plugin

Jquery plugin that exports an HTML table to JSON, CSV, TXT, or PDF and force the browser to download the generated file.

Live Demo

# First Last Handle
1 Mark Otto @mdo
2 Jacob Thornton @fat
3 Larry the Bird @twitter

How to Use

Add the css below to your html page

<link rel="stylesheet" media="all" href="bootstrap4.min.css" />

Create a container where you want to render table

<table class="table" id="example">
    <thead class="thead-dark">
            <th scope="col">#</th>
            <th scope="col">First</th>
            <th scope="col">Last</th>
            <th scope="col">Handle</th>
            <th scope="row">1</th>
            <th scope="row">2</th>
            <th scope="row">3</th>
            <td>the Bird</td>
<p class="lead">
    <button id="json" class="btn btn-primary">TO JSON</button>
    <button id="csv" class="btn btn-info">TO CSV</button>
    <button id="pdf" class="btn btn-danger">TO PDF</button>

Load jQuery library together with the TableHTMLExport library into your code

<script src="src/slim.min.js"></script>
<script src="src/jspdf.min.js"></script>
<script src="src/jspdf.plugin.autotable.min.js"></script>
<script src="src/tableHTMLExport.js"></script>
    $('#json').on('click', function () {
            type: 'json',
            filename: 'sample.json'
    $('#csv').on('click', function () {
            type: 'csv',
            filename: 'sample.csv'
    $('#pdf').on('click', function () {
            type: 'pdf',
            filename: 'sample.pdf'

Source Code


For more Advanced Usages, please check the demo page or visit the official website.