GithubHelp home page GithubHelp logo

jfowler-dc / table2csv Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rubo77/table2csv

0.0 1.0 0.0 10 KB

A small JQuery utility which allows you to export any HTML table as CSV file

License: The Unlicense

JavaScript 100.00%

table2csv's Introduction

table2CSV

This is a duplicate of another fork: https://github.com/ZachWick/TableCSVExport that already implemented some more new features (emptyValue, showHiddenRows, rowFilter)

so just for completion, here the original manual:

A small JQuery utility which allows you to export any HTML table as CSV file

It's very handy tool to use specially during development of reporting projects. It is also useful when you have some 3rd party JQuery table search plugin attached to your table.

thanks to http://www.kunalbabre.com/projects/table2CSV.php

Option 1

$('#example1').table2CSV();

Option 2

This can be used when you need custom header

$('#example1').table2CSV({
  header:['prefix','Employee Name','Contact']
});

Option 3

This can be used when you need to get output as string

alert(
  $('#example1').table2CSV({
  delivery:'value',
  header:['prefix','Employee Name','Contact']
}));

Option 3.1 - Generate CSV File

This can be done by posting the csv value obtained above to PHP or any similar server side script.

Step 1: Html File

<form action="getCSV.php" method ="post" > 
<input type="hidden" name="csv_text" id="csv_text">
<input type="submit" value="Get CSV File" 
   onclick="getCSVData()"
</form>
<script>
function getCSVData(){
  var csv_value=$('#example1').table2CSV({delivery:'value'});
  $("#csv_text").val(csv_value);  
}
</script>

Step 2: PHP File ( getCSV.php )

<?php
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"my-data.csv\"");
$data=stripcslashes($_REQUEST['csv_text']);
echo $data; 
?>

Option 4

This can be used when you need different separator

alert(
$('#example1').table2CSV({
  separator : ';',
  delivery:'value',
  header:['prefix','Employee Name','Contact']
}));

table2csv's People

Contributors

kepro avatar rubo77 avatar sinri avatar

Watchers

 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.