2017 © Pedro Pelรกez
 

library tableexport

image

intelogie/tableexport

  • Monday, July 30, 2018
  • by bgauthier
  • Repository
  • 1 Watchers
  • 0 Stars
  • 70 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 155 Forks
  • 0 Open issues
  • 14 Versions
  • 21 % Grown

The README.md

Build Status, (*1)

TableExport

The simple, easy-to-implement plugin to export HTML tables to xlsx, xls, csv, and txt files, (*2)

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:, (*3)

<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

uncompressed compressed
CSS ๐Ÿ”— ๐Ÿ”—
JS ๐Ÿ”— ๐Ÿ”—
Images โ€” ๐Ÿ”—xlsx๐Ÿ”—xls๐Ÿ”—csv๐Ÿ”—txt

Dependencies

Required:
Optional / Theming:
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 and TableExport.js., (*4)

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

To support older browsers ( Firefox < 20, Opera < 15, Safari < 6 ) also include Blob.js before the FileSaver.js script., (*5)

<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 utilizes the Bootstrap CSS framework to deliver enhanced table and button styling. For non-Bootstrap projects, initialize with the bootstrap property set to false., (*6)

$("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., (*7)

JavaScript

To use the export plugin, just call:, (*8)

$("table").tableExport();

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

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., (*10)

/* 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
    ignoreCols: null,                   // (Number, Number[]), column indices to exclude from the exported file
    ignoreCSS: ".tableexport-ignore"    // (selector, selector[]), selector(s) to exclude from the exported file
});

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

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

/* Run plugin and save it to a variable */
var tables = $("table").tableExport();
/* 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:, (*13)

www.clarketravis.com/tableexport

Methods

A table of available methods and their usage can be found here:, (*14)

www.clarketravis.com/tableexport

Settings

Each button is assigned a default class and default content based on its respective filetype and corresponding css styles., (*15)

/* 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., (*16)

/* 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 โœ“ โœ“ โœ“ โœ“ โœ“

*requires third-party dependencies, (*17)

Live Demo

A live, interactive demo can be found here:, (*18)

www.clarketravis.com/tableexport

License

TableExport.js is licensed under the terms of the MIT License, (*19)

Credits

The Versions

30/07 2018

dev-dev

dev-dev

  Sources   Download

01/04 2018

v3.1.0

3.1.0.0

  Sources   Download

01/04 2018

v3.1.1

3.1.1.0

  Sources   Download

01/04 2018

v3.1.2

3.1.2.0

  Sources   Download

01/04 2018

v3.1.3

3.1.3.0

  Sources   Download

01/04 2018

v3.2.0

3.2.0.0

  Sources   Download

01/04 2018

v3.2.1

3.2.1.0

  Sources   Download

01/04 2018

v3.2.2

3.2.2.0

  Sources   Download

01/04 2018

v3.2.3

3.2.3.0

  Sources   Download

01/04 2018

v3.2.4

3.2.4.0

  Sources   Download

01/04 2018

v3.2.5

3.2.5.0

  Sources   Download

01/04 2018

3.2.6

3.2.6.0

  Sources   Download

01/04 2018

v3.0.0

3.0.0.0

  Sources   Download

01/07 2016

dev-master

9999999-dev

  Sources   Download