KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Trait "koolreport\excel\ExcelExportable" not found #2943

Open pickorea opened this topic on on Jan 13, 2023 - 4 comments

pickorea commented on Jan 13, 2023

Hi there!

I am working on a laravel project and use koolreport to produce a report and works fine however I came across and error Trait "koolreport\excel\ExcelExportable" not found when trying to export a report as excel

This is what I did I import use \koolreport\excel\ExcelExportable; into Myreport class as follows

<?php
namespace App\Reports;
use \koolreport\processes\Group;
use \koolreport\processes\Sort;
use \koolreport\processes\Limit;

class MyReport extends \koolreport\KoolReport
{
    use \koolreport\excel\ExcelExportable;
    use \koolreport\laravel\Friendship;
      

    function setup()
    {
    
        $this->src("")
        ->query("select islands.island_name as Island, villages.village_name as Village, trainings.training_date as Date, training_types.training_name as Training, count(case when training_details.gender = 1 then 1 end) as Male, count(case when training_details.gender = 0 then 1 end) as Female, count(*) as Total from islands left join trainings on islands.id = trainings.island_id left join training_types on training_types.id = trainings.training_type_id left join training_details on training_details.training_id = trainings.id left join villages on villages.id = training_details.village_id GROUP BY trainings.training_date, islands.island_name, villages.village_name, training_types.training_name")
        ->pipe(new Sort(array(
            "training_date"=>"asc"
        )))
        ->pipe($this->dataStore(""));        
    }
}

and this is my laravel route

Route::get('koolexcel', [ReportController::class, 'excel'])->name('koolexcel');

and this is my ReportController method

 public function excel()
    {
        $report = new MyReport;
        $report->run()->exportToExcel()->toBrowser("myreport.xlsx");
    }

and I create a link @extends('layouts.app')

@section('content')
    <div class="box">
            <div class="box-header with-border">
                <div class="box-header with-border">
                <div class="alert alert-info clearfix">
                    <a href="{{ route('report.koolexcel') }}" class="alert-link"><button type="button" class="btn btn-primary btn-sm float-end">{{ __(' EXTRACT TO EXCEL') }}</button></a> 
                </div>
            </div>
    </div>
<?php $report->render(); ?>
@endsection

However when I click the link the error appears as Trait "koolreport\excel\ExcelExportable" not found could you please help me how to make this work

KoolReport commented on Jan 13, 2023

Do you have the excel package or KoolReport Pro?

pickorea commented on Jan 13, 2023

I use this composer require koolreport/laravel and composer require maatwebsite/excel

Juan Daniel commented on Jan 13, 2023

Hi, I have the same problem, how do I download the Excel package?

Sebastian Morales commented on Jan 17, 2023

For excel export you would need either Excel package or KoolReport Pro license here:

https://www.koolreport.com/packages

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
None yet

None