# TableExport

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

[![GitHub release](https://img.shields.io/github/release/clarketm/tableexport.svg)](/) [![Build Status](https://travis-ci.org/clarketm/TableExport.svg?branch=master)](https://travis-ci.org/clarketm/TableExport) [![Downloads](https://img.shields.io/npm/dt/tableexport.svg)](/) [![License](https://img.shields.io/npm/l/tableexport.svg)](/)

## Docs

* [Migrating from **3.x** to **4.x**?](/docs/migrating_v3_to_v4)
* [Migrating from **4.x** to **5.x**?](/docs/migrating_v4_to_v5)
* [`v3` docs](https://tableexport.v3.travismclarke.com/) and [README](https://github.com/clarketm/TableExport/tree/3.x.x#getting-started):
* [`v4` docs](https://tableexport.travismclarke.com/READMEv4.html) and [README](https://github.com/clarketm/TableExport/tree/4.x.x#getting-started):
* [`v5` docs](https://tableexport.travismclarke.com/) and [README](https://github.com/clarketm/TableExport/#getting-started):

## Getting Started

### Install manually using `<script>` tags

To use this library, include the [FileSaver.js](https://github.com/clarketm/FileSaver.js/) library, and [TableExport](https://tableexport.travismclarke.com) library before the closing `<body>` tag of your HTML document:

```markup
<script src="FileSaver.js"></script>
...
<script src="tableexport.js"></script>
```

### Install with Bower

```
$ bower install tableexport.js
```

### Install with npm

```
$ npm install tableexport
```

### CDN

|            |                         uncompressed                         |                                                                                                           compressed                                                                                                           |
| :--------: | :----------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|   **CSS**  | [🔗](https://unpkg.com/tableexport/dist/css/tableexport.css) |                                                                                [🔗](https://unpkg.com/tableexport/dist/css/tableexport.min.css)                                                                                |
|   **JS**   |  [🔗](https://unpkg.com/tableexport/dist/js/tableexport.js)  |                                                                                 [🔗](https://unpkg.com/tableexport/dist/js/tableexport.min.js)                                                                                 |
| **Images** |                               —                              | [🔗xlsx](https://unpkg.com/tableexport/dist/img/xlsx.svg)[🔗xls](https://unpkg.com/tableexport/dist/img/xls.svg)[🔗csv](https://unpkg.com/tableexport/dist/img/csv.svg)[🔗txt](https://unpkg.com/tableexport/dist/img/txt.svg) |

### Dependencies

#### Required:

* [FileSaver.js](https://github.com/clarketm/FileSaver.js/)

#### Optional:

* [jQuery](https://jquery.com) (1.2.1 or higher)
* [Bootstrap](http://getbootstrap.com/getting-started/#download) (3.1.0 or higher)

#### Add-Ons:

In order to provide **Office Open XML SpreadsheetML Format ( `.xlsx` )** support, you must include the following third-party library in your project before both [FileSaver.js](https://github.com/clarketm/FileSaver.js/) and [TableExport](https://tableexport.travismclarke.com).

* [xlsx.core.js](https://github.com/SheetJS/js-xlsx) by *SheetJS*

> Including `xlsx.core.js` is **NOT** necessary if installing with [`Bower`](/#install-with-bower) or [`npm`](/#install-with-npm)

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

#### Older Browsers:

To support legacy browsers ( **Chrome** < 20, **Firefox** < 13, **Opera** < 12.10, **IE** < 10, **Safari** < 6 ) include the [Blob.js](https://github.com/clarketm/Blob.js/) polyfill before the [FileSaver.js](https://github.com/clarketm/FileSaver.js/) script.

* [Blob.js](https://github.com/clarketm/Blob.js) by *eligrey* (forked by *clarketm*)

> Including `Blob.js` is **NOT** necessary if installing with [`Bower`](/#install-with-bower) or [`npm`](/#install-with-npm)

```markup
<script src="Blob.js"></script>
<script src="FileSaver.js"></script>
...
<script src="tableexport.js"></script>
```

## Usage

### JavaScript

To use this library, simple call the [`TableExport`](https://tableexport.travismclarke.com) constructor:

```javascript
new TableExport(document.getElementsByTagName("table"));

// OR simply

TableExport(document.getElementsByTagName("table"));

// OR using jQuery

$("table").tableExport();
```

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 filetype(s) of your choice.

```javascript
/* Defaults */
TableExport(document.getElementsByTagName("table"), {
  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: true)
  exportButtons: true,                // (Boolean), automatically generate the built-in export buttons for each of the specified formats (default: true)
  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)
  trimWhitespace: true,               // (Boolean), remove all leading/trailing newlines, spaces, and tabs from cell text in the exported file(s) (default: false)
  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')
});
```

> **Note:** to use the `xlsx` filetype, you must include [js-xlsx](https://github.com/SheetJS/js-xlsx/blob/master/dist/xlsx.core.min.js); reference the [`Add-Ons`](/#add-ons) section.

### Properties

* [`headers`](https://tableexport.v3.travismclarke.com/examples/headers_footers.html)
* [`footers`](https://tableexport.v3.travismclarke.com/examples/headers_footers.html)
* [`formats`](https://tableexport.v3.travismclarke.com/examples/formats-xlsx-xls-csv-txt.html)
* [`filename`](https://tableexport.v3.travismclarke.com/examples/filename.html)
* [`bootstrap`](https://tableexport.v3.travismclarke.com/examples/bootstrap.html)
* [`exportButtons`](https://tableexport.v3.travismclarke.com/examples/exportButtons.html)
* [`position`](https://tableexport.v3.travismclarke.com/examples/position.html)
* [`ignoreRows`](https://tableexport.v3.travismclarke.com/examples/ignore-row-cols-cells.html)
* [`ignoreCols`](https://tableexport.v3.travismclarke.com/examples/ignore-row-cols-cells.html)
* [`trimWhitespace`](https://tableexport.v3.travismclarke.com/examples/whitespace.html)
* [`RTL`](https://tableexport.v3.travismclarke.com/examples/right-to-left.html)
* [`sheetname`](https://tableexport.v3.travismclarke.com/examples/sheetname.html)

### Methods

TableExport supports additional methods (**getExportData**, **update**, **reset** and **remove**) to control the [`TableExport`](https://tableexport.travismclarke.com) instance after creation.

```javascript
/* First, call the `TableExport` constructor and save the return instance to a variable */
var table = TableExport(document.getElementById("export-buttons-table"));
```

#### [`getExportData`](https://tableexport.v3.travismclarke.com/examples/exportButtons.html)

```javascript
/* get export data */
var exportData = table.getExportData(); // useful for creating custom export buttons, i.e. when (exportButtons: false)

/*****************
 ** exportData ***
 *****************
{
    "export-buttons-table": {
        xls: {
            data: "...",
            fileExtension: ".xls",
            filename: "export-buttons-table",
            mimeType: "application/vnd.ms-excel"
        },
        ...
    }
};
*/
```

#### [`getFileSize`](https://tableexport.v3.travismclarke.com/examples/exportButtons.html)

```javascript
var tableId = "export-buttons-table";
var XLS = table.CONSTANTS.FORMAT.XLS;

/* get export data (see `getExportData` above) */
var exportDataXLS = table.getExportData()[tableId][XLS];

/* get file size (bytes) */
var bytesXLS = table.getFileSize(exportDataXLS.data, exportDataXLS.fileExtension);

/**********************************
 ** bytesXLS (file size in bytes)
 **********************************
352
*/
```

#### [`update`](https://tableexport.v3.travismclarke.com/examples/update_reset_remove.html)

```javascript
/* update */
table.update({
  filename: "newFile" // pass in a new set of properties
});
```

#### [`reset`](https://tableexport.v3.travismclarke.com/examples/update_reset_remove.html)

```javascript
/* reset */
table.reset(); // useful for a dynamically altered table
```

#### [`remove`](https://tableexport.v3.travismclarke.com/examples/update_reset_remove.html)

```javascript
/* remove */
table.remove(); // removes caption and buttons
```

### Settings

Below are some of the popular configurable settings to customize the functionality of the library.

#### [`ignoreCSS`](https://tableexport.v3.travismclarke.com/examples/ignore-row-cols-cells.html)

```javascript
/**
 * CSS selector or selector[] to exclude/remove cells (<td> or <th>) from the exported file(s).
 * @type {selector|selector[]}
 * @memberof TableExport.prototype
 */

// selector
TableExport.prototype.ignoreCSS = ".tableexport-ignore";

// selector[]
TableExport.prototype.ignoreCSS = [".tableexport-ignore", ".other-ignore-class"];

// OR using jQuery

// selector
$.fn.tableExport.ignoreCSS = ".tableexport-ignore";

// selector[]
$.fn.tableExport.ignoreCSS = [".tableexport-ignore", ".other-ignore-class"];
```

#### [`emptyCSS`](https://tableexport.v3.travismclarke.com/examples/ignore-row-cols-cells.html)

```javascript
/**
 * CSS selector or selector[] to replace cells (<td> or <th>) with an empty string in the exported file(s).
 * @type {selector|selector[]}
 * @memberof TableExport.prototype
 */

// selector
TableExport.prototype.emptyCSS = ".tableexport-empty";

// selector[]
TableExport.prototype.emptyCSS = [".tableexport-empty", ".other-empty-class"];

// OR using jQuery

// selector
$.fn.tableExport.emptyCSS = ".tableexport-empty";

// selector[]
$.fn.tableExport.emptyCSS = [".tableexport-empty", ".other-empty-class"];
```

```javascript
/* default charset encoding (UTF-8) */
TableExport.prototype.charset = "charset=utf-8";

/* default `filename` property if "id" attribute is unset */
TableExport.prototype.defaultFilename = "myDownload";

/* default class to style buttons when not using Bootstrap or the built-in export buttons, i.e. when (`bootstrap: false` & `exportButtons: true`)  */
TableExport.prototype.defaultButton = "button-default";

/* Bootstrap classes used to style and position the export button, i.e. when (`bootstrap: true` & `exportButtons: true`) */
TableExport.prototype.bootstrapConfig = ["btn", "btn-default", "btn-toolbar"];

/* row delimeter used in all filetypes */
TableExport.prototype.rowDel = "\r\n";
```

```javascript
/**
 * Format-specific configuration (default class, content, mimeType, etc.)
 * @memberof TableExport.prototype
 */
formatConfig: {
    /**
     * XLSX (Open XML spreadsheet) file extension configuration
     * @memberof TableExport.prototype
     */
    xlsx: {
        defaultClass: 'xlsx',
        buttonContent: 'Export to xlsx',
        mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
        fileExtension: '.xlsx'
    },
    xlsm: {
        defaultClass: 'xlsm',
        buttonContent: 'Export to xlsm',
        mimeType: 'application/vnd.ms-excel.sheet.macroEnabled.main+xml',
        fileExtension: '.xlsm'
    },
    xlsb: {
        defaultClass: 'xlsb',
        buttonContent: 'Export to xlsb',
        mimeType: 'application/vnd.ms-excel.sheet.binary.macroEnabled.main',
        fileExtension: '.xlsb'
    },
    /**
     * XLS (Binary spreadsheet) file extension configuration
     * @memberof TableExport.prototype
     */
    xls: {
        defaultClass: 'xls',
        buttonContent: 'Export to xls',
        separator: '\t',
        mimeType: 'application/vnd.ms-excel',
        fileExtension: '.xls',
        enforceStrictRFC4180: false
    },
    /**
     * CSV (Comma Separated Values) file extension configuration
     * @memberof TableExport.prototype
     */
    csv: {
        defaultClass: 'csv',
        buttonContent: 'Export to csv',
        separator: ',',
        mimeType: 'text/csv',
        fileExtension: '.csv',
        enforceStrictRFC4180: true
    },
    /**
     * TXT (Plain Text) file extension configuration
     * @memberof TableExport.prototype
     */
    txt: {
        defaultClass: 'txt',
        buttonContent: 'Export to txt',
        separator: '  ',
        mimeType: 'text/plain',
        fileExtension: '.txt',
        enforceStrictRFC4180: true
    }
},

//////////////////////////////////////////
// Configuration override example
//////////////////////////////////////////

/* Change the CSV (Comma Separated Values) `mimeType` to "application/csv" */
TableExport.prototype.formatConfig.xlsx.mimeType = "application/csv"
```

### CSS

[TableExport](https://tableexport.travismclarke.com) packages with customized [Bootstrap](http://getbootstrap.com/getting-started/#download) CSS stylesheets to deliver enhanced table and button styling. These styles can be *enabled* by initializing with the `bootstrap` property set to `true`.

```javascript
TableExport(document.getElementsByTagName("table"), {
  bootstrap: true
});
```

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

### Browser Support

|             | Chrome | Firefox |  IE | Opera | Safari |
| :---------: | :----: | :-----: | :-: | :---: | :----: |
| **Android** |    ✓   |    ✓    |  -  |   ✓   |    -   |
|   **iOS**   |    ✓   |    -    |  -  |   -   |    ✓   |
| **Mac OSX** |    ✓   |    ✓    |  -  |   ✓   |    ✓   |
| **Windows** |    ✓   |    ✓    |  ✓  |   ✓   |    ✓   |

> A full list of [browser support](https://github.com/clarketm/FileSaver.js#supported-browsers) can be found in the [FileSaver.js](https://github.com/clarketm/FileSaver.js) README. Some [legacy browsers](https://github.com/clarketm/FileSaver.js#supported-browsers) may require an additional third-party dependency: [Blob.js](https://github.com/clarketm/Blob.js/)

### Examples

#### Customizing Properties

* [`headers`](https://tableexport.v3.travismclarke.com/examples/headers_footers.html)
* [`footers`](https://tableexport.v3.travismclarke.com/examples/headers_footers.html)
* [`formats`](https://tableexport.v3.travismclarke.com/examples/formats-xlsx-xls-csv-txt.html)
* [`filename`](https://tableexport.v3.travismclarke.com/examples/filename.html)
* [`bootstrap`](https://tableexport.v3.travismclarke.com/examples/bootstrap.html)
* [`exportButtons`](https://tableexport.v3.travismclarke.com/examples/exportButtons.html)
* [`position`](https://tableexport.v3.travismclarke.com/examples/position.html)
* [`ignoreRows`](https://tableexport.v3.travismclarke.com/examples/ignore-row-cols-cells.html)
* [`ignoreCols`](https://tableexport.v3.travismclarke.com/examples/ignore-row-cols-cells.html)
* [`trimWhitespace`](https://tableexport.v3.travismclarke.com/examples/whitespace.html)
* [`RTL`](https://tableexport.v3.travismclarke.com/examples/right-to-left.html)
* [`sheetname`](https://tableexport.v3.travismclarke.com/examples/sheetname.html)

#### Customizing Settings

* [`ignoreCSS`](https://tableexport.v3.travismclarke.com/examples/ignore-row-cols-cells.html)
* [`emptyCSS`](https://tableexport.v3.travismclarke.com/examples/ignore-row-cols-cells.html)

#### Miscellaneous

* [`rowspan`](https://tableexport.v3.travismclarke.com/examples/rowspan-colspan.html)
* [`colspan`](https://tableexport.v3.travismclarke.com/examples/rowspan-colspan.html)
* [`cell data types`](https://tableexport.v3.travismclarke.com/examples/cell-data-types.html) (`string`, `number`, `boolean`, `date`)
* [`emoji`](https://tableexport.v3.travismclarke.com/examples/unicode-emoji.html)
* [`Arabic`](https://tableexport.v3.travismclarke.com/examples/arabic-language.html)

#### Skeletons

* [TableExport + RequireJS](https://github.com/clarketm/tableexport_requirejs_app) skeleton.
* [TableExport + Flask](https://github.com/clarketm/tableexport_flask_app) skeleton.
* [TableExport + Webpack 1](https://github.com/clarketm/tableexport_webpack-v1_app) skeleton.
* [TableExport + Angular 4 + Webpack 2](https://github.com/clarketm/tableexport_angular4_webpack2_app) skeleton.

### License

[TableExport](https://tableexport.travismclarke.com) is licensed under the terms of the [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0.html) License

### Going Forward

#### TODOs

* [x] Update JSDocs and TypScript definition file.
* [x] Fix bug with **CSV** and **TXT** `ignoreRows` and `ignoreCols` (rows/cols rendered as empty strings rather than being *removed*).
* [x] Reimplement and test the `update`, `reset`, and `remove` **TableExport** prototype properties without requiring jQuery.
* [x] Make jQuery as *peer dependency* and ensure proper **TableExport** rendering in browser, AMD, and CommonJS environments.
* [x] Force jQuery to be an optionally loaded module.
* [x] Use the enhanced [SheetJS](https://github.com/SheetJS/js-xlsx#supported-output-formats) `xls`, `csv`, and `txt` formats (exposed via `enforceStrictRFC4180` prototype property).
* [x] Allow `ignoreCSS` and `emptyCSS` to work with any `selector|selector[]` instead of solely a single CSS class.
* [x] Ensure (via testing) full consistency and backwards-compatibility for jQuery.
* [ ] Add **Export as PDF** support.

### Credits

Special thanks the the following contributors:

* [SheetJS](https://github.com/SheetJS) - js-xlsx
* [Eli Grey](https://github.com/eligrey) - FileSaver.js & Blob.js


# Migrating from 3.x to 4.x?

## Changelog

### Properties

1. [`bootstrap`](/#properties) default changed from `true` to `false`.
2. [`fileName`](/#properties) renamed to `filename`.
3. [`ignoreCSS`](/#properties) moved to [*settings*](/#settings) (i.e. prototype).
4. [`emptyCSS`](/#properties) moved to [*settings*](/#settings) (i.e. prototype).
5. [`exportButtons`](/#properties) added and has a default value of `true`.

### Methods

1. [`getExportData`](/#methods) added to allow direct access to the export data.

### Settings

1. [`defaultFileName`](/#settings) renamed to `defaultFilename`.
2. [`ignoreCSS`](/#properties) added (moved from [*properties*](/#properties)).
3. [`emptyCSS`](/#properties) added (moved from [*properties*](/#properties)).


# Migrating from 4.x to 5.x?

## Changelog

### Major Features

1. Cell merge support, using `rowspan` and `colspan` html attributes on table. [**v5.0.0-rc.1**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.1), [**v5.0.0-rc.3**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.3), [**v5.0.0-rc.6**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.6), [**v5.0.0-rc.8**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.8), [**v5.0.0-rc.9**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.9)

### Properties

1. `xlsx` has replaced `xls` as the default spreadsheet format. [**v5.0.0-rc.2**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.2)

```javascript
// (String[]), filetype(s) for the export, (default: ['xlsx', 'csv', 'txt'])
formats: ['xlsx', 'csv', 'txt'],
```

1. Two(2) new export formats have been added: `xlsm` and `xlsb`. [**v5.0.0-rc.4**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.4)
2. Both `csv` and `xls` formats now have a the `enforceStrictRFC4180` property set to `false`. [**v5.0.0-rc.4**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.4)

### Methods

1. `getFileSize` utility method to quickly [calculate the filesize](https://github.com/clarketm/TableExport/blob/v5.0.0-rc.1/examples/exportButtons.html) of a file export. [**v5.0.0-rc.1**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.1)
2. `getBinaryData` renamed to a more semantically correct `getRawData`

### Settings

1. [`ignoreCSS`](/#ignorecss) can now accept either a `selector` (e.g. `'.tableexport-ignore'`) or `selector[]` (e.g. `['.tableexport-ignore', '#ignore']`). [**v5.0.0-rc.7**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.7)

```javascript
/**
 * CSS selector or selector[] to exclude/remove cells from the exported file(s).
 * @type {selector|selector[]}
 * @memberof TableExport.prototype
 */
ignoreCSS: ".tableexport-ignore";
```

1. [`emptyCSS`](/#emptycss) can now accept either a `selector` (e.g. `'.tableexport-empty'`) or `selector[]` (e.g. `['.tableexport-empty', '#empty']`). [**v5.0.0-rc.7**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.7)

```javascript
/**
 * CSS selector or selector[] to replace cells with an empty string in the exported file(s).
 * @type {selector|selector[]}
 * @memberof TableExport.prototype
 */
emptyCSS: ".tableexport-empty";
```

1. `defaultCaptionClass` class is now configurable rather than statically set to the `.tableexport-caption` class. [**v5.0.0-rc.10**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.10)

```javascript
/**
 * Class applied to each table caption.
 * @memberof TableExport.prototype
 */
defaultCaptionClass: "tableexport-caption";
```

1. `storageKey` attribute is now configurable rather than statically set to the `tableexport-id` attribute. [**v5.0.0-rc.10**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.10)

```javascript
/**
 * Attribute applied to each export button element used to reference a Storage key.
 * @memberof TableExport.prototype
 */
storageKey: "tableexport-id";
```

1. `defaultNamespace` string is now configurable rather than statically set to the `te-` string. [**v5.0.0-rc.10**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.10)

```javascript
/**
 * Namespace (i.e. prefix) applied to each table UUID and Storage key.
 * @memberof TableExport.prototype
 */
defaultNamespace: "tableexport-";
```

1. `types` renamed to `typeConfig`. [**v5.0.0-rc.1**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.1)
2. `xlsx`, `xls`, `csv`, and `txt` prototype properties moved to nested under the `formatConfig` namespace. [**v5.0.0-rc.1**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.1)

### Miscellaneous

1. Improved error logging to the console, including more verbose error descriptions. [**v5.0.0-rc.4**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.4)
2. Serialized export data is now stored in Session Storage rather than Local Storage to prevent undesirable persistence. [**v5.0.0-rc.10**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.10)
3. Implement caching by maintaining unique reference to tables by `id`. The `tableKey` attribute is now used to uniquely identify table elements and hold either the table's `id` or a UUID generated from the `defaultNamespace` and a unique internal counter. [**v5.0.0-rc.10**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.10), [**v5.0.0-rc.11**](https://github.com/clarketm/TableExport/releases/tag/v5.0.0-rc.11)


# v3 docs

[![Build Status](https://travis-ci.org/clarketm/TableExport.svg?branch=3.x.x)](https://travis-ci.org/clarketm/TableExport)

## [TableExport](https://tableexport.v3.travismclarke.com)

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

> **Notice:** As of May 2017, [v3.3](https://github.com/clarketm/TableExport/releases/tag/v3.3.13) has be superceded by [v4](https://github.com/clarketm/TableExport/releases/tag/v4.0.11).

## Deprecation notice:

#### Below are the docs for [`v3.3.13`](/docs/readmev3).

#### Check out [`v5`](/) for the latest release.

#### Live Demo

A live, interactive demo can be found on the [**TableExport**](https://tableexport.v3.travismclarke.com/#live-demo) webpage.

### Getting Started

#### Download and Setup

To use this plugin, include the [jQuery](https://jquery.com) library, [FileSaver.js](https://github.com/clarketm/FileSaver.js/) script, and [TableExport.js](https://tableexport.v3.travismclarke.com) plugin before the closing `<body>` tag of your HTML document:

```markup
<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
```

#### [CDNjs](https://cdnjs.com/libraries/TableExport)

|            |                                     uncompressed                                    |                                                                                                                                                         compressed                                                                                                                                                         |
| :--------: | :---------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|   **CSS**  | [🔗](https://cdnjs.cloudflare.com/ajax/libs/TableExport/3.3.13/css/tableexport.css) |                                                                                                                   [🔗](https://cdnjs.cloudflare.com/ajax/libs/TableExport/3.3.13/css/tableexport.min.css)                                                                                                                  |
|   **JS**   |  [🔗](https://cdnjs.cloudflare.com/ajax/libs/TableExport/3.3.13/js/tableexport.js)  |                                                                                                                    [🔗](https://cdnjs.cloudflare.com/ajax/libs/TableExport/3.3.13/js/tableexport.min.js)                                                                                                                   |
| **Images** |                                          —                                          | [🔗xlsx](https://cdnjs.cloudflare.com/ajax/libs/TableExport/3.3.13/img/xlsx.svg)[🔗xls](https://cdnjs.cloudflare.com/ajax/libs/TableExport/3.3.13/img/xls.svg)[🔗csv](https://cdnjs.cloudflare.com/ajax/libs/TableExport/3.3.13/img/csv.svg)[🔗txt](https://cdnjs.cloudflare.com/ajax/libs/TableExport/3.3.13/img/txt.svg) |

#### [unpkg](https://unpkg.com/#/)

|            |                           uncompressed                          |                                                                                                                 compressed                                                                                                                 |
| :--------: | :-------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|   **CSS**  | [🔗](https://unpkg.com/tableexport@v3/dist/css/tableexport.css) |                                                                                     [🔗](https://unpkg.com/tableexport@v3/dist/css/tableexport.min.css)                                                                                    |
|   **JS**   |  [🔗](https://unpkg.com/tableexport@v3/dist/js/tableexport.js)  |                                                                                      [🔗](https://unpkg.com/tableexport@v3/dist/js/tableexport.min.js)                                                                                     |
| **Images** |                                —                                | [🔗xlsx](https://unpkg.com/tableexport@v3/dist/img/xlsx.svg)[🔗xls](https://unpkg.com/tableexport@v3/dist/img/xls.svg)[🔗csv](https://unpkg.com/tableexport@v3/dist/img/csv.svg)[🔗txt](https://unpkg.com/tableexport@v3/dist/img/txt.svg) |

#### Dependencies

**Required:**

* [jQuery](https://jquery.com) (1.2.1 or higher) `*`
* [FileSaver.js](https://github.com/clarketm/FileSaver.js/)

> `*` jQuery dependency requirement is removed as of [v4](https://github.com/clarketm/TableExport/tree/v4.0.11)

**Optional / Theming:**

* [Bootstrap](http://getbootstrap.com/getting-started/#download) (3.1.0 or higher)

**Add-Ons:**

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](https://github.com/clarketm/FileSaver.js/) and [TableExport.js](https://tableexport.v3.travismclarke.com).

* [xlsx.core.js](https://github.com/clarketm/js-xlsx) by *clarketm*

```markup
<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](https://github.com/clarketm/Blob.js/) polyfill before the [FileSaver.js](https://github.com/clarketm/FileSaver.js/) script.

Until [Safari](https://github.com/clarketm/FileSaver.js/issues/242) provides native support for either the [HTML5 download attribute](http://caniuse.com/#feat=download) or [service workers](http://caniuse.com/#search=service%20workers), limited `xlx` and `xlsx` support is provided by including the [Blob.js](https://github.com/clarketm/Blob.js/) polyfill, albeit the **filename** will always be labeled `Unknown`.

* [Blob.js](https://github.com/clarketm/Blob.js) by *clarketm*

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

### Usage

#### CSS

By default, [TableExport.js](https://tableexport.v3.travismclarke.com) utilizes the [Bootstrap](http://getbootstrap.com/getting-started/#download) CSS framework to deliver enhanced table and button styling. For non-Bootstrap projects, initialize with the `bootstrap` property set to `false`.

```javascript
$("table").tableExport({
  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.

#### JavaScript

To use the export plugin, just call:

```javascript
$("table").tableExport();
```

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.

```javascript
/* Defaults */
$("table").tableExport({
  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[]), filetype(s) 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 cells 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.

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

```javascript
/* update */
tables.update({
  fileName: "newFile" // pass in a new set of properties
});

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

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

#### Properties

A table of available properties and their usage can be found [**here**](https://tableexport.v3.travismclarke.com/#properties)

#### Methods

A table of available methods and their usage can be found [**here**](https://tableexport.v3.travismclarke.com/#methods)

#### Settings

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

```javascript
/* 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/vnd.ms-excel",
  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 that.

```javascript
/* 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** |    ✓   |    ✓    |  -  |   ✓   |     -     |
|   **iOS**   |    ✓   |    -    |  -  |   -   |     ✓     |
| **Mac OSX** |    ✓   |    ✓    |  -  |   ✓   |     ✓     |
| **Windows** |    ✓   |    ✓    |  ✓  |   ✓   |     ✓     |

\*only *partial* support for `xls` and `xlsx`: requires third-party dependency ([Blob.js](https://github.com/clarketm/Blob.js/))

#### Live Demo

A live, interactive demo can be found on the [**TableExport**](https://tableexport.v3.travismclarke.com/#live-demo) webpage.

**Examples:**

**Customizing Properties**

* [`headers`](https://tableexport.v3.travismclarke.com/examples/headers_footers.html)
* [`footers`](https://tableexport.v3.travismclarke.com/examples/headers_footers.html)
* [`formats`](https://tableexport.v3.travismclarke.com/examples/formats-xlsx-xls-csv-txt.html)
* [`filename`](https://tableexport.v3.travismclarke.com/examples/filename.html)
* [`bootstrap`](https://tableexport.v3.travismclarke.com/examples/bootstrap.html)
* [`exportButtons`](https://tableexport.v3.travismclarke.com/examples/exportButtons.html)
* [`position`](https://tableexport.v3.travismclarke.com/examples/position.html)
* [`ignoreRows`](https://tableexport.v3.travismclarke.com/examples/ignore-row-cols-cells.html)
* [`ignoreCols`](https://tableexport.v3.travismclarke.com/examples/ignore-row-cols-cells.html)
* [`trimWhitespace`](https://tableexport.v3.travismclarke.com/examples/whitespace.html)

**Customizing Settings**

* [`ignoreCSS`](https://tableexport.v3.travismclarke.com/examples/ignore-row-cols-cells.html)
* [`emptyCSS`](https://tableexport.v3.travismclarke.com/examples/ignore-row-cols-cells.html)

**Miscellaneous**

* [`Arabic`](https://tableexport.v3.travismclarke.com/examples/arabic-language.html)
* [`emoji`](https://tableexport.v3.travismclarke.com/examples/unicode-emoji.html)
* [`cell data types`](https://tableexport.v3.travismclarke.com/examples/cell-data-types.html) (`string`, `number`, `boolean`, `date`)

**Skeletons**

* [TableExport + RequireJS](https://github.com/clarketm/tableexport_requirejs_app) skeleton.
* [TableExport + Flask](https://github.com/clarketm/tableexport_flask_app) skeleton.
* [TableExport + Webpack 1](https://github.com/clarketm/tableexport_webpack-v1_app) skeleton.
* [TableExport + Angular 4 + Webpack 2](https://github.com/clarketm/tableexport_angular4_webpack2_app) skeleton.

#### License

[TableExport.js](https://tableexport.v3.travismclarke.com) is licensed under the terms of the [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0.html) License

#### :star: Credits

Special thanks the the following contributors:

* [John Resig](https://github.com/jeresig) - jQuery
* [SheetJS](https://github.com/SheetJS) - js-xlsx
* [Eli Grey](https://github.com/eligrey) - FileSaver.js & Blob.js


# v4 docs

## [TableExport](https://tableexport.travismclarke.com)

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

[![GitHub release](https://img.shields.io/github/release/clarketm/tableexport.svg)](/docs/readmev4) [![Build Status](https://travis-ci.org/clarketm/TableExport.svg?branch=master)](https://travis-ci.org/clarketm/TableExport) [![Downloads](https://img.shields.io/npm/dt/tableexport.svg)](/docs/readmev4) [![License](https://img.shields.io/npm/l/tableexport.svg)](/docs/readmev4)

## Deprecation notice:

#### Below are the docs for [`v4.0.11`](/docs/readmev4).

#### Check out [`v5`](/) for the latest release.

### Docs

* [Migrating from **3.x** to **4.x**?](/docs/migrating_v3_to_v4)
* [`v3` docs](https://tableexport.v3.travismclarke.com/) and [README](https://github.com/clarketm/TableExport/tree/3.x.x#getting-started):
* [`v4` docs](https://tableexport.travismclarke.com/READMEv4.html) and [README](https://github.com/clarketm/TableExport/tree/4.x.x#getting-started):

### Getting Started

#### Install manually using `<script>` tags

To use this library, include the [FileSaver.js](https://github.com/clarketm/FileSaver.js/) library, and [TableExport](https://tableexport.travismclarke.com) library before the closing `<body>` tag of your HTML document:

```markup
<script src="FileSaver.js"></script>
...
<script src="tableexport.js"></script>
```

#### Install with Bower

```
$ bower install tableexport.js
```

#### Install with npm

```
$ npm install tableexport
```

#### CDN

**CDNjs**

|            |                                     uncompressed                                    |                                                                                                                                                         compressed                                                                                                                                                         |
| :--------: | :---------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|   **CSS**  | [🔗](https://cdnjs.cloudflare.com/ajax/libs/TableExport/4.0.11/css/tableexport.css) |                                                                                                                   [🔗](https://cdnjs.cloudflare.com/ajax/libs/TableExport/4.0.11/css/tableexport.min.css)                                                                                                                  |
|   **JS**   |  [🔗](https://cdnjs.cloudflare.com/ajax/libs/TableExport/4.0.11/js/tableexport.js)  |                                                                                                                    [🔗](https://cdnjs.cloudflare.com/ajax/libs/TableExport/4.0.11/js/tableexport.min.js)                                                                                                                   |
| **Images** |                                          —                                          | [🔗xlsx](https://cdnjs.cloudflare.com/ajax/libs/TableExport/4.0.11/img/xlsx.svg)[🔗xls](https://cdnjs.cloudflare.com/ajax/libs/TableExport/4.0.11/img/xls.svg)[🔗csv](https://cdnjs.cloudflare.com/ajax/libs/TableExport/4.0.11/img/csv.svg)[🔗txt](https://cdnjs.cloudflare.com/ajax/libs/TableExport/4.0.11/img/txt.svg) |

**unpkg**

|            |                         uncompressed                         |                                                                                                           compressed                                                                                                           |
| :--------: | :----------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|   **CSS**  | [🔗](https://unpkg.com/tableexport/dist/css/tableexport.css) |                                                                                [🔗](https://unpkg.com/tableexport/dist/css/tableexport.min.css)                                                                                |
|   **JS**   |  [🔗](https://unpkg.com/tableexport/dist/js/tableexport.js)  |                                                                                 [🔗](https://unpkg.com/tableexport/dist/js/tableexport.min.js)                                                                                 |
| **Images** |                               —                              | [🔗xlsx](https://unpkg.com/tableexport/dist/img/xlsx.svg)[🔗xls](https://unpkg.com/tableexport/dist/img/xls.svg)[🔗csv](https://unpkg.com/tableexport/dist/img/csv.svg)[🔗txt](https://unpkg.com/tableexport/dist/img/txt.svg) |

#### Dependencies

**Required:**

* [FileSaver.js](https://github.com/clarketm/FileSaver.js/)

**Optional:**

* [jQuery](https://jquery.com) (1.2.1 or higher)
* [Bootstrap](http://getbootstrap.com/getting-started/#download) (3.1.0 or higher)

**Add-Ons:**

In order to provide **Office Open XML SpreadsheetML Format ( `.xlsx` )** support, you must include the following third-party library in your project before both [FileSaver.js](https://github.com/clarketm/FileSaver.js/) and [TableExport](https://tableexport.travismclarke.com).

* [xlsx.core.js](https://github.com/SheetJS/js-xlsx) by *SheetJS*

> Including `xlsx.core.js` is **NOT** necessary if installing with [`Bower`](/docs/readmev4#install-with-bower) or [`npm`](/docs/readmev4#install-with-npm)

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

**Older Browsers:**

To support legacy browsers ( **Chrome** < 20, **Firefox** < 13, **Opera** < 12.10, **IE** < 10, **Safari** < 6 ) include the [Blob.js](https://github.com/clarketm/Blob.js/) polyfill before the [FileSaver.js](https://github.com/clarketm/FileSaver.js/) script.

* [Blob.js](https://github.com/clarketm/Blob.js) by *eligrey* (forked by *clarketm*)

> Including `Blob.js` is **NOT** necessary if installing with [`Bower`](/docs/readmev4#install-with-bower) or [`npm`](/docs/readmev4#install-with-npm)

```markup
<script src="Blob.js"></script>
<script src="FileSaver.js"></script>
...
<script src="tableexport.js"></script>
```

### Usage

#### JavaScript

To use this library, simple call the [`TableExport`](https://tableexport.travismclarke.com) constructor:

```javascript
new TableExport(document.getElementsByTagName("table"));

// OR simply

TableExport(document.getElementsByTagName("table"));

// OR using jQuery

$("table").tableExport();
```

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 filetype(s) of your choice.

```javascript
/* Defaults */
TableExport(document.getElementsByTagName("table"), {
  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: ["xls", "csv", "txt"], // (String[]), filetype(s) for the export, (default: ['xls', 'csv', 'txt'])
  filename: "id", // (id, String), filename for the downloaded file, (default: 'id')
  bootstrap: false, // (Boolean), style buttons using bootstrap, (default: true)
  exportButtons: true, // (Boolean), automatically generate the built-in export buttons for each of the specified formats (default: true)
  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)
  trimWhitespace: true // (Boolean), remove all leading/trailing newlines, spaces, and tabs from cell text in the exported file(s) (default: false)
});
```

> **Note:** to use the `xlsx` filetype, you must include [js-xlsx](https://github.com/SheetJS/js-xlsx/blob/master/dist/xlsx.core.min.js); reference the [`Add-Ons`](/docs/readmev4#add-ons) section.

#### Properties

* [`headers`](https://tableexport.v3.travismclarke.com/examples/headers_footers.html)
* [`footers`](https://tableexport.v3.travismclarke.com/examples/headers_footers.html)
* [`formats`](https://tableexport.v3.travismclarke.com/examples/formats-xlsx-xls-csv-txt.html)
* [`filename`](https://tableexport.v3.travismclarke.com/examples/filename.html)
* [`bootstrap`](https://tableexport.v3.travismclarke.com/examples/bootstrap.html)
* [`exportButtons`](https://tableexport.v3.travismclarke.com/examples/exportButtons.html)
* [`position`](https://tableexport.v3.travismclarke.com/examples/position.html)
* [`ignoreRows`](https://tableexport.v3.travismclarke.com/examples/ignore-row-cols-cells.html)
* [`ignoreCols`](https://tableexport.v3.travismclarke.com/examples/ignore-row-cols-cells.html)
* [`trimWhitespace`](https://tableexport.v3.travismclarke.com/examples/whitespace.html)

#### Methods

TableExport supports additional methods (**getExportData**, **update**, **reset** and **remove**) to control the [`TableExport`](https://tableexport.travismclarke.com) instance after creation.

```javascript
/* First, call the `TableExport` constructor and save the return instance to a variable */
var table = TableExport(document.getElementById("export-buttons-table"));
```

**getExportData**

```javascript
/* get export data */
var exportData = table.getExportData(); // useful for creating custom export buttons, i.e. when (exportButtons: false)

/*****************
 ** exportData ***
 *****************
{
    "export-buttons-table": {
        xls: {
            data: "...",
            fileExtension: ".xls",
            filename: "export-buttons-table",
            mimeType: "application/vnd.ms-excel"
        },
        ...
    }
};
*/
```

**update**

```javascript
/* update */
table.update({
  filename: "newFile" // pass in a new set of properties
});
```

**reset**

```javascript
/* reset */
table.reset(); // useful for a dynamically altered table
```

**remove**

```javascript
/* remove */
table.remove(); // removes caption and buttons
```

#### Settings

Below are some of the popular configurable settings to customize the functionality of the library.

**ignoreCSS**

```javascript
/* class selector to exclude/remove cells (<td> or <th>) or rows (<tr>) from the exported file(s). */
TableExport.prototype.ignoreCSS = "tableexport-ignore";

// OR using jQuery

$.fn.tableExport.ignoreCSS = "tableexport-ignore";
```

**emptyCSS**

```javascript
/* class selector to replace cells (<td> or <th>) with an empty string (i.e. "blank cell") in the exported file(s). */
TableExport.prototype.emptyCSS = "tableexport-empty";

// OR using jQuery

$.fn.tableExport.emptyCSS = "tableexport-empty";
```

```javascript
/* default charset encoding (UTF-8) */
TableExport.prototype.charset = "charset=utf-8";

/* default `filename` property if "id" attribute is unset */
TableExport.prototype.defaultFilename = "myDownload";

/* default class to style buttons when not using Bootstrap or the built-in export buttons, i.e. when (`bootstrap: false` & `exportButtons: true`)  */
TableExport.prototype.defaultButton = "button-default";

/* Bootstrap classes used to style and position the export button, i.e. when (`bootstrap: true` & `exportButtons: true`) */
TableExport.prototype.bootstrapConfig = ["btn", "btn-default", "btn-toolbar"];

/* row delimeter used in all filetypes */
TableExport.prototype.rowDel = "\r\n";
```

```javascript
/* Format-specific configuration (default class, content, and separator) */

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

/* Excel Binary spreadsheet (.xls) */
TableExport.prototype.xls = {
  defaultClass: "xls",
  buttonContent: "Export to xls",
  separator: "\t",
  mimeType: "application/vnd.ms-excel",
  fileExtension: ".xls"
};

/* Comma Separated Values (.csv) */
TableExport.prototype.csv = {
  defaultClass: "csv",
  buttonContent: "Export to csv",
  separator: ",",
  mimeType: "application/csv",
  fileExtension: ".csv"
};

/* Plain Text (.txt) */
TableExport.prototype.txt = {
  defaultClass: "txt",
  buttonContent: "Export to txt",
  separator: "  ",
  mimeType: "text/plain",
  fileExtension: ".txt"
};
```

#### CSS

[TableExport](https://tableexport.travismclarke.com) packages with customized [Bootstrap](http://getbootstrap.com/getting-started/#download) CSS stylesheets to deliver enhanced table and button styling. These styles can be *enabled* by initializing with the `bootstrap` property set to `true`.

```javascript
TableExport(document.getElementsByTagName("table"), {
  bootstrap: true
});
```

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

#### Browser Support

|             | Chrome | Firefox |  IE | Opera | Safari |
| :---------: | :----: | :-----: | :-: | :---: | :----: |
| **Android** |    ✓   |    ✓    |  -  |   ✓   |    -   |
|   **iOS**   |    ✓   |    -    |  -  |   -   |    ✓   |
| **Mac OSX** |    ✓   |    ✓    |  -  |   ✓   |    ✓   |
| **Windows** |    ✓   |    ✓    |  ✓  |   ✓   |    ✓   |

> A full list of [browser support](https://github.com/clarketm/FileSaver.js#supported-browsers) can be found in the [FileSaver.js](https://github.com/clarketm/FileSaver.js) README. Some [legacy browsers](https://github.com/clarketm/FileSaver.js#supported-browsers) may require an additional third-party dependency: [Blob.js](https://github.com/clarketm/Blob.js/)

#### Examples

**Customizing Properties**

* [`headers`](https://tableexport.v3.travismclarke.com/examples/headers_footers.html)
* [`footers`](https://tableexport.v3.travismclarke.com/examples/headers_footers.html)
* [`formats`](https://tableexport.v3.travismclarke.com/examples/formats-xlsx-xls-csv-txt.html)
* [`filename`](https://tableexport.v3.travismclarke.com/examples/filename.html)
* [`bootstrap`](https://tableexport.v3.travismclarke.com/examples/bootstrap.html)
* [`exportButtons`](https://tableexport.v3.travismclarke.com/examples/exportButtons.html)
* [`position`](https://tableexport.v3.travismclarke.com/examples/position.html)
* [`ignoreRows`](https://tableexport.v3.travismclarke.com/examples/ignore-row-cols-cells.html)
* [`ignoreCols`](https://tableexport.v3.travismclarke.com/examples/ignore-row-cols-cells.html)
* [`trimWhitespace`](https://tableexport.v3.travismclarke.com/examples/whitespace.html)

**Customizing Settings**

* [`ignoreCSS`](https://tableexport.v3.travismclarke.com/examples/ignore-row-cols-cells.html)
* [`emptyCSS`](https://tableexport.v3.travismclarke.com/examples/ignore-row-cols-cells.html)

**Miscellaneous**

* [`cell data types`](https://tableexport.v3.travismclarke.com/examples/cell-data-types.html) (`string`, `number`, `boolean`, `date`)
* [`emoji`](https://tableexport.v3.travismclarke.com/examples/unicode-emoji.html)
* [`Arabic`](https://tableexport.v3.travismclarke.com/examples/arabic-language.html)

**Skeletons**

* [TableExport + RequireJS](https://github.com/clarketm/tableexport_requirejs_app) skeleton.
* [TableExport + Flask](https://github.com/clarketm/tableexport_flask_app) skeleton.
* [TableExport + Webpack 1](https://github.com/clarketm/tableexport_webpack-v1_app) skeleton.
* [TableExport + Angular 4 + Webpack 2](https://github.com/clarketm/tableexport_angular4_webpack2_app) skeleton.

#### License

[TableExport](https://tableexport.travismclarke.com) is licensed under the terms of the [Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0.html) License

#### Going Forward

**TODOs**

* [x] Update JSDocs and TypScript definition file.
* [x] Fix bug with **CSV** and **TXT** `ignoreRows` and `ignoreCols` (rows/cols rendered as empty strings rather than being *removed*).
* [x] Reimplement and test the `update`, `reset`, and `remove` **TableExport** prototype properties without requiring jQuery.
* [x] Make jQuery as *peer dependency* and ensure proper **TableExport** rendering in browser, AMD, and CommonJS environments.
* [x] Force jQuery to be an optionally loaded module.
* [x] Use the enhanced [SheetJS](https://github.com/SheetJS/js-xlsx#supported-output-formats) `xls`, `csv`, and `txt` formats (exposed via `enforceStrictRFC4180` prototype property).
* [x] Allow `ignoreCSS` and `emptyCSS` to work with any `selector|selector[]` instead of solely a single CSS class.
* [x] Ensure (via testing) full consistency and backwards-compatibility for jQuery.
* [ ] Add **Export as PDF** support.

#### Credits

Special thanks the the following contributors:

* [SheetJS](https://github.com/SheetJS) - js-xlsx
* [Eli Grey](https://github.com/eligrey) - FileSaver.js & Blob.js


# v5 docs


# Install manually using script tags


# Install with Bower


# Install with npm


# CDN


# Required


# Optional


# Add-Ons


# Older Browsers


# JavaScript


# Properties


# Methods


# Settings


# CSS


# Browser Support


# Customizing Properties


# Customizing Settings


# Miscellaneous


# Skeletons


# License


# Going Forward


# Credits


