protonemedia/laravel-splade

Undefined constant Maatwebsite\Excel\Excel::XLSX

dade1987 opened this issue · 2 comments

  • Laravel Version: 10.11.0
  • PHP Version: 8.2.6
  • Splade JS Version (npm): ^1.4.8
  • Splade PHP Version (composer): 2.5.1
  • Dev environment (OS, Sail/Valet/etc): Apache/2.4.54 (Ubuntu)

Composer (PHP) package version: 1.4.11
NPM (JS) package version: 1.4.11

Description:

Undefined constant Maatwebsite\Excel\Excel::XLSX

Steps To Reproduce Issue:

I just made a SpladeTable instance Categories.php, with inside:

use Maatwebsite\Excel\Excel;

public function configure(SpladeTable $table)
    {
        $table
        ->column('id', canBeHidden:false)
        ->column('name', sortable:true, canBeHidden:true)
        ->column('slug', canBeHidden:false)
        ->column('action', canBeHidden: false)
        ->paginate(5)
        ->defaultSort('name')
        ->withGlobalSearch('Search through the data...', ['name'])
        ->export(Excel::XLSX) ;
    }

then i visited splade.test/categories

Make sure you have the maatwebsite/excel package installed.

And write your function like this:

public function configure(SpladeTable $table)
    {
        $table
        ->column('id', canBeHidden:false)
        ->column('name', sortable:true, canBeHidden:true)
        ->column('slug', canBeHidden:false)
        ->column('action', canBeHidden: false)
        ->paginate(5)
        ->defaultSort('name')
        ->withGlobalSearch('Search through the data...', ['name'])
        ->export(
                type:Excel::XLSX
            )
    }

It's all in the docs.

Yes you need the package, it's also in the docs :)