KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.

Issue when using blade package and the excel package together #1510

Open Satish Dongol opened this topic on on Jun 29 - 5 comments

Satish Dongol commented on Jun 29

In my project, I am using the blade and the excel export package together and it seems there is some compatibility issue.

Do we have any example of using blade templates with the excel package?

The error I am getting is

Undefined property: koolreport\core\WidgetContainer::$excelExportHandler

Thank you

David Winterburn commented on Jun 30

Please post your php code for us to check it for you. Thanks!

Satish Dongol commented on Jun 30

Code to generate the excel file $report->run()->exportToExcel('MyExcel')->saveAs($fullPath);

I have created a temporary MyExcel.view.php file just to test it.

use \koolreport\blade\Engine;
protected function bladeInit()
        $viewsFolder = base_path(<view folder path>);
        $cacheFolder = base_path(<cache folder path>);
        $blade = new \Jenssegers\Blade\Blade($viewsFolder, $cacheFolder);
        return $blade;

In the reports class file, I have initialized the blade package of koolreports.

I have tried placing the template file for the excel in the folder where the Reports class file was located as well as in the custom view folder. The most interesting thing I found was that I had to create MyExcel.view.php file in the folder where Reports class file was located and MyExcel.view.php file in the custom view folder as well for it to work, otherwise, it would just give view not found error.

Please provide me some information regarding this and if I am doing something wrong.

David Winterburn commented on Jul 1

Did you add trait \koolreport\excel\ExcelExportable to your report class like this:

class MyReport extends koolreport\KoolReport
    use \koolreport\excel\ExcelExportable;

Please post the full error message as well. Thanks!

Satish Dongol commented on Jul 1

Thank you for the reply.

Actually I did get it working by having the .excel.php file in the same place as my report class. But I could not get it working with blade as my view. Or when I use custom view folders. Also, for some reason, I was unable to send params to the .excel.php file from my controller. Is there a different method of passing parameters to this file?

PS I do have the trait loaded in my class.

David Winterburn commented on Jul 1

Please use the excel view file in the format of "MyReportExcel.view.php" instead of "MyReport.excel.php" (this one is old). In the view file you could access the report via $this and any of its property $this->myProp, $this->params, etc.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed