**Fatal error** : Uncaught PHPExcel_Reader_Exception: Could not open file

Hello,
I’m trying to import an excel spreadsheet to a database using a control application and the built-in excel php library. I’ve watched the youtube tutorial and tried to adapt the example file providing by Nate . unfortunately when the application tries to process the file I get the following error.

Fatal error : Uncaught PHPExcel_Reader_Exception: Could not open /Applications/Scriptcase/v9/wwwroot/scriptcase/file/doc/asset_group_11_1.xlsx for reading! File does not exist. in /Applications/Scriptcase/v9/wwwroot/scriptcase/prod/third/phpexcel/PHPExcel/Reader/Excel2007.php:82 Stack trace: #0 /Applications/Scriptcase/v9/wwwroot/scriptcase/prod/third/phpexcel/PHPExcel/IOFactory.php(268): PHPExcel_Reader_Excel2007->canRead(’/Applications/S…’) #1 /Applications/Scriptcase/v9/wwwroot/scriptcase/prod/third/phpexcel/PHPExcel/IOFactory.php(191): PHPExcel_IOFactory::createReaderForFile(’/Applications/S…’) #2 /Applications/Scriptcase/v9/wwwroot/scriptcase/app/UFM_August_2020/process_assets/index.php(1663): PHPExcel_IOFactory::load(’/Applications/S…’) #3 /Applications/Scriptcase/v9/wwwroot/scriptcase/app/UFM_August_2020/process_assets/index.php(2506): process_assets_apl->controle() #4 {main} thrown in /Applications/Scriptcase/v9/wwwroot/scriptcase/prod/third/phpexcel/PHPExcel/Reader/Excel2007.php on line 82

Any advice greatly appreciated

Thanks in advance

Phill

Hi,

Below is snippet of my code that I had used to read an Excel file for parsing and selectively storing records…

sc_include_lib(“excel”);
$excelfile = [location]; // variable that stores Excel file name

$objPHPExcel=PHPExcel_IOFactory::load($excelfile);

$ErrorCount = 0;
$ErrorRows = ‘’;
$SuccessCount = 0;
$SuccessRows = ‘’;

//foreach ($objPHPExcel->getWorksheetIterator() as $worksheet){
$worksheet = $objPHPExcel->getActiveSheet();

$highestRow = $worksheet->getHighestRow(); 	

sc_begin_trans(); 

for ($row=4;$row <= $highestRow; $row++){
		$cell = $worksheet -> getCellByColumnAndRow (2, $row);

hth.

thank-you hth,

the code now throws up a different fatal error;

Fatal error : Uncaught Error: Class ‘PHPExcel_IOFactory’ not found in /Applications/Scriptcase/v9/wwwroot/scriptcase/app/UFM_August_2020/process_assets/index.php:1661 Stack trace: #0 /Applications/Scriptcase/v9/wwwroot/scriptcase/app/UFM_August_2020/process_assets/index.php(2514): process_assets_apl->controle() #1 {main} thrown in /Applications/Scriptcase/v9/wwwroot/scriptcase/app/UFM_August_2020/process_assets/index.php on line 1661

Phill

I am using slightly older version of SC, that use PHPExcel. If you are using the latest it must be PHPspreadsheet library…

You may have to change the code accordingly…

Hi
Im using version 9.4.032, Ive amend the code accordingly know the original error code has returned ?

Fatal error : Uncaught PHPExcel_Reader_Exception: Could not open /Applications/Scriptcase/v9/wwwroot/scriptcase/file/doc/asset_group_11_1(4).xlsx for reading! File does not exist

thank-you for your time.