473,563 Members | 2,635 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 1884

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($tar getdir."\\some_ file.xls", "w");
fwrite($ff3, "<html><tab le border=1>\r\n") ;
fwrite($ff3, "<tr><td><b>Ite m:</b></td<td><b>Used
in:</b></td<tr>\r\n");
fwrite($ff3, "<tr><td>su gar</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=""number2 dec"">" . $price ."</td><td class=""number2 dec"">
=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_Exc ell_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
35509
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 and extract information from specific worksheets and cells. I'm not really sure how to get started with this process. I ran the COM Makepy...
3
20275
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 (MyXL). It uses the worksheet's Application property to make Microsoft Excel visible, to close it, and so on. Using two API calls, the DetectExcel Sub...
6
12475
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# application. It seems simple enough, but the problem I'm encountering is as follows: In order for the user to select the cell from Excel, they must first...
14
5763
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 SQL DATABASE, probably by the click of a button. Is this possible? & what is the BEST APPROACH for doing this? & also if any links are there do...
22
15320
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 reproduce the behavior described below? For this example, I am using Excel 2002 and VS .NET 2002 and VB 6. MSFT KB article 304661 gives a trivial...
9
2810
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 Excel.Application Dim ExcelWB As Excel.Workbook
7
2418
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 (no database!)with some titles and info, is entered in the worksheet in a printable format. This is some of the code... Public exlAppl As...
16
2679
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 System.Collections.Generic.List<frmMain.sDBTest> LoadTestSet(string TestSetFile, System.Collections.Generic.List<frmMain.sDBTestDBviewList)
9
4524
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 TypeOf obj Is IDisposable Then DirectCast(obj, IDisposable).Dispose()
0
7659
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7580
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8103
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7634
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7945
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6244
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3634
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3618
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2079
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.