Class 'PHPExcel' not found in Excel5.php error upon loading an excel file on PHP

2.1k Views Asked by At

What could be the cause of this error upon loading a program that would get the content of an excel file and display it on PHP.

Fatal error: Class 'PHPExcel' not found in C:\xampp\htdocs\uploader\PHPExcel\Reader\Excel5.php on line 624

Below code loads the excel file and get a specific worksheet.

include 'PHPExcel/IOFactory.php';

$inputFileName = 'example1.xls';

//  Read your Excel workbook
try {
    $inputFileType = PHPExcel_IOFactory::identify($inputFileName);
    $objReader = PHPExcel_IOFactory::createReader($inputFileType);
    $objPHPExcel = $objReader->load($inputFileName);
} catch(Exception $e) {
    die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e->getMessage());
}

//  Get worksheet dimensions
$sheet = $objPHPExcel->getSheet(0); 
$highestRow = $sheet->getHighestRow(); 
$highestColumn = $sheet->getHighestColumn();

for ($row = 1; $row <= $highestRow; $row++){ 

    //  Read a row of data into an array
    $rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row,NULL,TRUE,FALSE);                              
}

As per the error, line 624 only instantiate a PHPExcel class but it seems there's something wrong on the PHPExcel class.

0

There are 0 best solutions below