Writing to an excel sheet 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
nanditagokhale
Forum Newbie
Posts: 4
Joined: Tue May 12, 2009 10:17 am

Writing to an excel sheet using PHP

Post by nanditagokhale »

Hello everybody,
I am trying to write to an excel sheet using PHP..here's the code

Code: Select all

 
$filename ="Report.xls";
$export_file = "/home/expressi/public_html/store/admin/".$filename;
$fp=fopen($export_file,"wb");
fwrite($fp,"Productid\t");
fwrite($fp,"Product Code\t");
fwrite($fp,"Number of units in inventory\t");
fwrite($fp,"Number of units sold\t");
 
Here am using \n for new line and \t to write to a new tab

Now if I want to to access a particular row and col, how can I do that?
Or can u suggest any other convenient method of writing to excel sheet.

I am coding in Xcart software. So the basic code is in place and I am customizing it.
Last edited by Benjamin on Tue May 12, 2009 11:35 am, edited 1 time in total.
Reason: Added [code=php] tags.
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Writing to an excel sheet using PHP

Post by Mark Baker »

nanditagokhale wrote:I am trying to write to an excel sheet using PHP..here's the code
Now if I want to to access a particular row and col, how can I do that?
Or can u suggest any other convenient method of writing to excel sheet.
There is always the option of using a library such as PHPExcel to write a real Excel workbook rather than simply writing text to a file that has an extension of .xls
Post Reply