0

I 5 minute quick start guide for Laravel-Excel https://docs.laravel-excel.com/3.1/exports/ but it returns a blank page instead of the Excel file. My code looks almost identical to the site. I'm running PHP 8.2, Laravel 11.5, and Laravel-Excel 3.1

EntriesExport

<?php

namespace App\Exports;

use App\Models\Entry;
use Maatwebsite\Excel\Concerns\FromCollection;

class EntriesExport implements FromCollection
{
    /**
     * @return \Illuminate\Support\Collection
     */
    public function collection()
    {
        return Entry::all();
    }
}

In my controller:

public function export()
    {
        return Excel::download(new EntriesExport, 'entries.xlsx');
    }

In my routes:

Route::get('/entries/export/', [EntriesController::class, 'export'])->name('excel');

1 Answer 1

0

I got it working by changing the route from /entries/export/ to /xlsxexport. For some reason it doesn't work the way I had it. It's working now.

Sign up to request clarification or add additional context in comments.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.