Reputation: 1
I am using following code to access excel file in php.
$excel = new COM("Excel.application",,) or die ("ERROR: Unable to instantaniate COM!\r\n");
// DATA RETRIEVAL
$Workbook = $excel->Workbooks->Open($file) or die("ERROR: Unable to open " . $file . "!\r\n");
$Worksheet = $Workbook->Worksheets($sheet);
$Worksheet->Activate;
The above code working on local machine but when I try to execute this code on any web server then It's not working. Can Someone help me Where is the problem in this code.
Upvotes: 0
Views: 1632
Reputation: 1
You need Excel to be installed on your servers + the php process needs the correct permissions to be able to access the COM application.
We've had lot's of trouble with Office Interop in the past and I advise against it. If anything happens to your process the Excel instances are kept open on the server and these instances take up a lot of RAM.
You are better off using libraries that leverage the OpenXML specification, such as Spreadsheetlight:
You can use it from PHP, there is an example here:
Upvotes: 0