Closed mobotan1 closed 9 years ago
is the bundle installed?
Yes, sure. I did update via composer and appkernel.php... On 5 Oct 2015 12:46, "Giulio De Donato" notifications@github.com wrote:
is the bundle installed?
https://github.com/liuggio/ExcelBundle#installation
— Reply to this email directly or view it on GitHub https://github.com/liuggio/ExcelBundle/issues/90#issuecomment-145482860.
where are you calling $this
?
BTW is not ExcelBundle related issue is how you configured test env.
@mobotan1 if you publish some code would be possible help otherwise is not so easy.
Here is my code cut I have controller function: /* @Route("/excel", name="ExcelJob") / public function ExcelAction() { $ExcelFile = "/home/my/project/1.xlsx”; $phpExcelObject = $this->get(' ExcelService')-> LoadExcelFile($ExcelFile) //…
And I have separate class:
Services.yml ExcelService: class: AppBundle\Controller\ExcelClass arguments:
class ExcelClass extends Controller
{
public function LoadExcelFile($ExcelFile){
$phpExcelObject = $this->get('phpexcel')->createPHPExcelObject($ExcelFile);
return $phpExcelObject;
}
@mobotan1
$this->get('phpexcel')
, you should ask on irc on any php channel.I got it! In controller -
$phpExcelObject = $this->get('##Name_Of_Service##');
In Service -
protected $container;
protected $phpexcel;
public function setContainer (\Symfony\Component\DependencyInjection\ContainerInterface $container) {
$this->container = $container;
$this->phpexcel = $this->container->get('phpexcel');
}
public function ExcelTest(){
$ExcelFile = // path to Excel file
$phpExcelObject = $this->phpexcel->createPHPExcelObject($ExcelFile);
//...
}
I just spent whole day but unfortunately didn't find the solution - I have done all through the instruction, but every time I receive symfony debug error: @mitsurugi Error: Call to a member function get() on null 500 Internal Server Error @
My tests show that problem starts from declaration: $phpExcelObject = $this->get('phpexcel')->createPHPExcelObject();
PHPExcel alone works finу via // $objPHPExcel = new PHPExcel();
Please, help - where to look, what to check?