TableExport.js


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


Download

Getting Started

Download and Setup


Copy
<script type="text/javascript" src="/path/to/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="/path/to/jquery.tableexport.js"></script>


Install with Bower




Dependencies


In order to download Excel(.xlsx) files, the following plugins are required:

  • xlsx.core.js
  • Blob.js
  • FileSaver.js
  • Export2Excel.js


Usage

Methods




Settings




CSS


Copy
/* [String] column separator, [default: ","] */
.top,
.head {
    caption-side: top;
}

.bottom {
    caption-side: bottom;
}


JavaScript


Copy
$("table").tableExport();
Copy
$("table").tableExport({
    separator: ",",                         // [String] column separator, [default: ","]
    headings: true,                         // [Boolean], display table headings (th elements) in the first row, [default: true]
    buttonContent: "Export",                // [String], text/html to display in the export button, [default: "Export file"]
    addClass: "",                           // [String], additional button classes to add, [default: ""]
    defaultClass: "btn",                    // [String], the default button class, [default: "btn"]
    defaultTheme: "btn-default",            // [String], the default button theme, [default: "btn-default"]
    type: "csv",                            // [xlsx, csv, txt], type of file, [default: "csv"]
    fileName: "export",                     // [id, name, String], filename for the downloaded file, [default: "export"]
    position: "bottom",                     // [top, bottom], position of the caption element relative to table, [default: "bottom"]
    stripQuotes: true                       // [Boolean], remove containing double quotes (.txt files ONLY), [default: true]
});


Browser Support


Chrome Firefox Internet Explorer Opera Safari
Android N/A N/A
iOS N/A
Mac OS X
Windows


Live Demo

Demo 1


Countries By Population

Rank Country Population % of world population Date
1 China 1,370,570,000 18.9% June 24, 2015
2 India 1,273,140,000 17.6% June 24, 2015
3 United States 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

Demo 2


Countries By Population

Rank Country Population % of world population Date
1 China 1,370,570,000 18.9% June 24, 2015
2 India 1,273,140,000 17.6% June 24, 2015
3 United States 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

Demo 3


Countries By Population

Rank Country Population % of world population Date
1 China 1,370,570,000 18.9% June 24, 2015
2 India 1,273,140,000 17.6% June 24, 2015
3 United States 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

Demo 4


Countries By Population

Rank Country Population % of world population Date
1 China 1,370,570,000 18.9% June 24, 2015
2 India 1,273,140,000 17.6% June 24, 2015
3 United States 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


License


sample

sample

sample

sample

sample



Credits