Solved

Anyone make php COM working on WIN7?

Posted on 2011-09-09
17
1,356 Views
Last Modified: 2012-05-12
I updated my computer from xp to win7.
the php COM do not work now.
Anyone can help?

code:

$excel = new COM("excel.application") or die("Unable to instanciate excel");
$excel->Visible = 0;
$excel->DisplayAlerts = 0;
$excel->Workbooks->Open("C:\projects\test.xls");

Get error:
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> Microsoft Office Excel<br/><b>Description:</b> Microsoft Office Excel cannot access the file 'C:\projects\test.xls'. There are several possible reasons: • The file name or path does not exist. • The file is being used by another program. • The workbook you are trying to save has the same name as a currently open workbook
0
Comment
Question by:zcfyhome
  • 7
  • 3
  • 2
  • +3
17 Comments
 
LVL 5

Expert Comment

by:Eduardo Goicovich
ID: 36513260
you need set appropiate permission in com+

- Run dcomcnfg.exe
- Find excel application and click properties
- Click the Security tab
- Use Custom Access Permissions
- Add the user who runs the php application
- Use Custom Launch permissions
- Add the user who runs the web server service
0
 

Author Comment

by:zcfyhome
ID: 36513341
Thanks.
But I can't follow yours.
I run the dcomcnfg.exe , I can't find excel.
Could you give me detail steps.

Thank you very much
0
 
LVL 10

Expert Comment

by:Derokorian
ID: 36515343
in dcomcnfg:

Console Root -> Component Services -> Computers -> My Computer -> DCOM Config -> Microsoft Excel Application -> right-click -> properties then belfegor's steps from there.
0
 

Author Comment

by:zcfyhome
ID: 36524160
Thanks.
I did these two permissions change.
But it looks no  change on the result.
I get same error.

Any idea about this.

Thank you!
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 36533774
The problem is not DCOM as the error message was received from the COM Excel Object

I'd check permissions on the file and directory you are trying to access.  My guess is that your IIS user does not have read/write permissions.
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 36533784
To prove it is working:

$excel = new COM("excel.application") or die("Unable to instanciate excel"); 
$excel->Visible = 0;
$excel->DisplayAlerts = 0; 
echo "Excel Version: " . $excel->Version;

Open in new window

0
 

Author Comment

by:zcfyhome
ID: 36535996
it shows
Excel Version: 12.0

I use Apache/2.0.63 (Win32) PHP/5.1.6.

The update files function looks ok. So the apache should have permissions.

Any others?

Thanks
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 108

Expert Comment

by:Ray Paseur
ID: 36536123
Can you step back from the technical details and just tell us in plain language what you want to do?  There may be a better solution than COM.  Thanks, ~Ray
0
 

Author Comment

by:zcfyhome
ID: 36536709
I did loaded the client excel template file and insert the data, then send to the client excel report.
It works fine on winxp and win server 2003.
I would like make it work on win7.

Thanks
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 36538881
What are the permissions on the excel file?  Is it locked by someone else having the sheet open at the same time?
0
 

Author Comment

by:zcfyhome
ID: 36538947
The file permissions should ok , I give all " Full control". the sheet do not open at same time.

Thanks
0
 
LVL 5

Accepted Solution

by:
Eduardo Goicovich earned 500 total points
ID: 36539829
HI,

  Can you tell me that account are using to start apache service?

Create directory “C:\Windows\SysWOW64\config\systemprofile\Desktop ” (for 64 bit Windows) or “C:\Windows\System32\config\systemprofile\Desktop ” (for 32 bit Windows)
Set Full control permissions for directory Desktop to the account starting the service
0
 

Author Comment

by:zcfyhome
ID: 36543197
Good. It is working now.
Thank you very much!
I just wonder why need create this directory, it's so ...

Thanks again.
0
 

Author Closing Comment

by:zcfyhome
ID: 36543203
Good. it is working.
0
 

Expert Comment

by:xaiadax
ID: 37923020
i don't get it. meaning, i have to create a new folder (Desktop) and then set it to Full Control?
can you tell me what does it for?

i 'm also having the same problem.
i'm creating a function that enable user to upload data using excel, and once submitted, the data will get to be imported into MSSQL Server database.

the upload was ok. the excel file got copied into the temp folder in the server. the problem comes when it's time to retrieve data from that excel file into mssql. it was ok before i changed my OS to Windows 7. now everything is a mess.

pls help.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now