Welcome Guest, Not a member yet? Register   Sign In
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');

[font=Tahoma, Verdana, Arial, sans-serif][font=Tahoma, Verdana, Arial, sans-serif]r[/font][font=Tahoma, Verdana, Arial, sans-serif]eq[/font][font=Tahoma, Verdana, Arial, sans-serif]uire(vendor/autoload.php): failed to open stream: No such file or directory [/font][/font]

[font=Tahoma, Verdana, Arial, sans-serif]I need a help on how to set it up and use it in my app.[/font]

Attached Files Thumbnail(s)

(This post was last modified: 08-20-2020, 11:16 PM by jreklund.)

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.

Theme © iAndrew 2016 - Forum software by © MyBB