# Add new class from library - what is right way?

**URL:** https://discourse.roots.io/t/add-new-class-from-library-what-is-right-way/16251
**Category:** sage
**Created:** 2019-08-01T19:52:28Z
**Posts:** 4

## Post 1 by @rerege — 2019-08-01T19:52:28Z

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

> **[PHPOffice/PHPExcel](https://github.com/PHPOffice/PHPExcel)**
>
> ARCHIVED. Contribute to PHPOffice/PHPExcel development by creating an account on GitHub.

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

---

## Post 2 by @strarsis — 2019-08-01T21:14:57Z

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:

> **[Import any XML or CSV File to WordPress](https://wordpress.org/plugins/wp-all-import/)**
>
> WP All Import is an extremely powerful importer that makes it easy to import any XML or CSV file to WordPress.

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

---

## Post 3 by @rerege — 2019-08-02T17:53:29Z

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

---

## Post 4 by @system — 2019-09-12T19:52:30Z

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