Error on Calculation.php, locale? Not using locale and removing error from file makes file work okay

Topics: Developer Forum
Dec 22, 2012 at 3:33 AM

Also posted on CodeReview:

PHPExcel 1.7.8
PHP v5.3.10

I'm trying to use PHPExcel, and it's throwing an error for even the most basic things, and even for a script copied from somewhere ( ).

Warning:  Invalid argument supplied for foreach() in /home/.../public_html/pear/PEAR/PHPExcel/PHPExcel/Calculation.php on line 1685 />

The outputted file has this as the very top of the file, for which Excel (or Open Office) says is not a valid file. If I remove those two lines, everything is fine and Excel (or OO) can open it with no problems and everything the script does is there.

Calculation.php line 1685:

foreach (glob($localeFileDirectory.'/*',GLOB_ONLYDIR) as $filename) {

And the function it is in:

private function __construct() {
    $localeFileDirectory = PHPEXCEL_ROOT.'PHPExcel/locale/';
    foreach (glob($localeFileDirectory.'/*',GLOB_ONLYDIR) as $filename) {
        $filename = substr($filename,strlen($localeFileDirectory)+1);
        if ($filename != 'en') {
            self::$_validLocaleLanguages[] = $filename;

    $setPrecision = (PHP_INT_SIZE == 4) ? 12 : 16;
    $this->_savedPrecision = ini_get('precision');
    if ($this->_savedPrecision < $setPrecision) {
}   //  function __construct()

I installed PHPExcel via PEAR.

I didn't see a "locale" directory anywhere in the PHPExcel setup, so I tried creating it but still have the same problem.

I'm not setting or using a locale feature.