• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to generate PDF files and Mircrosoft Excel spreadsheets from database data using CodeIgniter?

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.

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

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)

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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.