Bobboau Posted October 10, 2008 Share Posted October 10, 2008 ok, so I need to generate some reports from a few excel spread sheets on my network. it seems like this would be simple enough, just make the Excel COM object read the data and go. unfortunately it just doesn't seem to work when ever I try to open a file I get a "can't open it for some reason" error (specificly: "Microsoft Office Excel cannot access the file 'filenamehere.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.'"). I can open the file if I paste the path into the address bar manually just fine. this has happened with every excel file I have tried to open, no matter where they are. I think it's some sort of permissions thing, but I don't get how that could be or how to fix it. I am running through Apache on a Vista machine. Quote Link to comment Share on other sites More sharing options...
Bobboau Posted October 14, 2008 Author Share Posted October 14, 2008 no clue? Quote Link to comment Share on other sites More sharing options...
Bendude14 Posted October 14, 2008 Share Posted October 14, 2008 are the excel files on your vista machine? what about trying to put them in the public directory if your concerned about premissions? Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 14, 2008 Share Posted October 14, 2008 ok, so I need to generate some reports from a few excel spread sheets on my network. it seems like this would be simple enough, just make the Excel COM object read the data and go. unfortunately it just doesn't seem to work when ever I try to open a file I get a "can't open it for some reason" error (specificly: "Microsoft Office Excel cannot access the file 'filenamehere.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.'"). I can open the file if I paste the path into the address bar manually just fine. this has happened with every excel file I have tried to open, no matter where they are. I think it's some sort of permissions thing, but I don't get how that could be or how to fix it. I am running through Apache on a Vista machine. firewall accesslist ? Quote Link to comment Share on other sites More sharing options...
Bobboau Posted October 14, 2008 Author Share Posted October 14, 2008 right now I am doing everything on the same machine, so mySQL, Apache, the excel files, me using firefox accessing my own ip address, it's all on the same computer. I will of course want to access remote files and access everything from other computers eventualy, but for the moment I'm just trying to do local development. just tried putting it in the public folder, no change. I just turned the firewall completely off and tried it, no go. if it helps this is what I currently have in the php file $PPMH_path = "C:\\Users\\Public\\test.xls"; try{ $excel=new COM("excel.application") or die("unable to start Excel on server!"); $excel->DisplayAlerts = 0; $excel->Visible = 0; $excel->Workbooks->Open($PPMH_path); $excel->Quit(); } catch (Exception $e) { echo "\n**error** ".$e; $excel->Quit(); } Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 14, 2008 Share Posted October 14, 2008 3rd party class ? if so use the php documentation to do it from scratch, connection read and output, this will give you a greater understanding of the process Quote Link to comment Share on other sites More sharing options...
Bobboau Posted October 14, 2008 Author Share Posted October 14, 2008 what you mean COM? I'm fairly sure it's a standard extension for windows. http://us.php.net/manual/en/book.com.php I specifically need to use the COM interface because I have to deal with a bunch of different excel versions. the error happens only if I try to read or write a file with it, if I just perform tasks on a new excel sheet it works fine as far as I can see, but that is fairly useless. Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 14, 2008 Share Posted October 14, 2008 what you mean COM? I'm fairly sure it's a standard extension for windows. http://us.php.net/manual/en/book.com.php I specifically need to use the COM interface because I have to deal with a bunch of different excel versions. the error happens only if I try to read or write a file with it, if I just perform tasks on a new excel sheet it works fine as far as I can see, but that is fairly useless. iv never connected using com in php and didnt spot it in the code sorry. i thoght u were using some 3rd party stuff with com in it. Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 14, 2008 Share Posted October 14, 2008 i would guess u need to log in or somthing by the looks of it, have you turned off UAC on ur vista machine then restarted ur machine? Quote Link to comment Share on other sites More sharing options...
Bobboau Posted October 16, 2008 Author Share Posted October 16, 2008 just turned UAC off and tried again, does not effect anything. (other than vista is now nagging me of the impending doom caused by turning it off. ) also I have gone into the service controls and told the Apache server to log in with my credentials Quote Link to comment Share on other sites More sharing options...
Bobboau Posted October 16, 2008 Author Share Posted October 16, 2008 /*hit quote when I meant to hit edit*/ Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 17, 2008 Share Posted October 17, 2008 /*hit quote when I meant to hit edit*/ right click the directory u need to access and go to its premissions and add the server etc i forgot what teh services account is, the prob is taht is for IIS so there must be another account for APACHE u probs need to see who it runs under and give appropriate permisssions on that directory. Quote Link to comment Share on other sites More sharing options...
Bobboau Posted October 17, 2008 Author Share Posted October 17, 2008 well it runs under my account, and I have all the permissions in the world. not to mention it's the public folder I'm trying to access right now, that has just about the loosest security of anything in vista. but I just tried reading from a folder that I granted full control to just about everything I could see that could conceivably include Apache. Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 17, 2008 Share Posted October 17, 2008 ok so next, iv never used com in php but i can tell you rather than a syntax error which it might be or a function call ur missing its most likley to be a driver or some other software that ur missing. Quote Link to comment Share on other sites More sharing options...
Bobboau Posted October 17, 2008 Author Share Posted October 17, 2008 what sort of software/driver do you think I might be missing? excel works fine on it's own. is it possible this is a bug in PHP? I get the impression not many people use this extension, and it might just not work under vista. I am somewhat hesitant to imply it's not my fault this is working, but it seems like no one knows anything about this interface. or maybe I'm just looking in the wrong places. Quote Link to comment Share on other sites More sharing options...
Bendude14 Posted October 19, 2008 Share Posted October 19, 2008 You are responsible for installing support for the various COM objects that you intend to use (such as MS Word); we don't and can't bundle all of those with PHP. Have you done the above? Thats from the Documentation... Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 20, 2008 Share Posted October 20, 2008 You are responsible for installing support for the various COM objects that you intend to use (such as MS Word); we don't and can't bundle all of those with PHP. Have you done the above? Thats from the Documentation... tru that and also php on vista i had soem issues so there must still be some, but the extensions above u need to install them like the docs for php say. Quote Link to comment Share on other sites More sharing options...
Bobboau Posted October 21, 2008 Author Share Posted October 21, 2008 You are responsible for installing support for the various COM objects that you intend to use (such as MS Word); we don't and can't bundle all of those with PHP. Have you done the above? Thats from the Documentation... the com objects are installed with office, I know they work because if I use javascripting they work fine, and other than file related activities they seem to work fine in PHP, it is specificly I can not open or save a file. unless there is something specific for PHP I am not aware of. Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 23, 2008 Share Posted October 23, 2008 You are responsible for installing support for the various COM objects that you intend to use (such as MS Word); we don't and can't bundle all of those with PHP. Have you done the above? Thats from the Documentation... the com objects are installed with office, I know they work because if I use javascripting they work fine, and other than file related activities they seem to work fine in PHP, it is specificly I can not open or save a file. unless there is something specific for PHP I am not aware of. you go into php.ini and un-cooment the extentsion in the extensions section because it is not un-commented by default so it is not loaded. Quote Link to comment Share on other sites More sharing options...
Bobboau Posted October 28, 2008 Author Share Posted October 28, 2008 I uncommented everything related to COM in the ini file, I still have the same problem. I doubt this is the issue because I do get the excel COM object and it works exept for anything to do with files. the error I get is from the COM object it's self so PHP is makeing a working COM object. Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 29, 2008 Share Posted October 29, 2008 I uncommented everything related to COM in the ini file, I still have the same problem. I doubt this is the issue because I do get the excel COM object and it works exept for anything to do with files. the error I get is from the COM object it's self so PHP is makeing a working COM object. go to the php website look up the object check the versions required etc vista compatability etc, or do google searches for teh compatability of it with vista or your php version with vista etc Quote Link to comment Share on other sites More sharing options...
Bobboau Posted March 10, 2009 Author Share Posted March 10, 2009 I have figured out what is wrong, but I still am not able to fix it. Apparently office 2007 if run as a service in vista will not be allowed access to the file system. so, because Apache is running as a service, PHP is therfore running as a service and Excel is running as a service. I've tried a number of ways to try and get around this, but nothing seems to do it. I have tried running stuff as elaborate as running a javascript file from a system command line using psexec called by system(). none of this has been able to get around the service issue. so unless someone knows a way to spawn a command process in a different session and not as a service there will be no solution to this. it is 'almost' as if they have specifically made it impossible to use office on a server. oh, interestingly they have a new office version specifically for doing just that sort of thing. completely coincidental that. I hate microsoft. Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted March 10, 2009 Share Posted March 10, 2009 You could always try using a PHP Excel library that doesn't depend on .COM Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted March 23, 2009 Share Posted March 23, 2009 not a bad idea at all mark Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.