1

I wanted to include PHPExcel.php in a testing module. So I put this file and the rest of the lib into: sites/all/libraries/phpexcel/ and I used this in my module:

function mymod_libraries_info() {

$libraries['phpexcel'] = array(
'name' => 'PHP Excel',
'version arguments' => array(
  'file' => 'PHPExcel.php', // Could be any file with version info 
  'pattern' => '/Version (\d+)/', 
  'lines' => 5,
),
'files' => array(
  'php' => array('PHPExcel.php'), 
),
);
return $libraries;
}

But after a:

$objPHPExcel = new PHPExcel();

I get a:

Fatal error: Class 'PHPExcel' not found in sites/all/modules/mymod/mymod.module on line 81

Should be an easy inclusion somewhere? But where and how?

I found a composer.json as well along with the PHPExcel Lib - should I rather try to install composer_manager and try to get the composer installation working?

Thanks in advance

0

Your file path is maybe incorrect. Try the code below:

function mymod_libraries_info() {

    global $base_url;
    $path = $base_url . '/sites/all/libraries/phpexcel/PHPExcel.php';

    $libraries['phpexcel'] = array(
        'name' => 'PHP Excel',
        'version arguments' => array(
            'file' => $path, 
            'pattern' => '/Version (\d+)/', 
            'lines' => 5,
        ),
    'files' => array(
       'php' => array('PHPExcel.php'), 
    ),
);
return $libraries;
}
  • Still the same problem. mymod_libraries_info is not even being called. $name = 'PHPExcel'; libraries_load($name); $objPHPExcel = new PHPExcel(); At the instantiating line I'll get a: Fatal error: Class 'PHPExcel' not found in / – Chris Mar 27 '15 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.