Exporting large records to excel

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
jlising
Forum Commoner
Posts: 33
Joined: Mon Mar 19, 2007 1:48 am
Location: Pampanga, Philippines
Contact:

Exporting large records to excel

Post by jlising »

Hello,

What is the best method to export large number of records into an excel file?
I'm having problem with my current script, it export records to an excel file using spreadsheet writer of pear.

Many Thanks!
User avatar
ghurtado
Forum Contributor
Posts: 334
Joined: Wed Jul 23, 2008 12:19 pm

Re: Exporting large records to excel

Post by ghurtado »

I would suggest using CSV as a format, since excel has no trouble reading it and it is very simple to do with php.

http://us3.php.net/fgetcsv

Another, less known option, is to write a simple HTML file with actual HTML tables, which can be imported by Excel just fine.
deafpanda
Forum Newbie
Posts: 7
Joined: Thu Jul 31, 2008 5:25 pm

Re: Exporting large records to excel

Post by deafpanda »

What was the problem with the PEAR excel writer?

There's an excellent tutorial at http://devzone.zend.com/article/3336-Re ... s-with-PHP
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Exporting large records to excel

Post by omniuni »

I second the CSV option. Easy to use with PHP, and easy to import to excel, or any other spreadsheet, for that matter.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Exporting large records to excel

Post by VladSun »

There are some issues with Excel when importing CSV file with utf-8 charset. I couldn't find a way to tell Excel that the charset is utf-8.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
jlising
Forum Commoner
Posts: 33
Joined: Mon Mar 19, 2007 1:48 am
Location: Pampanga, Philippines
Contact:

Re: Exporting large records to excel

Post by jlising »

Thanks guys for your replies.

I can now export records using the spread sheet excel writer. One more problem is, when I export records containing special characters. Some characters (i.e. ñ, Ñ) are not properly interpreted.

Do you know how to solve this problem?

Regards,
Jess
Post Reply