PHPOffice / PHPExcel

ARCHIVED
Other
11.46k stars 4.2k forks source link

Install pathing not working #1423

Closed daybreak10 closed 5 years ago

daybreak10 commented 5 years ago

I know this version is deprecated, but corporately we don't have a choice but to be on PHP 5.4.16 at this time (am on CentOS 7 using Docker container - Linux {containerid} 4.9.93-linuxkit-aufs #1 SMP Wed Jun 6 16:55:56 UTC 2018 x86_64). I still need the functionality to be able to create xls with multiple tabs or I wouldn't bother with an add-on. This is the issue that I am having...

PHPEXCEL_ROOT="/var/www/html/DaysRpt/classes/PHPExcel/"

PHPExcel.php has the change to where the PHPExcel class files are and it does find the autoloader ok as well in this configuration -- if (!defined('PHPEXCEL_ROOT')) { define('PHPEXCEL_ROOT', dirname(FILE) . '/PHPExcel/'); require(PHPEXCEL_ROOT . 'Autoloader.php'); }

Autoloader.php has been changed to this (I've tried using PHPEXCEL_ROOT and various combinations with only slightly different can't find errors). But at least with this, it can find the PHPExcel_Shared_String and does the preload correctly-- $pClassFilePath = "/var/www/html/DaysRpt/classes/" . strreplace('', DIRECTORY_SEPARATOR, $pClassName) . '.php';

No matter how I alter the PHPEXCEL_ROOT or the paths in both of these files, it either doesn't find the files from the autoloader or it doesn't find the class file specificed in the PHPExcel.php....here's the error from the error_log when using this combination....

PHP Fatal error: Class 'PHPExcel_Calculation' not found in /var/www/html/DaysRpt/classes/PHPExcel.php on line 367, referer: http://localhost:9080/DaysRpt/index.php

Again, I know I should upgrade my PHP and use PHPspreadsheet instead and I wish I could, but in the meantime I am hoping someone out there can still assist with this configuration setup. Thanks.

daybreak10 commented 5 years ago

RESOLVED with this configuration:

In the PHPExcel.php file....

/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
    //define('PHPEXCEL_ROOT', dirname(__FILE__) . 'classes/PHPExcel/');
    define('PHPEXCEL_ROOT', 'PHPExcel/');
    require(PHPEXCEL_ROOT . 'Autoloader.php');
}

in the autoloader.php....

        //$pClassFilePath = PHPEXCEL_ROOT .
        //    str_replace('_', DIRECTORY_SEPARATOR, $pClassName) .
        //      '.php';

        $pClassFilePath = "/var/www/html/DaysRpt/classes/" .
            str_replace('_', DIRECTORY_SEPARATOR, $pClassName) .
              '.php';