• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
phpspreadsheet in Codeigniter4

Hi folks,

I am new in codeigniter 4, when needed to manipulate some excel files in my app I found the phpspreadsheet library convenient for that. However, after installing it using  composer I found it difficult to implement it in my app. 

Even when I tested their example hereafter couldn't work instead displayed 


require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World !');
$writer = new Xlsx($spreadsheet);
$writer->save('hello world.xlsx');

require(vendor/autoload.php): failed to open stream: No such file or directory 

I need a help on how to set it up and use it in my app.

Attached Files Thumbnail(s)

Hi, CI4 already knows where composer are located. This is how you load it inside an controller

PHP Code:
namespace App\Controllers;

use \
use \

Example extends BaseController
    public function 
$spreadsheet = new Spreadsheet();
$sheet $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1''Hello World !');
$writer = new Xlsx($spreadsheet);
$writer->save('hello world.xlsx');

PS. Moved your thread into CodeIgniter 4 Support.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.