Giter Site home page Giter Site logo

tablecsvexport's Introduction

Update: When I tried to submit to the official jQuery Plugin list, I found that my original name (table2CSV) had already been taken, so I have changed every occurrence of 'table2CSV' to 'TableCSVExport'

This plugin converts any set of columns of a HTML table to a CSV file that can then be viewed in a popup window, as a data string, or downloaded as a file.

I had a need for such a utility at my day job (at LectureTools Inc.) and searching netted me only one interesting possibility - the initial plugin that I have built upon. It appears that development on this stopped around June 2009, so I decided to 'fork' it and enhance it. You can find my project here, on my Github account; It has the plugin and a HTML test page.

Dependencies:

This plugin was developed using jQuery 1.6.2 and is not tested with other versions.

Usage:

Include script file however you need to for your particular project.

HTML:[code]<script src='jquery.TableCSVExport.js'></script>[/code]
cakePHP 1.2: [code]echo $javascript->link("jquery.TableCSVExport.js");[/code]

cakePHP 1.3: [code]echo $html->script('jquery.TableCSVExport.js');[/code]

Then, simply execute the javascript line [code]jQuery('#table-id').TableCSVExport();[/code] to use the plugin with the default options.

Options:

separator (Default: ',')
The character that separates entries in the resulting CSV file.

 

delivery (Default: 'popup')

The manner in which to return the CSV data file. Options are:

'popup' - opens a new window and displays the CSV data in a box where it can be copied from.
'value' - returns the CSV data as a single long string
'download' - triggers a download of a file containing the CSV data
 

header (Default: [])

An array containing strings of the column headers

Example: [code] jQuery('#table-id').TableCSVExport({header:['Name','Mon','Tue','Wed','Thr','Fri']}) [/code]

 

columns (Default: [])

An array containing strings consisting of the headers for the columns to export. This MUST be a subset of the array passed to the header option.

Example: [code] jQuery('#table-id').TableCSVExport({header:['Name','Mon','Tue','Wed','Thr','Fri'], columns:['Name','Mon']}) [/code]

This will export only the 'Name' and 'Mon' columns as CSV data.


emptyValue (Default: '')

Column default value if the column is empty.

showHiddenRows (Default: false)

if it's true, will export rows with display: 'none'.

rowFilter (Default: '')

You can add jquery selector filter, to filter table rows.

Ex: rowFilter: '.myClass'

Important Notes:

1. When using the columns option to only export certain columns, you must also set the header array and the columns array must be a subset of the header array.

2. The javascript .trim() function is called on each table datum, so be aware that beginning or terminating whitespace will be lost.

3. jquery.TableCSVExport.js is released under the MIT License and LectureTools Inc. retains all copyrights.

tablecsvexport's People

Contributors

zachwick avatar pauloortins avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.