How can i create an xls file

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
Dilbert137
Forum Commoner
Posts: 57
Joined: Sat Jun 02, 2007 5:02 am
Location: Mauritius

How can i create an xls file

Post by Dilbert137 »

Dear All,

I'm searching for a coding which can make me create xls file from a database fields and that the client can save the data in xls.

Thanks
Dilbert137
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: How can i create an xls file

Post by omniuni »

Not to say it's impossible, but it is far easier to export as a CSV, and import that into your spreadsheet of choice.

http://php.net/manual/en/function.fputcsv.php
bjazmoore
Forum Newbie
Posts: 11
Joined: Mon Dec 28, 2009 12:12 pm

Re: How can i create an xls file

Post by bjazmoore »

To make a file that Excel will open nativly (when you double click the file) simply seperate your data with a tab (ASCII 9) and then save the file with an XLS extension. It will not have any special formatting, but excel will happily open it.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: How can i create an xls file

Post by Darhazer »

You can use the PHPExcel library
Post Reply