Closed (fixed)
Project:
PHPExcel
Version:
7.x-3.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
21 Mar 2013 at 11:34 UTC
Updated:
8 Jul 2013 at 11:30 UTC
Hi,
getting:
PHP Fatal error: Call to a member function detach() on a non-object in /home/user/www/site/sites/all/libraries/PHPExcel/Classes/PHPExcel/CachedObjectStorage/MemoryGZip.php on line 47
code to export xls:
module_load_include('inc', 'phpexcel', 'phpexcel');
$export = array('1' => 'id1','2' => 'id2');
$headers['export'] = array_keys($export);
$data['export'][] = array_values($export);
$path = 'sites/default/files/export.xls';
$options = array('format' => 'xls');
if (phpexcel_export($headers, $data, $path, $options)) {
drupal_set_message(t('exported'));
}
using Github downloaded lib, v 1.7.9
Comments
Comment #1
wadmiraal commentedHave you checked the return value ? The return value is no longer a boolean from 3.x onward, but an integer. Each integer corresponds to an error. I have to document each value, but you can check the
phpexcel.incfile for now, and check the constants defined at the start of the file.Comment #2
wizardfish commentedsame problem here, and can't see return value as it doesn't make it that far.
tried alechko's code and getting same error.
Comment #3
wadmiraal commentedI tried the exact code above and it works just fine.
What version of the module are you using ?
Can you try commenting out this block of code from the
phpexcel.incfile (at line 75):This sets an internal caching mechanism for better performance. It might be related.
It might be a PHP extension that's missing. But that would surprise me, as this module has been running smoothly on all kinds of servers - including shared hosts.
Comment #4
wizardfish commentedThanks very much for the timely reply wadmiraal. Blocking out that code worked.
I'm using PHPExcel 7.x-3.2
libraries 1.7.9 from Github
and PHP 5.3 on WAMPSERVER 2.0
Comment #5
wadmiraal commentedOk.
On the latest version, there's a new default caching mechanism. It might remove that error. This is the default behavior of PHPExcel (library). If the error remains, it might be related to the PHPExcel Library (and not the module).
There's also a new admin page (admin/config/system/phpexcel), where you can specify what caching mechanism you want to use. See #1777560: Expose PHPExcel caching options.
Does updating to the new version help ?
Comment #6
wadmiraal commented