Fork me on GitHub


The simple, easy-to-implement jQuery plugin that allows you to quickly and dynamically convert HTML tables to Excel spreadsheets .xls .xlsx, comma separated values .csv, and plain text .txt in only one line of code.

Deprecation notice:

May 05, 2017

Below are the docs for v3.3.13. For the v5 docs (latest stable), please click the button above.

Getting Started

Download and Setup

To use this plugin, include the jQuery library, FileSaver.js script, and TableExport.js plugin before the closing <body> tag of your HTML document:

<script src="jquery.js"></script>
<script src="FileSaver.js"></script>
<script src="tableexport.js"></script>

Install with Bower

$ bower install tableexport.js

Install with npm

$ npm install tableexport

Use with a CDN

uncompressed compressed
CSS tableexport.css tableexport.min.css
JavaScript tableexport.js tableexport.min.js
Images xlsx.svg  xls.svg  csv.svg  txt.svg



* jQuery dependency requirement is removed as of 4.0.0

Optional / Theming:


In order to provide Office Open XML SpreadsheetML Format ( .xlsx ) support, you must include the following third-party script to your project before FileSaver.js and TableExport.js

<script src="xlsx.core.js"></script>
<script src="FileSaver.js"></script>
<script src="tableexport.js"></script>

Older Browsers:

To support older browsers ( Chrome < 20, Firefox < 13, Opera < 12.10, IE < 10, Safari < 6 ) include the Blob.js polyfill before the FileSaver.js script.

Until Safari provides native support for either the HTML5 download attribute or service workers, limited xlx and xlsx support is provided by including the Blob.js polyfill, albeit the filename will always be labeled Unknown.

<script src="xlsx.core.js"></script>
<script src="Blob.js"></script>
<script src="FileSaver.js"></script>
<script src="tableexport.js"></script>



By default, TableExport.js utilizes the Bootstrap CSS framework to deliver enhanced table and button styling. For non-Bootstrap projects, initialize with the bootstrapproperty set to false.

    bootstrap: false

When used along with Bootstrap, there are four custom classes .xlsx, .xls, .csv, .txt providing button styling for each of the exportable filetypes.

with Bootstrap ( bootstrap: true )

without Bootstrap ( bootstrap: false )


To use the export plugin, just call:


Additional properties can be passed in to customize the look and feel of your tables, buttons, and exported data.

Notice that by default, TableExport will create export buttons for three different filetypes xls, csv, txt. You can choose which buttons to generate by setting the formats property to the filetypes of your choice.

/* Defaults */
    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[]), filetypes 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(s)
    ignoreCols: null,                  // (Number, Number[]), column indices to exclude from the exported file(s)
    ignoreCSS: ".tableexport-ignore",  // (selector, selector[]), selector(s) to exclude from the exported file(s)
    emptyCSS: ".tableexport-empty",    // (selector, selector[]), selector(s) to replace cells with an empty string in the exported file(s)
    trimWhitespace: false              // (Boolean), remove all leading/trailing newlines, spaces, and tabs from cell text in the exported file(s)

Note:  to use the xlsx filetype, you must include the third-party scripts listed in the Dependencies section.

TableExport supports additional methods (update, reset and remove) to control it after creation.

/* Run plugin and save it to a variable */
var tables = $("table").tableExport();

/* update */
    fileName: "newFile"         // pass in a new set of options

/* reset */
tables.tableExport.reset();     // useful for a dynamically altered table

/* remove */
tables.tableExport.remove();     // removes caption and buttons


Below is the list of available properties:

