Add new class from library - what is right way?

Hallo, i have total begginer question.
I want add library PHPExcel for read data from excel files. How can i implementate these:

require_once dirname(FILE) . ‘/PHPExcel/PHPExcel.php’;
$objPHPExcel = new PHPExcel();

and what is right place for folder PHPExcel

The data I want show in template: template-import-invoices-from-excel.blade.php

There are basically two cases:

  • When the library belongs to the theme, use composer inside the theme folder to install the package.
  • When the library belongs to a (site) plugin, use composer inside the plugin folder to install the package.

The library you want to use looks more like something for a site plugin.
The theme should rather render content, not manipulate it.

As a side note, for importing from Excel into WordPress I had very good experience with using an importer plugin:

The free version has been sufficient for me in may cases.

1 Like

Thank you strarsis …
I finally decided for another actual library phpoffice/phpspreadsheet
composer install everything
I added to controller
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
and everything works! My technological debt is smaller :wink: Thanks a lot
Ivo

This topic was automatically closed after 42 days. New replies are no longer allowed.