You can also do the opposite here
Make sure the table name has an ID of #example1 then it will take that table.
Not sure if you could email it but think I can get the string so may be able to attach it as an attachement as .csv.
Q. Would this work?…anyway this one pasted here does…….
tabletocsv.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script type="text/javascript" src="http://www.kunalbabre.com/projects/table2CSV.js" > </script> <form action="getCSV.php" method ="post" > <input type="hidden" name="csv_text" id="csv_text"> <input type="submit" value="Get CSV File" onclick="getCSVData()"> <div id="csv_text"></div> <table id="example1" width="0%" cellspacing="3" cellpadding="3" border="1" style="background-color:#FFFFCC"> <thead> <tr> <th>1</th> <th>2</th> <th>3</th> <th>4</th> </tr> </thead> <tbody> <tr> <td>5</td> <td>6</td> <td>7</td> <td>8</td> </tr> </tbody> </table> </form> <script> function getCSVData(){ var csv_value=$('#example1').table2CSV({delivery:'value'}); $("#csv_text").val(csv_value); } </script> |
And getCSV.php
MUST BE CALLED THIS…..
1 2 3 4 5 6 7 8 |
<?php header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"my-data.csv\""); $data=stripcslashes($_REQUEST['csv_text']); echo $data; ?> |