PHP COM and Excel problem
Posted on 2005-04-27
I'm using PHP 5.0.3 and Windows 2003 Server.
I'm opening an excel spreadsheet through PHP using COM, and then saving it as a tab delimited text file.
The problem is, COM always saves the file as read only, and I need write access to the file after.
i'm passing in parameter - 4158 as it's the only parameter that converts the spreadsheet to tab delimited, but, I need a write version of that save option
here's the code:
$excel = new COM("Excel.application") or die ("excelreader: constructor");
$workbook = $excel ->application->Workbooks->Open($path);
$newFile = substr($path, 0, -3) .'txt'; //strip extension and add a text one
$wkb->SaveAs($newFile, -4158); //I don't know that -4158 is the right parameter, it may be the problem (ie, read only), but it's the only one I could find that would save the file as a tab delimited text file
//these calls don't work, the system hangs when it tries to close the workbook or quit the excel app
Thanks for you help