1

I have written composer.json in my module, after running this file, I got all phpExcel dependcies included. Structure formed is like

vendor --phpoffice ---phpexcel ----classes ----phpexcel.php

I am setting classes to psr-0 level for autoloading but I'm not able to call PhpExcel class in my controller.

Any idea about this?

@edit

I have read below articles, but can't find satisfactory solution for this issue. I have implemented below described approach, but still can't figure out whats exactly I'm missing.

install https://www.drupal.org/project/libraries in project/modules/contrib folder.

Install https://www.drupal.org/project/phpexcel

Installed library from https://github.com/PHPOffice/PHPExcel and place it in "libraries" folder at root.

Now when I went to enable my modules it is simply giving me error:

The website encountered an unexpected error. Please try again later. Error: Class 'Drupal\libraries\StreamWrapper\LibraryDefinitionsStream' not found in Drupal\Core\StreamWrapper\StreamWrapperManager->addStreamWrapper() (line 156 of core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php).

If I include the phpexcel library using composer, it get included. But the issue is. This library has no namespaces. And If I call PhpExcel class in my controller,like

use PhpExcel/PhpExcel;

$spreadsheet = new SpreadsheetReader($file_path);

It gives error class not found.

How can I read excel file using phpExcel library?

Browse other questions tagged or ask your own question.