Property Description Values Default
headings Boolean
indicates whether or not to export the table rows in the <thead>.
true: include headings
false: exclude headings
footers Boolean
indicates whether or not to export the table rows in the <tfoot>.
true: include headings
false: exclude headings
formats String[]
filetypes to export. A button will be created for each type in the array.
xlsx: Open XML spreadsheet
xls: Binary spreadsheet
csv: comma separated value
txt: plain text
["xls", "csv", "txt"]
fileName String
filename for the exportable files. A value of "id" will assign the id attribute of the table as the filename.
id: table id attribute
"myFile"  // string
bootstrap Boolean
indicates whether or not to style the buttons using the Bootstrap CSS framework.
true: use Bootstrap* styling
false: use default styling
position String
position of the caption element relative to table.
top: position above table
bottom: position below table
ignoreRows Number, Number[]
zero-based row index (indices) to exclude from the exported file(s). This does not include any table headings (<th>).
null or false: include all rows
3  // integer
[0,2]  // integer[]
ignoreCols Number, Number[]
zero-based column index (indices) to exclude from the exported file(s).
null or false: include all columns
0  // integer
[1,2]  // integer[]
ignoreCSS selector, selector[]
excludes <tr>, <td>, or <th> elements matching the provided selector(s) from the exported file(s).
"tr.hide"  // selector
[".hide", ".ignore"]  // selector[]
emptyCSS selector, selector[]
replaces <tr>, <td>, or <th> elements matching the provided selector(s), with an empty string in exported file(s).
"tr.empty"  // selector
[".empty", ".blank"]  // selector[]
trimWhitespace Boolean
remove all leading & trailing newlines, spaces, and tabs from cell text in exported file(s).
true: trim whitespace
false: preserve whitespace
* requires the Bootstrap CSS framework


TableExport supports additional methods to control it after creation:

.tableExport.update( [ properties ] )

Argument Type Description Required Default
properties Object An object of TableExport property-value pairs No none




Each button is assigned a default class and default content based on its respective filetype and corresponding css styles.

/* default class, content, and separator for each export type */

/* Excel Open XML spreadsheet (.xlsx) */
$.fn.tableExport.xlsx = {
    defaultClass: "xlsx",
    buttonContent: "Export to xlsx",
    mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
    fileExtension: ".xlsx"

/* Excel Binary spreadsheet (.xls) */
$.fn.tableExport.xls = {
    defaultClass: "xls",
    buttonContent: "Export to xls",
    separator: "\t",
    mimeType: "application/",
    fileExtension: ".xls"

/* Comma Separated Values (.csv) */
$.fn.tableExport.csv = {
    defaultClass: "csv",
    buttonContent: "Export to csv",
    separator: ",",
    mimeType: "application/csv",
    fileExtension: ".csv"

/* Plain Text (.txt) */
$.fn.tableExport.txt = {
    defaultClass: "txt",
    buttonContent: "Export to txt",
    separator: "  ",
    mimeType: "text/plain",
    fileExtension: ".txt"

Below are additional defaults to support the functionality of the plugin.

/* default charset encoding (UTF-8) */
$.fn.tableExport.charset = "charset=utf-8";

/* default filename if "id" attribute is set and undefined */
$.fn.tableExport.defaultFileName = "myDownload";

/* default class to style buttons when not using bootstrap  */
$.fn.tableExport.defaultButton = "button-default";

/* bootstrap classes used to style and position the export buttons */
$.fn.tableExport.bootstrap = ["btn", "btn-default", "btn-toolbar"];

/* row delimeter used in all filetypes */
$.fn.tableExport.rowDel = "\r\n";

Browser Support

Chrome Firefox IE Opera Safari *
Android N/A N/A
Mac OS X
* only partial support for xls and xlsx : requires third-party dependency (Blob.js)

Live Demo

Countries By Population

Rank Country Population % of world population Date
1 中华人民共和国 (People's Republic of China) 1,370,570,000 18.9% June 24, 2015
2 India 1,273,140,000 17.6% June 24, 2015
3 United States "USA" 321,268,000 4.43% June 24, 2015
4 Indonesia 255,461,700 3.52% July 1, 2015
5 Brazil 204,503,000 2.82% June 24, 2015
6 Pakistan 190,156,000 2.62% June 24, 2015
7 Nigeria 183,523,000 2.53% July 1, 2015
8 Bangladesh 126,880,000 2.19% June 24, 2015


TableExport.js is licensed under the terms of the Apache-2.0 License
The Apache-2.0 License
Copyright (c) 2017 - Travis Clarke -
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.


John Resig - jQuery
SheetJS - js-xlsx
Eli Grey - FileSaver.js & Blob.js
Freepik - svg icons