how to save the data in .xls using php?

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
PHPycho
Forum Contributor
Posts: 336
Joined: Fri Jan 06, 2006 12:37 pm

how to save the data in .xls using php?

Post by PHPycho »

HI all
Saving the stored data in .html and .txt is simple. But i am looking for saving the data in excel.
Has anybody tried it out. If yes that would be very helpful to me .
Thanks in advance
Last edited by PHPycho on Fri Jan 12, 2007 7:56 pm, edited 1 time in total.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

User avatar
PHPycho
Forum Contributor
Posts: 336
Joined: Fri Jan 06, 2006 12:37 pm

Post by PHPycho »

Thanks for the quick reply Mr. volka
is there no other way than using pear ?
User avatar
ambivalent
Forum Contributor
Posts: 173
Joined: Thu Apr 14, 2005 8:58 pm
Location: Toronto, ON

Post by ambivalent »

This is based around output from MySQL but it should point you in a general direction: http://fundisom.com/phpsnippets/snip/da ... _to_excel/
User avatar
PHPycho
Forum Contributor
Posts: 336
Joined: Fri Jan 06, 2006 12:37 pm

Post by PHPycho »

I searched i came to know that PHP COM applications is useful in creating .doc .xls .ppt files.
But i didnt got the sufficient tutorial to start it out. Waiting for a good guidance.
THANKS
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Bear in mind that XLS and DOC files are binary. Unless you use pear you won't find any standard PHP functions for generating data for those types of files. You have to know the data structure. That second tutorial seems to know it but I must personally I would not fancy writing all my code like that, I'd write a proper loader and saver for PHP that than allowed me to add/change data in the file using objects or functions....what do you know that is exactly what that pear library is!

Pear is the way to go, you won't find anything better.
User avatar
PHPycho
Forum Contributor
Posts: 336
Joined: Fri Jan 06, 2006 12:37 pm

Post by PHPycho »

I have to save the data in simple format , there is no need of calculations and more..
Using pear may be a better idea, but that should be installed and that may be
a x-tra work to carry on. For simple format may be the COM application may be better.
Just i need is a good tutorial of .xls generation using COM objects and PHP.
Thanks in advance
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

For "simple" stuff, why not use CSV (comma separated values) or TSV (tab separated values)?
decipher
Forum Commoner
Posts: 38
Joined: Mon Mar 13, 2006 6:27 am
Location: south africa

Post by decipher »

^^ this is the way to go, especially when the data is in "simple format".
PHP has some built in functions to handle csv files:
http://www.php.net/fgetcsv

In excel or OO Calc, you can simply File >> Save As >> .csv
Definately a lot easier than trying to work with .xls files.
peace
Post Reply