|
Project Information
Featured
Downloads
|
The jQuery CSV to Table plugin reads in comma separated values (CSV) or tab separated values (TSV) data and generates an HTML table. Common spreadsheet programs, such as Microsoft Excel, are capable of saving in both CSV and TSV format. By calling the CSVToTable() function on a DIV, and providing the path to a CSV or TSV file to download, the plugin loads in the data and creates an HTML table. For example, if a file called 'test.csv' contains the following data: album,artist,price "lateralus","tool",13.00 "aenima","tool",12.00 "10,000 days","tool",14.00 "down in it","nine inch nails",3.00 "broken","nine inch nails",6.00 A simple plugin call like: <div id="CSVTable"></div>
<script>
$(function() {
$('#CSVTable').CSVToTable('test.csv');
});
</script>Would produce:
Configurable options:
The plugin will also trigger a "loadComplete" event upon successful render, so that you may use other jQuery plugins/code to modify the resulting table. One such example is the jQuery tablesorter plugin at http://tablesorter.com/ The example below shows how to fire code after the loadComplete event is triggered: $('#CSVTable').CSVToTable('test.csv',
{
loadingImage: 'images/loading.gif',
startLine: 1,
headers: ['Album Title', 'Artist Name', 'Price ($USD)']
}
).bind("loadComplete",function() {
$('#CSVTable').find('TABLE').tablesorter();
});;
|