PHPExcel import fails during load on IIS - php

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 change 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)

Related

Missing XMLReader Class

I am playing around with parsing spreadsheets and found the spreadsheet-reader class. I installed and have a very simple program written to open and parse an ".ODS" spreadsheet file. When I run it I get the error:
PHP Fatal error: Class 'XMLReader' not found in...
The line in question:
$ss = new SpreadsheetReader("test.ods");
So I google around and find out the version of PHP on that system needs to be at least 5.1 for it to use the version of XMLReader built into the core of PHP. I am using 5.4.12 there. I check with php -i and find PHP was compiled with: '--enable-xmlreader=shared'. According to the docs nothing needs to be configured at runtime to enable it.
Where else can I check and what am I doing wrong?
The solution is because PHP was built with a shared object file you DO need to modify php.ini: extension=xmlreader.so.

Lessphp: Failed to assign arg #list

I use php less compiler to compile bootstrap.less. When I upload on the server bootstrap.less via smartFTP everything works fine.
But as soon as I open and save bootstrap.less on the server (without changing it, just save it using remote editor linke PSPad or Remote System Explorer in Eclipse) I got the error:
Failed to assign arg #list: ../_css/less/bootstrap.less on line 51
So saving the file does something strange, but why and what?
As mentioned by #max-k it's a bug. All above version 3.0.0 don't work.
Lessphp seems to break on mixins like .col(#index) when (#index = 1) { // initial.
Solutions: switch back to TB3.0.0, wait for the bug fix, use a alternative library like less.php

PHP OAUTH class api

I am using OAuth::fetch() example in PHP.net (Outh code. The cod i use is
<?PHP
try{
$oauth = new OAuth("consumer_key","consumer_secret",OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_AUTHORIZATION);
$oauth->setToken("access_token","access_token_secret");
$oauth->fetch("http://photos.example.net/photo?file=vacation.jpg");
$response_info = $oauth->getLastResponseInfo();
header("Content-Type: {$response_info["content_type"]}");
echo $oauth->getLastResponse();
} catch(OAuthException $E) {
echo "Exception caught!\n";
}?>
The Error message is
Fatal error: Class 'OAuth' not found in C:\wamp\www\Jesvin\MyTest1\test1.php on line 3
You do not have the OAuth class available to use. It is a php extension and not part of the core package, you will need to install it manually into wamp. First thing to do is check whether the extension is available but not loaded.
Your php extension library will be something like /path/to/wamp/php/ext (i do not use wamp so you will have to google for your path or look for yourself in your filesystem).
If you see an oauth extension, you can skip installing oauth, if you do not you need to get a precompiled dll, look here: http://downloads.php.net/pierre/ and seach for "oauth", there are 2 (not sure which one you should use, so pick one, and if it doesnt work try the other).
Download it and stick teh dll in your extensions directory along with teh other php extensions.
Then find your php.ini file (you can use a file with <?php phpinfo; ?> and load it in your browser to see where php.ini is). Find where the extensions are defined and either uncomment or add this line to your php.ini file
extension=php_oauth.dll
ensure the dll name in the code above is teh same as the one you downloaded and installed to the extension folder. Also make sure there is NO semi colon at the start of this line.
That should just about do it. Hopefully php will load the DLL fine and it will work. Using pre-comiled dll's doesn't always work, but in this instance it will hopefully work.

XMLdiff for php installation

I am trying to install xml diff ; https://github.com/mmacia/XMLdiff and i have not managed yet to make it work.Whenever i run any test example,i get
Fatal error: Interface 'PHPUnit_Framework_Test' not found in
C:\xampp\php\PEAR\PHPUnit\Framework\TestSuite.php on line 85
Has anyone managed to install and use the library.I am using xampp on windows.
I believe your problem has to do with PHPUnit's Autoloader.php not being included. This file sets the php spl_autoloadspl_register function which is responsible for loading in interfaces and classes like PHPUnit_Framework_Test.
According to this SO question, you have to include the autoloader file manually. Without knowing more about your set-up and how that particular library works, I would say do something like this in the appropriate file(s):
// define phpunit path
if ( ! defined('PHPUNIT_PATH')) {
// define an absolute path to your PHPUnit dir
// CHECK THIS, i'm not good with php on windows:
define('PHPUNIT_PATH','C:\xampp\php\PEAR\PHPUnit');
}
// Then include the autoloader like this:
include PHPUNIT_PATH.'Autoloader.php';
I hope this helps you or anyone else out.
Check execution flags for C:\xampp\php\PEAR\PHPUnit\Framework\Framework\Test.php
The file needs to be executable by the user who is launching tests (probably you).

Open Flash Chart and Zend Framework Autoloader: class not found

I'm trying to upgrade the charts in my zend framework based website to the open flash chart 2 (version: kvasir) library. It used to work just fine with older versions. However, using the new version, when I try to create e.g. lines, I get error messages such as
Warning: include(line\hollow.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\weMatch\library\Zend\Loader.php on line 83
Fatal error: Class 'line_hollow' not found in C:\xampp\htdocs\weMatch\application\default\controllers\FeedbackController.php on line 215
I suspect that the Zend_Loader_Autoloader is replacing the underscore with a backslash. Can I exclude the whole open flash chart library from the Zend_Loader_Autoloader?
It is changing the _ to /. You could just include the file yourself beforehand.
require_once('path/to/line_hollow.php'); or whatever the filename is.
I found out that the API of the open flash library has changed with the new version (kvasir). As in old versions, there's a file you need to include which includes all the other library classes (open-flash-chart.php). I saw that the class line_hollow.php was commented out in this file and I therefore guess it's deprecated. When I tried to include line_hollow.php, there were some follow up errors. Luckily, there are other ways to achieve the same result. Instead of:
$line = new line_hollow();
you go
$line= new line();
$dot = new hollow_dot();
$line->set_default_dot_style($dotTeam);
The latter way gives you more flexibility, because you can give the $dot additional attributes.

Categories