Link to home
Start Free TrialLog in
Avatar of APD Toronto
APD TorontoFlag for Canada

asked on

PHPExcel: Undefined offset with particular file

Hi Experts,

I'm trying to load the attached Excel file using PHPExcel, but as soon as I do, I get:
Notice: Undefined offset: 8 in C:\inetpub\wwwroot\CSS_Reservations\excel_lib\PHPExcel\Reader\Excel5.php on line 5873

Notice: Undefined offset: 7 in C:\inetpub\wwwroot\CSS_Reservations\excel_lib\PHPExcel\Reader\Excel5.php on line 5873

Notice: Undefined offset: 7 in C:\inetpub\wwwroot\CSS_Reservations\excel_lib\PHPExcel\Reader\Excel5.php on line 5873

Notice: Undefined offset: 6 in C:\inetpub\wwwroot\CSS_Reservations\excel_lib\PHPExcel\Reader\Excel5.php on line 5873

Open in new window


My code thus far is
        global $env;
        //copy template file
       
            //Temporarily Change directory to root to copy files...
            $currentDIR = getcwd();
            chdir("../../");
            $rootDIR = getcwd();
            //Change DIR back
            chdir($currentDIR);
            
        $slash = DIRECTORY_SEPARATOR;

        //echo 'dir = ' . $currentDIR . '<br>';
        
        
        $file_name = "NiagaraPAXreport_" . $_SESSION['sess_id'] . ".xls";
        
        $file_from = $rootDIR . $slash . "reports" . $slash . "niagara_pax"
                                    . $slash . "NiagaraPAXreport_template.xls";
        
        $file_physical = $rootDIR . $slash . "downloads" . $slash . $file_name;        
        $file_virtual = $env['url'] . '/downloads/' . $file_name;        
        $copy_success = copy($file_from, $file_physical);          
        
        //Define From / To Dates as objects        
        $date_from = new DateTime($from);
        $date_to = new DateTime($to);
        
        /** Include PHPExcel **/
        error_reporting(E_ALL);
        set_time_limit(0);
                
        $fileType = 'Excel5';
        
        require_once '../../excel_lib/PHPExcel/IOFactory.php';
        
        // Read the file
        $excelReaderObj = PHPExcel_IOFactory::createReader($fileType);
        $excel_obj = $excelReaderObj->load($file_physical);

Open in new window


The error goes away if I comment out the last line, but I need that in order to be able to work with the file.

Additionally, I'm using this same code in another module with another file, and it works.  I also went into that module, swapped that file with the attached, it stopped working (same errors).  

Therefore, something is wrong with the attached file, but what?  I even removed the chart on the second sheet - the error persist.

Any help will be greatly appreciated.

Thank you.
NiagaraPAXreport-template.xls
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of APD Toronto

ASKER

I'm also able to open this file manually in MS Excel, but it won't let me open it (load it) through PHPExcel
I had to recreeate the file.