-1

I have seen a lot of responses that pretty much say this is impossible but a lot of the questions are either for C#, java or some other language, the few for PHP are not properly asked, or the answer is deeply confusing and contradicting.

Is there a clean, easy, simple way to create and download a CSV file from a premade HTML table in PHP.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
LogicLooking
  • 916
  • 1
  • 16
  • 32
  • If you need to do this just once, not automated ongoing, you can look at the solutions provided here: http://stackoverflow.com/questions/259091/how-can-i-scrape-an-html-table-to-csv – Patrick Moore Nov 18 '13 at 16:48
  • This needs to be auto generated. That is - click a button, generate the html table in the background and then generate the csv from that... Copy and paste solutions are not acceptable. – LogicLooking Nov 18 '13 at 16:49
  • your preamble is not relevant to this question – also your question is not clear, does the HTML Table exist outside the generation of the CSV output or should they both be generated from the same Source of data? – Hannes Nov 18 '13 at 16:51
  • Could you elaborate as to why the HTML table is getting created first and then you want to convert the table to CSV? Why are you unable to do the CSV instead of the table or even along-side the table-generating script? Are you scraping a web-page? Because if so then you need to look into [DomDocument](http://php.net/manual/en/class.domdocument.php). Also requesting `clean, easy, simple` is going to be the reason for contradicting answers because everything is tailored to specific situations. – MonkeyZeus Nov 18 '13 at 17:12

1 Answers1

0

If you don't mind using a jquery plugin, you can use something like Datatables and Tabletools. You can see the output here . It's pretty easy and fast to set up

raygo
  • 1,348
  • 5
  • 18
  • 40