PhpExcel : Fatal error: Class 'PHPExcel_Shared_ZipStreamWrapper'

13,525

Solution 1

You must enable on php extension the zip dll

Solution 2

The same problem has been nagging me to death for a whole day. I found out that if you have your own autoloader function previously registered with spl, then you'll have to return false in the event your autoloader fails to load the required class, like this:

spl_autoload_register('my_autoload');
function my_autoload($className)
{
    if(file_exists(CLASS_PREFIX.".$className.php"))
    {
        require_once(CLASS_PREFIX.".$className.php");
    }
    else
    {
        return false;
    }
}

Solution 3

Looks like you're running some other library with its own autoloader that interferes with the PHPExcel autoloader. The latest SVN code has been modified to prevent this problem.

In the /Classes/PHPExcel/Autoloader.php script itself, change:

public static function Register() {
    return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
}   //  function Register()

to

public static function Register() {
    if (function_exists('__autoload')) {
        //    Register any existing autoloader function with SPL, so we don't get any clashes
        spl_autoload_register('__autoload');
    }
    //    Register ourselves with SPL
    return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
}    //    function Register()

Solution 4

If anyone happens to be on Linux, then this error can be caused by incorrect usage rights.

I had this same issue, but I changed the owner of the 'Shared' folder, and set it to be 'www-data' user, which is the apache user on my system (chown www-data:www-data Shared). This fixed the "Class 'PHPExcel_Shared_ZipStreamWrapper' not found" error.

Yet this is not the full fix, What you really need to do is make sure the folders and files in the PHPExcel folder are assigned to the correct user, and that they have the correct rights. Here is how you do it:

You need to assign the PHPExcel folder and every item in it to the www-data user so Apache can access the files. Make sure you are one level below your PHPExcel folder and then run this command:

sudo chown -R www-data:www-data PHPExcel

And that is that it. Apache should be able to access all the files and the error should be resolved.

Share:
13,525
leka
Author by

leka

Updated on June 05, 2022

Comments

  • leka
    leka almost 2 years

    I have encountered this error

    Fatal error: Class 'PHPExcel_Shared_ZipStreamWrapper' not found in \VBOXSVR\ACACIASOFT\apc\spreadsheet\lib\phpexcel\PHPExcel\Autoloader.php on line 29

    My currrent setup is : Host Machine : Windows 7 : this is where i check out my solution from svn

    Virtual Box Guest Machine : : Windows XP : where my apache, php, mysql installed. : I have also added the shared directory on my virtual box so that i will use this as the documentroot location

    My dilemma started when i change the documentroot. it bring error on my phpexcel modules but when i changed back the documentroot c:/program files/apache.... copy the project to this directory. this will not bring any error.