All Projects → OmbraDiFenice → table2csv

OmbraDiFenice / table2csv

Licence: GPL-3.0 license
A simple jQuery plugin to convert HTML tables to CSV

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to table2csv

Fancytree
JavaScript tree view / tree grid plugin with support for keyboard, inline editing, filtering, checkboxes, drag'n'drop, and lazy loading
Stars: ✭ 2,398 (+7393.75%)
Mutual labels:  jquery-plugin
Percircle
⭕️ CSS percentage circle built with jQuery
Stars: ✭ 217 (+578.13%)
Mutual labels:  jquery-plugin
Ajax Live Search
AJAX Live Search is a PHP search form that similar to Google Autocomplete feature displays the result as you type.
Stars: ✭ 238 (+643.75%)
Mutual labels:  jquery-plugin
Jquery Resizable
A small jQuery plug-in to make DOM components resizable
Stars: ✭ 206 (+543.75%)
Mutual labels:  jquery-plugin
Amaranjs
Nice, sleek and stylish notifications.
Stars: ✭ 214 (+568.75%)
Mutual labels:  jquery-plugin
Jquery Multiselect
Turn a multiselect list into a nice and easy to use list with checkboxes.
Stars: ✭ 221 (+590.63%)
Mutual labels:  jquery-plugin
Disableautofill.js
Disable form auto-fill and auto-complete functions.
Stars: ✭ 201 (+528.13%)
Mutual labels:  jquery-plugin
ferris-wheel-jquery-plugin
A jquery plugin that adds a cool button to your web page.
Stars: ✭ 13 (-59.37%)
Mutual labels:  jquery-plugin
Bootstrap Checkbox
A checkbox component based on Bootstrap framework.
Stars: ✭ 214 (+568.75%)
Mutual labels:  jquery-plugin
Jquery Viewer
A jQuery plugin wrapper for Viewer.js.
Stars: ✭ 235 (+634.38%)
Mutual labels:  jquery-plugin
Gridtab
GridTab is a lightweight jQuery plugin to create grid based responsive tabs https://gopalraju.github.io/gridtab
Stars: ✭ 210 (+556.25%)
Mutual labels:  jquery-plugin
Loadgo
LoadGo is a Javascript plugin for using your logo as a progress bar.
Stars: ✭ 214 (+568.75%)
Mutual labels:  jquery-plugin
Roundslider
roundSlider - A free jQuery plugin
Stars: ✭ 232 (+625%)
Mutual labels:  jquery-plugin
Jquery Aniview
A jQuery plugin that works in harmony with animate.css in order to enable animations only when content comes into view.
Stars: ✭ 205 (+540.63%)
Mutual labels:  jquery-plugin
Ziptastic Jquery Plugin
This is a jQuery plugin that shows how Ziptastic could be used.
Stars: ✭ 244 (+662.5%)
Mutual labels:  jquery-plugin
Sliderawesome
A slider plugin full of various effects and styles that allows any customization. 一款可定制的风格效果多样的轮播图插件。
Stars: ✭ 204 (+537.5%)
Mutual labels:  jquery-plugin
Magnify
A lightweight jQuery magnifying glass zoom plugin.
Stars: ✭ 218 (+581.25%)
Mutual labels:  jquery-plugin
vicopo
API HTTP et Script pour trouver les villes à partir d'un code postal et code postaux à partir d'une ville
Stars: ✭ 27 (-15.62%)
Mutual labels:  jquery-plugin
Modaal
An accessible dialog window library for all humans.
Stars: ✭ 2,702 (+8343.75%)
Mutual labels:  jquery-plugin
Liteaccordion
A lightweight horizontal accordion plugin for jQuery.
Stars: ✭ 234 (+631.25%)
Mutual labels:  jquery-plugin

table2csv

Build Status

A simple jQuery plugin to convert HTML tables to CSV. It allows you to download or display the content of a regular HTML table as a CSV file.

It is useful if you want to quickly build a downloadable report from a web based tool.

Check out the live example page.

Installation

You can install this plugin from npm

$ npm install table2csv

Usage

Import jQuery and this script

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="/path/to/table2csv.min.js"></script>

where /path/to/ will be the path where you installed the plugin. If you installed it through npm it will probably be node_modules/table2csv/dist

then invoke the table2csv() function on the jQuery object of the table

$("table").first().table2csv(); // default action is 'download'

The plugin currently convert just one table at a time and must be called directly on the table you want to convert. These limits will hopefully be removed in future versions.

table2csv() accepts 2 arguments, both optional:

table2csv(action, options)

See below for the description.

Example

<table id="tab">
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr>
    <td>Alfreds Futterkiste</td>
    <td>Maria Anders</td>
    <td>Germany</td>
  </tr>
  <tr>
    <td>Ernst Handel</td>
    <td>Roland Mendel</td>
    <td>Austria</td>
  </tr>
  <tr>
    <td>Island Trading</td>
    <td>Helen Bennett</td>
    <td>UK</td>
  </tr>
  <tr>
    <td>Magazzini Alimentari Riuniti</td>
    <td>Giovanni Rovelli</td>
    <td>Italy</td>
  </tr>
</table>
// download the content of table "tab"
$("#tab").table2csv(); // default action is 'download'

This will start the download of a file called 'table.csv' which will contain the following:

"Company","Contact","Country"
"Alfreds Futterkiste","Maria Anders","Germany"
"Ernst Handel","Roland Mendel","Austria"
"Island Trading","Helen Bennett","UK"
"Magazzini Alimentari Riuniti","Giovanni Rovelli","Italy"

You can change the name of the downloaded file and other settings using the options.

Actions

  • 'download'
    This is the default action (i.e. the one performed if you call table2csv() without any argument). Convert the table to a csv and start the download of the file. The file name can be specified in the options (default is table.csv).

  • 'output'
    With this action the csv output is not downloaded as a file, but appended as text inside the html page. Use the appendTo option to specify the jQuery selector of the destination element (default is body).

  • 'return'
    With this action the extracted csv will be returned as a string by the call to table2csv().
    WARNNG: the other actions will return the same jQuery object they were called on, thus allowing you to chain the call with other jQuery methods. With this action instead, since you get a string in return, you will no longer be able to do that. For example, this will not work:

    $("#tab").table2csv('return').find(".col2"); // TypeError: $(...).table2csv(...).find is not a function

Options

General options

  • separator
    default: ','
    The field separator to use in the csv

  • newline
    default: '\n'
    The line separator to use in the csv

  • quoteFields
    default: true
    Whether to quote fields in the csv

  • excludeColumns
    default: ''
    jQuery selector for the columns you don't want to export in the csv (tipically a list of classes)

  • excludeRows
    default: ''
    jQuery selector for the rows you don't want to export in the csv (tipically a list of classes)

  • trimContent
    default: true
    Trims the content of individual <th>, <td> tags of whitespaces. This will produce valid output even if the table is indented.

Download options

These options apply only when the 'download' action is used

  • filename
    default: 'table.csv'
    This is the name given to the file when the 'download' action is invoked

Output options

These options apply only when the 'output' action is used

  • appendTo
    default: 'body'
    jQuery selector of the element inside which append the generated csv text. This is only used when the 'output' action is invoked
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].