473,498 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP with Excel

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

Thanks,
Raghu

Jan 16 '07 #1
6 1876

ABC wrote:
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

Jan 16 '07 #2
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.

Jan 16 '07 #3
ABC wrote:
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.
Jan 16 '07 #4
Cord-Heinrich Pahlmann wrote:
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
Jan 16 '07 #5
ABC wrote:
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.
Jan 17 '07 #6
Sanders Kaufman wrote:

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
Jan 17 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
35479
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
3
20270
by: Otie | last post by:
I found the following under the GetObject help notes and in the example for GetObject: "This example uses the GetObject function to get a reference to a specific Microsoft Excel worksheet...
6
12467
by: Matthew Wieder | last post by:
I have the following requirements: Build a stand-alone C# application that asks the user to click in a cell in an Excel spreadsheet, and then displays the address of that cell in the C#...
14
5731
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
22
15311
by: Howard Kaikow | last post by:
There's a significant problem in automating Excel from VB .NET. Reminds me of a problem I encountered almost 3 years ago that was caused by the Norton Auntie Virus Office plug-in. Can anybody...
9
2804
by: Anthony | last post by:
To me, creating Excel 2003 spreadsheets programmatically via VB.NET hasn't really changed since the days of VB6. That is, I'd do something similar to this Code: Dim ExcelApp As...
7
2413
by: Alain \Mbuna\ | last post by:
Hi everybody. In my program I have some data that is calculated after some input from the user. I have written some code that opens an Excel workbook, with 5 worksheets and the calculated data...
16
2668
by: alexia.bee | last post by:
Hi all, In some weird reason, excel instance won;t die if i remove the comment from 4 lines of setting values into struct. here is a snipcode public...
9
4517
by: Doug Glancy | last post by:
I got the following code from Francesco Balena's site, for disposing of Com objects: Sub SetNothing(Of T)(ByRef obj As T) ' Dispose of the object if possible If obj IsNot Nothing AndAlso...
0
7126
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7210
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7381
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5465
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4916
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3087
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
659
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
293
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.