This is for PHPExcel as opposed to the reader but the principle is the same. No need to actually include files. They can be autoloaded.
Add to your autoload.php:
$loader->registerPrefixes(array(
'Twig_Extensions_' => $ws.'Symfony/vendor/twig-extensions/lib',
'Twig_' => $ws.'Symfony/vendor/twig/lib',
'Zend_' => $ws.'ZendFramework-1.11.11/library',
'PHPExcel' => $ws.'PHPExcel/Classes' // Change to support the reader
));
After which you can do something like:
$reader = new \Spreadsheet_Reader();
Note the leading slash is required to handle the non-namespaced library.
I abstracted things just a bit by using a service:
/* ==================================================
* Wrap interface to the excel spreasheet processing
*/
namespace Zayso\CoreBundle\Component\Format;
class Excel
{
public function newSpreadSheet()
{
return new \PHPExcel();
}
public function newWriter($ss)
{
return \PHPExcel_IOFactory::createWriter($ss, 'Excel5');
}
public function load($file)
{
return \PHPExcel_IOFactory::load($file);
}
}