Here is the button located:
plugins/xxx/xxx/controllers/competitions/update.htm:
<button
type="button"
data-request="onExportExcel"
data-request-data="id: <?= implode($this->params) ?>"
data-hotkey="ctrl+e, cmd+e"
data-load-indicator="Exporting Competition..."
class="btn btn-primary oc-icon-file-text-o">
Exportiere Teilnehmer des Bewerbes als Excel Sheet
</button>
which is calling:
plugins/xxx/xxx/controllers/competitions.php
use Vdomah\Excel\Classes\Excel;
use A711\Classic\Excel\CompetitionExport;
/**
* Competitions Back-end Controller
*/
class Competitions extends Controller
{
...
public function onExportExcel()
{
return Excel::export(CompetitionExport::class, 'competition', 'xlsx');
}
which should return
plugins/xxx/xxx/excel/CompetitionExport.php
use A711\Classic\Models\Competition;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Events\AfterSheet;
use Illuminate\Support\Facades\Input;
class CompetitionExport implements FromCollection, WithHeadings, WithEvents
{
// set the headings
public function headings(): array
{
return [
'Bewerb', 'Beschreibung'
];
}
// , 'Beifahrer Nachname', 'Beifahrer Vorname', 'PLZ', 'Ort', 'Straße'
// freeze the first row with headings
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
$event->sheet->freezePane('A2', 'A2');
},
];
}
// get the data
public function collection()
{
$competition = Competition::all();
$data = [];
if ($competition->count() > 0) {
foreach ($competition as $comp) {
$data[] = [$comp->bewerb, $comp->description];
}
}
return collect($data);
}
thats it .... (of course I like to extend the excel columns, when basic thing is working..)
Thanks, if you have any idea - would be great!