CodeIgniter Forums
How to generate PDF files and Mircrosoft Excel spreadsheets from database data using CodeIgniter? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: How to generate PDF files and Mircrosoft Excel spreadsheets from database data using CodeIgniter? (/thread-58547.html)



How to generate PDF files and Mircrosoft Excel spreadsheets from database data using CodeIgniter? - El Forum - 06-22-2013

[eluser]Unknown[/eluser]
Hi,
I'm new to CodeIgniter. I used to generate Excel files in PHP using normal PHP code. Is there a way to do that in a more easy fashion in CodeIgniter? I would be greatful if i could get a video tutorial link.

If someone helps me also to present data to a web user by pointing the user to download a PDF file generated from a database (after a search for instance)

Thank you for your precious time to respond to this issue.


How to generate PDF files and Mircrosoft Excel spreadsheets from database data using CodeIgniter? - El Forum - 06-22-2013

[eluser]Ckirk[/eluser]
Firstly what library (if any) are you used to using to generate Excel docs? If not a library did you just use the HTTP header method?

Either way I'd recommend using something like the PHPExcel library. That would make it the easier method, as requested.
It's pretty straight forward using third party libraries in codeigniter.

For PDF generation I use DOMPDF. Again it's easy to implement.
Here's a tutorial on how to intigrate PHPExcel into codeigniter

The same principle applies, if you want to use DOMPDF.

Hope that helps Smile


How to generate PDF files and Mircrosoft Excel spreadsheets from database data using CodeIgniter? - El Forum - 07-02-2013

[eluser]Unknown[/eluser]
I used the HTTP headers to generate the Excel file and the browser knew that the file that was coming in was a Excel file and just prompted the user the download the file. But I have never come up to a problem of formatting the generated file since the file is just a row Excel file that the user must take care of himself (chaning font size, font-family, etc)

You suggested me to use PHPExcel library and i saw the example you gave, but since the data returned from database is not know in advance, i still wonder how you can tell the library which cells or rows in the generated file to put data in (in a loop for instance)


How to generate PDF files and Mircrosoft Excel spreadsheets from database data using CodeIgniter? - El Forum - 07-03-2013

[eluser]Ckirk[/eluser]
The data from the database is known at the point where you create the excel doc. In the example on that tutorial it does show that the data is being taken from a database so if you follow the same format (adjusted to suit your data) then you wont go wrong Smile