Search code examples
phpincludexamppphpexcelinclude-path

Warning: include(PHPExcel.php): failed to open stream: No such file or directory


Im trying to implement Converting single sheet in an XLS file to CSV with PHPExcel - Memory exhausted but got stuck in the PHP Excel loading process.

I downloaded the pack (http://phpexcel.codeplex.com/) and, following the install instructions, copied the folder 'Classes' to three directories:

1) C:\xampp\htdocs\mycode - just my current working directory

2) C:\xampp\php\pear - bcs its what i get when I echo get_include_path();

and

3) C:\xampp\php\pear\PEAR - you know, just in case...

still when I run:

include 'PHPExcel.php';
include 'PHPExcel/IOFactory.php';

I get the following error messages:

Warning: include(PHPExcel.php): failed to open stream: No such file or directory in C:\xampp\htdocs\mycode\paths.php on line 5

Warning: include(): Failed opening 'PHPExcel.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\mycode\paths.php on line 5

Warning: include(PHPExcel/IOFactory.php): failed to open stream: No such file or directory in C:\xampp\htdocs\mycode\paths.php on line 6

Warning: include(): Failed opening 'PHPExcel/IOFactory.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\mycode\paths.php on line 6

tks in advance...


Solution

  • ...copied the folder 'Classes' to three directories

    Seems the hint is right there. Shouldn't it be

    require_once 'Classes/PHPExcel.php';
    

    Alternatively, add the Classes folder to your include path...

    set_include_path(implode(PATH_SEPARATOR, [
        realpath(__DIR__ . '/Classes'), // assuming Classes is in the same directory as this script
        get_include_path()
    ]));
    
    require_once 'PHPExcel.php';