how to export html table to excel || new question -> how to export rows generated by mysql queries to excel?? |
[eluser]johnmiller[/eluser]
hi all... old question i need to export data from dynamic html table to excel... does codeigniter provide any feature for that??? how should i do that??? new question now the below given is my question... how to export query result to an excel???
[eluser]outrage[/eluser]
You could also try this very easy to use plugin: http://codeigniter.com/wiki/Excel_Plugin/ Good luck
[eluser]Derek Allard[/eluser]
[quote author="outrage" date="1224223987"]You could also try this very easy to use plugin[/quote] Ah that takes me back :: blank stare while I have fond memories :: ![]() Just in the interest of full disclosure, the plugin I wrote doesn't truly export to Excel. It exports to csv and tricks excel into opening it by changing the file extension. That said, it's probably good for 99% of potential needs. If you need full on Excel support with formulas and links and such, check out the PEAR library.
[eluser]dcunited08[/eluser]
I may be wrong but Excel_Plugin exports data from a DATABASE table, not an HTML table. To do that you would have to pull the table out of output (or using $table->generate()) and change the <td>s to commas and </tr> to endlines. Is there a package that does that?
[eluser]Derek Allard[/eluser]
No, you are correct dcunited08. When the OP wrote "dynamic" table, I assumed they meant "generated by a db". There's nothing in CI that parses html tables and extracts text.
[eluser]dcunited08[/eluser]
I wrote a method for MY_Table that should allow you to output the table as a csv, please give it a try and let me know if it works for you. Code: /**
[eluser]johnmiller[/eluser]
Thanks a lot... but, dcunited08, your code is for creating CSV file, right? I would like to create an excel. Derek is right, dynamic means generated by db only. And actually I am exporting to excel using query. Means... suppose... I have first_name and last_name in the dynamic table. If I hit 'export to excel' button, all the details related to listed people have to export to excel (like first_name, last_name, address, city, state, zip etc...) So I am trying to export data from database to excel (using query) I tried using http://codeigniter.com/wiki/Excel_Plugin/ The below is what I did controller Code: function app_details_export() model Code: function app_export($id) and /system/plugins/to_excel_pi.php but when i run this, i get a fatal error like below... Fatal error: Call to a member function field_data() on a non-object in C:\wamp\www\mywork\system\plugins\to_excel_pi.php on line 15
[eluser]johnmiller[/eluser]
and one more thing... I told you I am getting a fatal error... I am getting it after exporting some values to excel... suppose... I am exporting 20 rows to excel... sometimes 15 random rows will export to excel without any problem... and after that, in excel, i am getting fatal error message... |
Welcome Guest, Not a member yet? Register Sign In |