Page 1 of 1

how to save the data in .xls using php?

Posted: Fri Jan 12, 2007 7:49 pm
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

Posted: Fri Jan 12, 2007 7:52 pm
by volka

Posted: Fri Jan 12, 2007 8:03 pm
by PHPycho
Thanks for the quick reply Mr. volka
is there no other way than using pear ?

Posted: Fri Jan 12, 2007 8:47 pm
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/

Posted: Fri Jan 12, 2007 9:50 pm
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

Posted: Sat Jan 13, 2007 4:35 am
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.

Posted: Sat Jan 13, 2007 3:57 pm
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

Posted: Sat Jan 13, 2007 8:44 pm
by feyd
For "simple" stuff, why not use CSV (comma separated values) or TSV (tab separated values)?

Posted: Sun Jan 14, 2007 2:23 pm
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