Tag Archives: export csv

Export as .csv with jQuery

This is so simple and very useful for reporting purpose. You can easily export your html table to .csv format with this jquery scripts.

Step 1: Html File

<form action="getCSV.php" method="post">
<input id="csv_text" name="csv_text" type="hidden" />
<input onclick="getCSVData()" type="submit" value="Get CSV File" />
 
<script type="text/javascript"><!--mce:0--></script>
</form>

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;
?-->

Thanks to the code writer
source: http://www.kunalbabre.com/projects/table2CSV.php