Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old January 16th, 2007, 10:15 AM
ABC
Guest
 
Posts: n/a
Default PHP with Excel

Hi,
Can i write to MS-Excel using PHP? I am using PHP 5 on Linux. Any help
would be appreciated!

Thanks,
Raghu

  #2  
Old January 16th, 2007, 10:55 AM
Sonnich
Guest
 
Posts: n/a
Default Re: PHP with Excel


ABC wrote:
Quote:
Hi,
Can i write to MS-Excel using PHP? I am using PHP 5 on Linux. Any help
would be appreciated!
>
Thanks,
Raghu
That depends - you can write a file, which Excel can read, and add a
link to that. AFAIK only ASP has an option to open a file in Excel.
Correct me if I am wrong.

Af for exporting there are a few tricks:

$ff3=fopen($targetdir."\\some_file.xls", "w");
fwrite($ff3, "<html><table border=1>\r\n");
fwrite($ff3, "<tr><td><b>Item:</b></td<td><b>Used
in:</b></td<tr>\r\n");
fwrite($ff3, "<tr><td>sugar</td><td>coffee</td></tr>");

For tricks with numbers, try:
<STYLE TYPE="text/css"><!--
.number2dec {mso-number-format: Fixed;}
--></STYLE>
and use it like
<td class=""number2dec"">" . $price ."</td><td class=""number2dec"">
=d" . $y1 . "*e" . $y2 ."</td>"
This will add the first as a number, and the seconds as a fomula.

Try play around with this.

S

  #3  
Old January 16th, 2007, 03:15 PM
Cord-Heinrich Pahlmann
Guest
 
Posts: n/a
Default Re: PHP with Excel

PEAR can nicely write an Excel-File. I use it in one of my projects and
it works really good.
http://pear.php.net/package/Spreadsheet_Excel_Writer

Hope that helps.

  #4  
Old January 16th, 2007, 05:45 PM
Carl Pearson
Guest
 
Posts: n/a
Default Re: PHP with Excel

ABC wrote:
Quote:
Hi,
Can i write to MS-Excel using PHP? I am using PHP 5 on Linux. Any help
would be appreciated!
>
Thanks,
Raghu
>
As mentioned, the Pear package works well.

If your target spreadsheet is very complicated, though, you could always
just write out a csv file of the data, and use some VBA code in Excel to
import it as you saw fit.

This would however entail the user running macros when the sheet opens,
and not all folks like to do that.
  #5  
Old January 16th, 2007, 07:55 PM
Peter Chant
Guest
 
Posts: n/a
Default Re: PHP with Excel

Cord-Heinrich Pahlmann wrote:
Quote:
PEAR can nicely write an Excel-File. I use it in one of my projects and
it works really good.
http://pear.php.net/package/Spreadsheet_Excel_Writer
I second that - it works well and you have reasonable control over
formatting so you can make sure that the exported file looks nice.

Pete

--
http://www.petezilla.co.uk
  #6  
Old January 17th, 2007, 03:55 AM
Sanders Kaufman
Guest
 
Posts: n/a
Default Re: PHP with Excel

ABC wrote:
Quote:
Hi,
Can i write to MS-Excel using PHP? I am using PHP 5 on Linux. Any help
would be appreciated!

Easy! Just give an XML, HTML, CSV or other file an ".xls"
extension. Excel will load it like it and display it and
manipulate it just fine.
  #7  
Old January 17th, 2007, 08:15 PM
Peter Chant
Guest
 
Posts: n/a
Default Re: PHP with Excel

Sanders Kaufman wrote:

Quote:
Easy! Just give an XML, HTML, CSV or other file an ".xls"
extension. Excel will load it like it and display it and
manipulate it just fine.
Really though - Spreadsheet_Excell_Writer is not that difficult and there
are good examples of its use on the web - it gives so much more with only a
little bit of learning.

Pete


--
http://www.petezilla.co.uk
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles