CodeIgniter Forums
Best CSV exporter? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Best CSV exporter? (/showthread.php?tid=34844)



Best CSV exporter? - El Forum - 10-11-2010

[eluser]GeXus[/eluser]
Would anyone recommend a good library for CSV export? Ideally, it could take a result, format it, and spit it out to download.

Thanks!


Best CSV exporter? - El Forum - 10-11-2010

[eluser]CroNiX[/eluser]
Different than the one built in? (assuming you want to take a db result and turn it into csv)

http://ellislab.com/codeigniter/user-guide/database/utilities.html#csv


Best CSV exporter? - El Forum - 10-11-2010

[eluser]GeXus[/eluser]
Hey.. thanks actually that's perfect Smile

Any idea how to have the CSV prompt to download? When I redirect to the CSV file, it displays it in the browser.


Best CSV exporter? - El Forum - 10-11-2010

[eluser]CroNiX[/eluser]
yeah, you need to send a different header if you don't want the browser to parse the content.

Try sending (using the real filename) just before you output it:
header('Content-disposition: attachment; filename=filename_of_your_csv.csv');
header('Content-type: text/csv');


Best CSV exporter? - El Forum - 10-11-2010

[eluser]GeXus[/eluser]
Awesome, thank you!