KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Read excel -- error Uncaught Error: Class 'PhpOffice\PhpSpreadsheet\IOFactory' not found #2463

Open hayu opened this topic on on Nov 26, 2021 - 8 comments

hayu commented on Nov 26, 2021

Hi i'm making an API to read excel and i got error

Uncaught Error: Class 'PhpOffice\PhpSpreadsheet\IOFactory' not found in D:\PhpProject\gsapi\vendor\koolreport\excel\ExcelDataSource.php:91

I have already installed the excel koolreport package and the phpoffice/ package at the vendor.

vendor/
- koolreport
    - core
    - excel
- PhpOffice
Sebastian Morales commented on Nov 26, 2021
  1. How did you install KoolReport, is it by downloading our packages or using composer?

  2. Is there "vendor/phpoffice" or "vendor/excel/vendor/phpoffice"?

KoolReport commented on Nov 26, 2021

May I know you if you have included the "vendor/autoload.php"?

hayu commented on Nov 29, 2021
  1. I installed via composer
  2. there is "vendor/phpoffice"
hayu commented on Nov 29, 2021

I've include "vendor /autoload.php"

Sebastian Morales commented on Nov 29, 2021

Can you pls try our standard Excel datasource example and let us know the result:

https://www.koolreport.com/examples/reports/datasources/excel_report/

hayu commented on Nov 29, 2021

this is my script that I have adjusted to the standard excel data source example koolreport

<?php 
require ROOT_PATH."/gsapi/vendor/koolreport/core/autoload.php"; 

use \koolreport\excel\ExcelDataSource;

class tes extends \koolreport\KoolReport{
    public function settings()
    {
        return array(
            "dataSources"=>array(
                "read_excel"=>array(
                    "class"=>ExcelDataSource::class,
                    "filePath"=>dirname(__FILE__)."\\"."temp\data_tes.xlsx"
                )
            )
        );
    }
    public function setup()
    {
        $result = $this->src('read_excel')
        ->pipe($this->dataStore("data_tes.excel"));
    }
}
    $param = file_get_contents("php://input");
    $cls = new tes;
    $cls->run()->render();
?>

and this is the result

<br />
<b>Fatal error</b>: Uncaught Error: Class 'PhpOffice\PhpSpreadsheet\IOFactory'
not found in D:\PhpProject\gsapi\vendor\koolreport\excel\ExcelDataSource.php:91
Stack trace:
#0 D:\PhpProject\gsapi\vendor\koolreport\core\src\KoolReport.php(315):
koolreport\excel\ExcelDataSource-&gt;start()
#1 D:\PhpProject\gsapi\pltfrm\manifest\tes.php(30):
koolreport\KoolReport-&gt;run()
#2 {main}
thrown in <b>D:\PhpProject\gsapi\vendor\koolreport\excel\ExcelDataSource.php</b>
on line <b>91</b><br />
Sebastian Morales commented on Nov 29, 2021

Oh, in case you install KoolReport by composer, pls require "vendor/autload.php" instead of "vendor/koolreport/core/autoload.php".

hayu commented on Nov 29, 2021

oh okay i got it, problem solved. thank you very much

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
solved

Excel