PHPExcel import fails during load on IIS
I'm using PHPExcel to read data from a XLSX file. Everything works correctly on Debian & Apache, but it fails on IIS during the initial load:
$input = "C:/Inetpub/wwwroot/import/data/test.xlsx";
$objReader = new PHPExcel_Reader_Excel2007();
$objReader->setReadDataOnly(true);
print "Starting...";
try {
$objPHPExcel = $objReader->load($input);
print("Done!");
} catch (Exception $e) {
print "Caught exception: " . $e->getMessage();
}
Unfortunately there is no further output after "Starting..." although no errors are displayed nor tracked in the IIS logs. The file path is correct (tried both / and /) and has the proper permissions. Neither is an exception raised (tkx @ Mark).
Please advise:
1) Is there a way to enable some sort of debugging to see where exactly PHPExcel stops and (maybe) why?
2) What do I need to cha开发者_如何学Cnge to have this code running on Windows & IIS.
Have you tried using XDebug? You will need an IDE like Netbeans or phpDesigner which supports it.
Then create project with all your files, open that file which does the reading and add a breakpoint at the first line of code that runs.
Start the debugger and step through each line until the error occurs and you might have a clue as to what's causing your problem. This will require lots of patience.
Good luck!
Try to make sure zip extension is enabled in php.ini:
extension=php_zip.dll
Still strange that no exception is thrown.
I had the same issue and resolved it by adding the following line:
PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);
Here is the explanation from the PHPExcel documentation: https://phpexcel.codeplex.com/wikipage?title=FAQ&referringTitle=Home
PHP complains about ZipArchive not being found
Make sure you meet all Requirements, especially php_zip extension should be enabled. The ZipArchive class is only required when reading or writing formats that use Zip compression (Excel2007 and OOCalc). From version 1.7.6 the PCLZip library has been bundled with PHPExcel as an alternative to the ZipArchive class. This can be enabled by calling:
PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);
before calling the save method of the Excel2007 Writer. You can revert to using ZipArchive by calling:
PHPExcel_Settings::setZipClass(PHPExcel_Settings::ZIPARCHIVE);
At present, this only allows you to write Excel2007 files without the need for ZipArchive (not to read Excel2007 or OOCal)
精彩评论