vdomah / octoexcel

OctoberCMS wrapper for Maatwebsite/Laravel-Excel
MIT License
14 stars 10 forks source link

Class '\Maatwebsite\Excel\ExcelServiceProvider' not found #11

Closed bkrajendra closed 4 years ago

bkrajendra commented 4 years ago

Recently Im getting error for latest october build + octoexcel

Class '\Maatwebsite\Excel\ExcelServiceProvider' not found

No special things, just its a fresh install.

Im trying this simple code

use Vdomah\Excel\Classes\Excel;
use Vdomah\Excel\Classes\ExportExample;
function onStart()
{
    return Excel::export(ExportExample::class, 'my_export_filename');
}
Dinwid commented 4 years ago

If after installation you got any errors related to the maatwebsite/excel vendor not found: please run from your project's root

composer require maatwebsite/excel:3.1

bkrajendra commented 4 years ago

ok thanks. I'll try.

vdomah commented 4 years ago

ok thanks. I'll try.

please give us feedback if that will fix the issue

bkrajendra commented 4 years ago

yes it did fixed the issue. But in example class, there is Faker class which was throwing error. I suggest you to just add User:all() there to work it properly as Faker is mostly not installed by default. But most probably User will always be there.

This worked for me:

<?php namespace Company\Pluginname\Classes;

use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Events\AfterSheet;
use Company\Pluginname\Models\Profile;

class ExportApplications implements FromCollection, WithHeadings
{
    // set the headings
    public function headings(): array
    {
        return \DB::getSchemaBuilder()->getColumnListing('my_profiles_name');
    }

    // get the data
    public function collection()
    {
        return Profile::all();
    }
}
vdomah commented 4 years ago

Thanks for suggestion. Added a check for Faker existing in project to prevent the error. And added commented.