Laravel-excel: [BUG] Queued Export error in src/Jobs/AppendQueryToSheet.php

Created on 8 Jan 2020  路  6Comments  路  Source: Maatwebsite/Laravel-Excel

Prerequisites

  • [x] Checked if your Laravel Excel version is still supported: https://docs.laravel-excel.com/3.1/getting-started/support.html#supported-versions
  • [x] Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • [x] Checked that your issue isn't already filed.
  • [x] Checked if no PR was submitted that fixes this problem.
  • [x] Filled in the entire issue template

Versions

  • PHP version: 7.3.11
  • Laravel version: 6.10.0
  • Package version: 3.1.18

Description

I get the following error when running queued exports (even if run synchronously) from Laravel Nova:

Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function forPage() on null in .../vendor/maatwebsite/excel/src/Jobs/AppendQueryToSheet.php:92

Steps to Reproduce

  • Setup a custom Export using a Laravel Nova action. Custom export is pretty simple in my case, extends QueuedExport implements WithMapping, ShouldAutoSize, has a simple headings() and map() function which comply with the docs.
  • Select some records to export via Nova Resource
  • Experience error as mentioned above. Export isn't completed.

Expected behavior:

No error & export should complete.

Actual behavior:

See above

Additional Information

Reverting to Laravel-Excel 3.1.17 fixes the error. I also debated whether to report this here or in the Nova-Excel repo, but issue definitely originates from this repo, not the other one.

bug

All 6 comments

Same problem here

I've locked Laravel Nova Excel to use 3.1.17 for now, until we find a fix for it.

@patrickbrouwers any updates?

any updates? with 3.1.17 not update Laravel 7

Same here, in our case it's caused by update of

  • Updating maatwebsite/excel (3.1.17 => 3.1.19)
  • Updating maatwebsite/laravel-nova-excel (1.1.9 => 1.2.1)

The export action class looks as follows:

class Export extends QueuedExport
{
    public function __construct($resource)
    {
        $filename = sprintf('%s-%s.csv', $resource->uriKey(), time());
        $fields = collect($resource->fields(request()));

        $return = $this
            ->askForWriterType()
            ->withHeadings($fields->pluck('name')->toArray())
            ->withFilename($filename)
            ->only($fields->pluck('attribute')->toArray())
            ->onSuccess(function (ActionRequest $request, PendingDispatch $queue) use ($filename) {
                $queue
                    ->chain([
                        new NotifyUserOfCompletedExport($request->user(), storage_path("app/{$filename}")),
                    ]);

                return Action::message('Your export is queued!');
            });

        return $return;
    }

    public function name()
    {
        return __('Export');
    }
}

Affects all the lenses, irregardless of complexity.

Queued exports are deprecated in 1.2.x, there's currently no way of supporting them anymore unfortunately. See release notes https://github.com/Maatwebsite/Laravel-Nova-Excel/releases/tag/1.2.0 If you really need queued exports, you should create a custom action and queue a Excel::store yourself. If anybody finds a way of serializing the Nova query so we can access it from the queue, feel free to PR it.

Was this page helpful?
0 / 5 - 0 ratings