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