Git Product home page Git Product logo

laravel-nova-excel's People

Contributors

aarreedd avatar crnkovic avatar crynobone avatar domthomas-dev avatar halah-dev avatar joshmoreno avatar juliusvdijk avatar justindantzer avatar kabbouchi avatar laurencei avatar lx45 avatar m2de avatar marcfil avatar matthewjumpsoffbuildings avatar mbardelmeijer avatar mizmiz avatar niekdemelker avatar patrickbrouwers avatar puzzledmonkey avatar sandermuller avatar stylecibot avatar voicecode-bv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-nova-excel's Issues

[BUG] only index items are translated in export

Prerequisites

  • Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • Checked that your issue isn't already filed.
  • Checked if no PR was submitted that fixes this problem.

Versions

  • PHP version: 7.3
  • Laravel version: 5.8.17
  • Nova version: 2.0.5
  • Package version: 3.1.13 and 1.1.4

Description

The export picks up on translated fields like this:

public function fields(Request $request)
{
    return [
        Text::make(__('Company'), 'company'),
        Text::make(__('Lastname'), 'lastname')->sortable()
            ->rules('required', 'max:255'),
        Text::make(__('Firstname'), 'firstname')
    ]
}

They show up translated in the excel file, but only when they are on the index. For fields that are excluded from the index no translation is shown.

Except does not work

Trying the example on a barebones version of Laravel 5.7.3 and Laravel Nova version 1.0.16. Get the following error.

error

public function actions(Request $request)
{
    return [
        (new DownloadExcel)->except('email'),
    ];
}

Thanks!

Column Merging

Hi!

Firstly, great product. It's been an absolute time-saver for some of our projects.

In the normal version of the Excel lib, we can merge some of the output columns together but have looked through the docs and source, it doesn't seem to be possible in the Nova version - is that correct?

Big data download not supported

Prerequisites

[Y] Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
[Y] Checked that your issue isn't already filed.
[Y] Checked if no PR was submitted that fixes this problem.

Versions

PHP version: 7.3
Laravel version: 5.8.17
Nova version: 2.0.5
Package version: 3.1.13 and 1.1.4

Description

I've got more than 10, 000 records in my table. When I use Download Excel, it just nothing happens even though I use the chunk method.

 ((new DownloadExcel())->withHeadings()->withChunkCount(300)),

I thought it may work in chunk mode, but seems not.

[QUESTION] Export related models

Prerequisites

  • Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • Checked that your issue isn't already filed.
  • Checked if no PR was submitted that fixes this problem.

Versions

  • PHP version: 7.3
  • Laravel version: 5.7
  • Nova version: 1.3.1
  • Package version: - current -

Description

Actually this is no issue but a question. I have two models: Projects, Members. Each project has many members.

What I want to do? I want to export a list (xlsx) of all members for one project. I've created a Member's action. Then I have to select all members and run my action.

What I want to do instead? I want to run an action on a single project, getting all members. It this possible?

If this is the wrong place for questions like this, I apologize. Thank you for your help!

[PROPOSAL]

Laravel Nova Excel allows you to gain full control over your resource exports, and you can choose to create your own actions:
https://docs.laravel-excel.com/nova/1.1/exports/customizations.html#full-control

I added an action field and it worked, it's asking me for a value.
https://nova.laravel.com/docs/1.0/actions/defining-actions.html#action-fields

However when I add the handle() method to access the field I get a signature problem and I'm not sure what to do.

Return type declaration must be compatible with DownloadExcel->handle(request : \Laravel\Nova\Http\Requests\ActionRequest, exportable : \Laravel\Nova\Actions\Action) : array

No file extension when using askForWriterType

Prerequisites

  • Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • Checked that your issue isn't already filed.
  • Checked if no PR was submitted that fixes this problem.

Versions

  • PHP version: 7.1.3
  • Laravel version: 5.8
  • Nova version: 2.0
  • Package version: Laravel Excel: 3.1, Laravel Nova Excel: 1.1

Description

I have the following in my actions() function:

return [
    (new DownloadExcel())
        ->withFilename('documents')
        ->askForWriterType([
            Excel::XLSX => 'XLSX',
            Excel::CSV  => 'CSV',
            Excel::HTML  => 'HTML',
        ])
];

Instead of getting the filename I set within withFilename function followed by the extesion I selected in the dropdown menu, I get only documents without any extesion.

This is happening only when askForWriterType is used in combination with withFilename function.

I have seen in the documentation that when using withFilename, I should specify the file extension within the function parameter, like withFilename('documents.html'), but the file type beeing dynamic, how I can get what file type the user selected within the dropdown menu?

Steps to Reproduce

Just add the above code in your Nova component.

Expected behavior:

The name of the file I want to download should be documents. followed by the extesion I selected in the dropdown list. For example, if I select html, I should get documents.html.

Actual behavior:

Instead of getting the filename I set within withFilename function followed by the extesion I selected in the dropdown menu, I get only documents without any extesion.

Composer install fails

Not sure if this is pilot error, or a bug. Installing nova-excel with composer fails on dependencies. Installing 'maatwebsite/excel' via composer and then installing nova-excel appears to be a bandaid.


Using version ^1.0 for maatwebsite/laravel-nova-excel
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - maatwebsite/laravel-nova-excel 1.0.0 requires maatwebsite/excel ^3.0 -> satisfiable by maatwebsite/excel[3.0.x-dev].
    - maatwebsite/laravel-nova-excel 1.0.1 requires maatwebsite/excel ^3.0.10 -> satisfiable by maatwebsite/excel[3.0.x-dev].
    - maatwebsite/laravel-nova-excel 1.0.x-dev requires maatwebsite/excel ^3.0.10 -> satisfiable by maatwebsite/excel[3.0.x-dev].
    - Conclusion: don't install maatwebsite/excel 3.0.x-dev
    - Installation request for maatwebsite/laravel-nova-excel ^1.0 -> satisfiable by maatwebsite/laravel-nova-excel[1.0.0, 1.0.1, 1.0.x-dev].

and installing maatwebsite/excel first:

Using version ^3.0 for maatwebsite/excel
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 3 installs, 1 update, 0 removals
  - Installing markbaker/complex (1.4.6): Loading from cache
  - Installing phpoffice/phpspreadsheet (1.4.0): Loading from cache
  - Updating maatwebsite/excel (2.1.29 => 3.0.10): Downloading (100%)
  - Installing maatwebsite/laravel-nova-excel (1.0.1): Downloading (100%)
phpoffice/phpspreadsheet suggests installing mpdf/mpdf (Option for rendering PDF with PDF Writer)
phpoffice/phpspreadsheet suggests installing dompdf/dompdf (Option for rendering PDF with PDF Writer)
phpoffice/phpspreadsheet suggests installing tecnick.com/tcpdf (Option for rendering PDF with PDF Writer)
phpoffice/phpspreadsheet suggests installing jpgraph/jpgraph (Option for rendering charts, or including charts with PDF or HTML Writers)
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
Discovered Package: arsenaltech/nova-tab
Discovered Package: fideloper/proxy
Discovered Package: laravel/nova
Discovered Package: laravel/tinker
Discovered Package: maatwebsite/excel
Discovered Package: maatwebsite/laravel-nova-excel
Discovered Package: nickfairchild/nova-at-a-glance-card
Discovered Package: nunomaduro/collision
Discovered Package: owen-it/laravel-auditing
Package manifest generated successfully.```

$ composer require maatwebsite/laravel-nova-excel

Using version ^1.0 for maatwebsite/laravel-nova-excel
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating optimized autoload files

Illuminate\Foundation\ComposerScripts::postAutoloadDump
@php artisan package:discover
Discovered Package: arsenaltech/nova-tab
Discovered Package: fideloper/proxy
Discovered Package: laravel/nova
Discovered Package: laravel/tinker
Discovered Package: maatwebsite/excel
Discovered Package: maatwebsite/laravel-nova-excel
Discovered Package: nickfairchild/nova-at-a-glance-card
Discovered Package: nunomaduro/collision
Discovered Package: owen-it/laravel-auditing
Package manifest generated successfully.```

ERROR: preg_match() expects parameter 2 to be string, array given

Got this error while exporting one of our Nova resources to Excel through the action:

preg_match() expects parameter 2 to be string, array given at /home/insense/PHP_GIT/prj/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php:62)
[stacktrace]
#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'preg_match() ex...', '/home/insense/PHP_...', 62, Array)
#1 /home/insense/PHP_GIT/prj/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php(62): preg_match('/^[\\\\+\\\\-]?(\\\\d+\\\\....', Array)
#2 /home/insense/PHP_GIT/prj/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php(34): PhpOffice\\PhpSpreadsheet\\Cell\\DefaultValueBinder::dataTypeForValue(Array)
#3 /home/insense/PHP_GIT/prj/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php(184): PhpOffice\\PhpSpreadsheet\\Cell\\DefaultValueBinder->bindValue(Object(PhpOffice\\PhpSpreadsheet\\Cell\\Cell), Array)
#4 /home/insense/PHP_GIT/prj/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Worksheet.php(2508): PhpOffice\\PhpSpreadsheet\\Cell\\Cell->setValue(Array)
#5 /home/insense/PHP_GIT/prj/vendor/maatwebsite/excel/src/Sheet.php(208): PhpOffice\\PhpSpreadsheet\\Worksheet\\Worksheet->fromArray(Array, NULL, 'A1', false)
#6 /home/insense/PHP_GIT/prj/vendor/maatwebsite/excel/src/Sheet.php(359): Maatwebsite\\Excel\\Sheet->append(Array, 'A1', false)
#7 /home/insense/PHP_GIT/prj/vendor/maatwebsite/excel/src/Sheet.php(178): Maatwebsite\\Excel\\Sheet->appendRow(Array, Object(Maatwebsite\\LaravelNovaExcel\\Actions\\DownloadExcel))
#8 /home/insense/PHP_GIT/prj/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php(39): Maatwebsite\\Excel\\Sheet->Maatwebsite\\Excel\\{closure}(Object(Illuminate\\Database\\Eloquent\\Collection), 1)
#9 /home/insense/PHP_GIT/prj/vendor/maatwebsite/excel/src/Sheet.php(180): Illuminate\\Database\\Eloquent\\Builder->chunk(200, Object(Closure))
#10 /home/insense/PHP_GIT/prj/vendor/maatwebsite/excel/src/Sheet.php(117): Maatwebsite\\Excel\\Sheet->fromQuery(Object(Maatwebsite\\LaravelNovaExcel\\Actions\\DownloadExcel), Object(PhpOffice\\PhpSpreadsheet\\Worksheet\\Worksheet))
#11 /home/insense/PHP_GIT/prj/vendor/maatwebsite/excel/src/Writer.php(97): Maatwebsite\\Excel\\Sheet->export(Object(Maatwebsite\\LaravelNovaExcel\\Actions\\DownloadExcel))
#12 /home/insense/PHP_GIT/prj/vendor/maatwebsite/excel/src/Excel.php(126): Maatwebsite\\Excel\\Writer->export(Object(Maatwebsite\\LaravelNovaExcel\\Actions\\DownloadExcel), 'Xls')
#13 /home/insense/PHP_GIT/prj/vendor/maatwebsite/excel/src/Excel.php(80): Maatwebsite\\Excel\\Excel->export(Object(Maatwebsite\\LaravelNovaExcel\\Actions\\DownloadExcel), 'campaigns.xls', 'Xls')
#14 /home/insense/PHP_GIT/prj/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(223): Maatwebsite\\Excel\\Excel->download(Object(Maatwebsite\\LaravelNovaExcel\\Actions\\DownloadExcel), 'campaigns.xls', 'Xls')
#15 /home/insense/PHP_GIT/prj/vendor/maatwebsite/laravel-nova-excel/src/Actions/DownloadExcel.php(23): Illuminate\\Support\\Facades\\Facade::__callStatic('download', Array)
#16 /home/insense/PHP_GIT/prj/vendor/maatwebsite/laravel-nova-excel/src/Actions/ExportToExcel.php(89): Maatwebsite\\LaravelNovaExcel\\Actions\\DownloadExcel->handle(Object(Laravel\\Nova\\Http\\Requests\\ActionRequest), Object(Maatwebsite\\LaravelNovaExcel\\Actions\\DownloadExcel))
#17 /home/insense/PHP_GIT/prj/nova/src/Http/Controllers/ActionController.php(38): Maatwebsite\\LaravelNovaExcel\\Actions\\ExportToExcel->handleRequest(Object(Laravel\\Nova\\Http\\Requests\\ActionRequest))
#18 [internal function]: Laravel\\Nova\\Http\\Controllers\\ActionController->store(Object(Laravel\\Nova\\Http\\Requests\\ActionRequest), 'campaigns')
#19 /home/insense/PHP_GIT/prj/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#20 /home/insense/PHP_GIT/prj/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('store', Array)

Digging deeper, we found that this issue is related to: SpartnerNL/Laravel-Excel#873

On further analysis, we found that one of the attributes in the resource is an accessor that we include like so:

/**
* The accessors to append to the model's array form.
*
* @var array
*/
protected $appends = ['promo_modes'];

//@return array
public function getPromoModesAttribute()
{
    return $someArray;
}

Exporting a model with array accessors results in this error. Is there a workaround to say possibly exclude this field in the exported XLS/CSV?

Malformed UTF-8 characters, possibly incorrectly encoded

I get an error when starting the download action.

Versions

  • PHP version: 7.2
  • Mysql version: 5.7.22
  • Database encoding: UTF-8 unicode
  • Laravel version: 5.7
  • Nova version: 1.1.17
  • Package version: 3.1 and 1.0

Description

I used the quick instructions and installed the package.
Added an action to one of my entities.
When I press download, I receive a message
"Malformed UTF-8 characters, possibly incorrectly encoded"

P.S.

In the database I use Cyrillic

Error after updating

Hi, after updating I had the following error:

Argument 2 passed to Maatwebsite\LaravelNovaExcel\Actions\ExportToExcel::replaceFieldValuesWhenOnResource() must be of the type array, null given, called in /Users/danieljones/Dev/newforest-rustic-furniture/vendor/maatwebsite/laravel-nova-excel/src/Actions/ExportToExcel.php on line 242 {"userId":1,"email":"[email protected]","exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Argument 2 passed to Maatwebsite\LaravelNovaExcel\Actions\ExportToExcel::replaceFieldValuesWhenOnResource() must be of the type array, null given, called in /Users/danieljones/Dev/newforest-rustic-furniture/vendor/maatwebsite/laravel-nova-excel/src/Actions/ExportToExcel.php on line 242 at /Users/danieljones/Dev/newforest-rustic-furniture/vendor/maatwebsite/laravel-nova-excel/src/Actions/ExportToExcel.php:282)
[stacktrace]

I am now running version 1.1.0 up from 1.0.6.

How to get collection of models

Hey.

Is it possible to, in your own custom Action, get the models from the selected overview?

The Action documentation dictates that you can typehint it, but that's not possible because it would violate the DownloadExcel contract.

You can see the section of the docs here: https://nova.laravel.com/docs/1.0/actions/defining-actions.html#action-responses

I'd like to create a sheet per. model, and just use the first-sheet as a summary of the models.
How would I go about that?

[QUESTION/PROPOSAL] Export original field instead of computed ones

  • [X ] Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Nova Excel.
  • [X ] Checked that your issue isn't already filed.
  • [ X] Checked if no PR was submitted that fixes this problem.

Versions

  • PHP version: 7.3
  • Laravel version: 5.8.23
  • Nova version: 2.0.4
  • Package version: Laravel Nova Excel 1.1

Description

Resource index page displays a computed field from the original field. In this case, was adding an anchor tag to the email field using the Nova's method displayUsing().

Steps to Reproduce

Expected behavior:

Exporting to excel should use the original field instead of the computed one.

Actual behavior:

Exported field is exported with the computed format (eg. html tag)

Additional Information

Since it is usefull in some cases to export the computed fields, maybe we could have an option to toggle this behaviour either to a single or multiple columns.

Computed Fields not properly included

Prerequisites

  • Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • Checked that your issue isn't already filed.
  • Checked if no PR was submitted that fixes this problem.

Versions

  • PHP version: 7.2
  • Laravel version: 5.7.15
  • Nova version: 1.2.0
  • Package version: 1.1.1

Description

Computed fields are only included for certain resources, but not others. Haven't been able to determine why.

Steps to Reproduce

Example:

Expected behavior:

All the field values to be added into the export.

Actual behavior:

Computed fields not properly added into the export.

Additional Information

This seems to happen when there's pagination involved (exporting about 200 items)

[BUG] Wrong order of columns

Prerequisites

  • Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • Checked that your issue isn't already filed.
  • Checked if no PR was submitted that fixes this problem.

Versions

  • PHP version: 7.2.20
  • Laravel version: 5.8.31
  • Nova version: 2.0.10
  • Package version: 3.1.15 / 1.1.5

Description

Wrong order of columns in exported excel

Steps to Reproduce

  1. Config Excel Export as following:
(new DownloadExcel)
                ->only([
                    'title',
                    'first_name',
                    'last_name',
                    'email'
                ])
                ->withHeadings([
                    'Title',
                    'Vorname',
                    'Nachname',
                    'E-Mail'
                ])
                ->askForWriterType()
  1. Export as XLS in Nova

Expected behavior:

Order of Data Excel file is: title, first_name, last_name, email

Actual behavior:

Order of Data Excel file is: first_name, last_name, title, email

Additional Information

Order of headings is correct though.

I think the problem is in vendor/maatwebsite/laravel-nova-excel/src/Actions/ExportToExcel.php in replaceFieldValuesWhenOnResource() where the 'resourceFields' are always used first and then the 'only' fields.

Possible solution

 protected function replaceFieldValuesWhenOnResource(Model $model, array $only = []): array
    {
        ...

        // Fix sorting
        $row = array_merge(array_flip($only), $row);

        return $row;
    }

or

 protected function replaceFieldValuesWhenOnResource(Model $model, array $only = []): array
    {
        ...

        // Fix sorting
        uksort($row, function($key1, $key2) use ($only) {
            return (array_search($key1, $only) > array_search($key2, $only));
        });

        return $row;
    }

Failed - No File [BUG]

  • [ 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.

Versions

  • PHP version: 7.2
  • Laravel version: 5.8
  • Nova version: 2.0.9
  • Package version: 1.1

Description

I am having this same issue. It just says "Failed - No File" in chrome. I have added the package manually in app.php, although auto discovery is on in my project, but still nothing. The response I get back from the package is:

download: "http://reflect.test/nova-vendor/maatwebsite/laravel-nova-excel/download?path=%2Fprivate%2Fvar%2Ftmp%2Flaravel-excel-9kHdcVh2sPrFf2vYUdgTsLmVpVW304ct&filename=users.csv"
name: "users.csv"

Steps to Reproduce

Followed installation guide
Clicked 1 user to download CSV or XLS file
Click Action Button
File download fails

Tried fix from issue #11 but did not work.

File to be downloaded

Actual behavior:

Error downloading. Says no file and the link in the response returns a 404

[QUESTION] Export Excel with same data displayed

Prerequisites

  • 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.

Versions

  • PHP version: 7.1.25
  • Laravel version: 5.7
  • Nova version: latest
  • Package version: latest

Description

Hi! Thank you for this time saver plugin. I have a question about his behaviour: i'm looking for export in excel a nova resource called that is a report with a lot of fields that are connected with foreign keys to other tables. Now in my nova resource page i can see the description of each row connected with keys in my report but if i click export to excel i have a single row with only foreign keys: can i have instead the description like in browser?

Steps to Reproduce

Create a resource in relation with others and add a relation field (like BelongsTo)

Expected behavior:

Show description of related resource

Actual behavior:

Show the foreign key to related resource

[BUG] Queued Export Failing Silently communication link failure

Prerequisites

  • Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • Checked that your issue isn't already filed.
  • Checked if no PR was submitted that fixes this problem.

Versions

  • PHP version: 7.1
  • Laravel version: 5.6
  • Nova version: 1.3.2
  • Package version: 1.1.3

Description

When trying to do a queued export (tried with both database and redis) it fails silently without throwing any error or having any failed jobs. After investigating further the queue processing stops at
Processing: Maatwebsite\Excel\Jobs\AppendQueryToSheet i opened the logs (when using the database driver) and i saw the error communication link failure: 1153 Got a packet bigger than max_allowed_packet bytes. From what i understand it tries to serialize a huge request object and fails.

Steps to Reproduce

Expected behavior:
Queue excel exports

Actual behavior:
Excel export queuing fails everytime no matter how large the selected dataset is.

screen shot 2019-02-26 at 12 54 19 pm

Any help will be greatly appreciated thanks in advance!

[BUG] Action log not working

Prerequisites

Activate the action log following nova documentation https://nova.laravel.com/docs/1.0/actions/defining-actions.html#action-log
(adding use Actionable to the model that refers to resource that has ExportToExcel or DownloadExcel action)

  • Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • Checked that your issue isn't already filed.
  • Checked if no PR was submitted that fixes this problem.

Versions

  • PHP version: 7.2.1
  • Laravel version: 5.8
  • Nova version: 2.0
  • Package version: 1.1

Description

If you activate the Action log, when you export something you should see the log inside the single view of the resource. This does not happen. I tried other actions and those are being logged correctly.

Steps to Reproduce

  1. Activate the action log following nova documentation https://nova.laravel.com/docs/1.0/actions/defining-actions.html#action-log
  2. Add ExportToExcel or DownloadExcel action to your resource
  3. Do an export

Expected behavior:

Create a new log of the performed action

Actual behavior:

Nothing is created

Headings not being set on QueuedExport

I've set up a QueuedExport and am using ->withHeadings() but headings are not being prepended to my export.

(new QueuedExport())
	->withHeadings('ID', 'First Name', 'Last Name', 'Email', 'Phone', 'City', 'State', 'Zip', 'Status')
	->only('id', 'first_name', 'last_name', 'email', 'phone', 'city', 'region', 'postal_code', 'worker_status')
	->withDisk(config('filesystems.default'))
	->withFilename($export_filename)
	->onSuccess(function (ActionRequest $request, PendingDispatch $queue) use ($export_filename) {
		$queue
			->allOnQueue('default')
			->chain([
				new NotifyUserOfCompletedExport(
					$request->user(),
					$export_filename,
					Storage::temporaryUrl($export_filename, Carbon::now()->addWeek())
				),
			]);

			return Action::message('Your export is queued. You will be notified when it\'s ready.');
		}),

Files Not download

Hello,
I had Installed maatwebsite/laravel-nova-excel (1.0.1) .
Integrated actions for Download Excel in my Nova Resources , no files downloaded . Message on Files showing . Failed -No File .
See Attachement

No files downloaded .
screenshot from 2018-09-03 12 55 56

[BUG/QUESTION] Download excel file behind load balancer

Prerequisites

  • Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • Checked that your issue isn't already filed.
  • Checked if no PR was submitted that fixes this problem.

Versions

  • PHP version: 7.2.18
  • Laravel version: 5.8.24
  • Nova version: v2.0.6
  • Package version: 1.0.2

Description

I've got a kubernetes setup running with Laravel in a container. The containers work fine with Nova and the excel package in general when you have 1 container running. However we have multiple containers running behind a load balancer.

The problem we have with this is that whenever we download the excel sheet or csv using the action from this package we receive a failed download. This is because the download is created in the /tmp directory in one controller and downloaded from a different controller.

The reason for this is the setup of how downloads work. Whenever you perform an action regarding downloading the download url is returned with the path and file name

download: "https://local.site.com/nova-vendor/maatwebsite/laravel-nova-excel/download?path=%2Ftmp%2Flaravel-excel-SzURRyYeVGglGtCWrrnie7NzfdidTJKi&filename=users-1562309499.csv"
name: "users-1562309499.csv"

After the response has been received in Nova the download is being called from the url. In our case this means the load balancer might take a different container and the download fails.

Note: I'm not sure if this problem lays in this package or Nova, but it surely isn't ideal!

So my actual question now! Is it possible to store the file somewhere else before downloading it. So somewhere local S3 or another directory than /tmp. Does this package provide functionality for that?

Steps to Reproduce

Not sure if I can provide this easily, but I can thing along if you need more info

Expected behavior:

  • The download is returned right away instead of a URL first

Actual behavior:

  • The download fails because the file doesn't exist in the /tmp directory of the random picked container.

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

Unable to open downloaded file. Utf8 encoding error

Prerequisites

Versions

  • PHP version: <7.2>
  • Laravel version: <5.7>
  • Nova version: <1.0>
  • Package version:

Description

The file downloaded is not opening. Giving a UTF8 Malformed error
image

Steps to Reproduce

Expected File to Open but giving error

Expected behavior:

Actual behavior:

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

[QUESTION]Data from the closure

Prerequisites

  • Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • Checked that your issue isn't already filed.
  • Checked if no PR was submitted that fixes this problem.

Versions

PHP version: 7.2

  • Laravel version: 5.8
  • Nova version: 2.0
  • Package version: 1.1

Description

The

...Text::make('Estimate Revenue', function() { return $this->slips->price; })->sortable()...

below doesn't work with this plugin.

Error: message: "Trying to get property of non-object"

  public function fields(Request $request)
    {
        return [
            ID::make()->sortable(),

            // I'm 100% sure slips and price is defined, it appears on nova tables
            Text::make('Estimate Revenue', function() { return $this->slips->price; })->sortable(),
...

Steps to Reproduce

Simply add a closure like the one above.

Expected behavior:

Just export.

Actual behavior:

Error: message: "Trying to get property of non-object"

Additional Information

Prove that $this->slips->price; is defined: https://i.imgur.com/FsOr1dH.png

Some columns don't show up when exported.

I spent the last few hours troubleshooting why some fields weren't showing up in my exports. After a while, I found out that Laravel Nova Excel makes the query into a model, at which point the protected $hidden property of the model stripped away the fields I was requesting with only().

To avoid this issue, I suggest looping through the items in the only() list and setting those manually on the model. That will allow people to hide items in other places of in the code. (Ex. Sending models to JSON format as discussed in the official Laravel docs) It'll also allow people to export that which they'd like to export.

[BUG] Communication link failure: 1153 Got a packet bigger than 'max_allowed_packet' bytes for QueuedExport

Prerequisites

  • Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • Checked that your issue isn't already filed. (probably related to #44, but I didn't want to hijack that issue)
  • Checked if no PR was submitted that fixes this problem.

Versions

  • PHP version: 7.2
  • Laravel version: 5.7.27
  • Nova version: 1.3.2
  • Package versions: Excel: 3.1.7, Nova Excel: 1.1.3

Description

On exporting ~3K subscriptions records via a QueuedExport we get an SQL exception:

Communication link failure: 1153 Got a packet bigger than 'max_allowed_packet' bytes (SQL: insert into `jobs` (`queue`, `attempts`, `reserved_at`, `available_at`, `created_at`, `payload`)

We are using the database driver in combination with php artisan queue:work --tries=5 --delay=5

The Subscription Nova Resource looks like:

public function fields(Request $request)
{
        return [
            ID::make()
                ->hideFromIndex(),

            BelongsTo::make('User', 'user', \App\Nova\Resources\User\User::class),

            Text::make('Stripe id'),

            Text::make('Initial source')
                ->hideFromIndex(),

            DateTime::make('End date')
                ->sortable(),

            DateTime::make('Cancelation requested at')
                ->sortable(),

            DateTime::make('Canceled at')
                ->sortable(),

            Code::make('Import data')
                ->json()
                ->hideFromIndex(),

            DateTime::make('Created at')
                ->sortable()
                ->hideFromIndex(),

            HasMany::make('Payments', 'payments', \App\Nova\Resources\Program\Subscription\SubscriptionPayment::class),
        ];
}
public function actions(Request $request)
{
        $filename = 'exports/subscriptions/subscriptions-' . Carbon::now() . '.xlsx';
        $disk = 's3';

        return [
            (new ExportSubscription)
                ->withFilename($filename)
                ->withDisk($disk)
                ->withChunkCount(1000)
                ->onSuccess(function (ActionRequest $request, PendingDispatch $queue) use ($filename, $disk) {
                    $queue->chain([
                        new NotifyAdminOfCompletedExport($request->user(), $filename, $disk),
                    ]);
                    return Action::message('The export is being created, when done it will be send via email to '.$request->user()->email);
                }),
        ];
}

The ExportSubscription looks like:

class ExportSubscription extends QueuedExport implements WithMapping, WithHeadings
{
    /**
     * Headers
     *
     * @return array
     */
    public function headings(): array
    {
        return [
            'ID',
            'External ID',
            'Name',
            'Email',
            'Stripe ID',
            'Initial source',
            'End date',
            'Cancelation requested at',
            'Canceled at',
            'Created at',
        ];
    }

    /**
     * @param Subscription $subscription
     *
     * @return array
     */
    public function map($subscription): array
    {
        return [
            $subscription->id,
            $subscription->user ? $subscription->user->external_id : null,
            $subscription->user ? $subscription->user->name : null,
            $subscription->user ? $subscription->user->email : null,
            $subscription->stripe_id,
            $subscription->initial_source,
            $subscription->end_date ? $subscription->end_date : null,
            $subscription->cancelation_requested_at ? $subscription->cancelation_requested_at : null,
            $subscription->canceled_at ? $subscription->canceled_at : null,
            $subscription->created_at ? $subscription->created_at : null,
        ];
    }
}

When I check the payload column it is stacked with information that is not my $subscription or $subscription->user for example (small excerpt):

O:55:\"Maatwebsite\\LaravelNovaExcel\\Requests\\SerializedRequest\":3:{s:66:\"\u0000Maatwebsite\\LaravelNovaExcel\\Requests\\SerializedRequest\u0000className\";s:65:\"Maatwebsite\\LaravelNovaExcel\\Requests\\ExportResourceActionRequest\";s:65:\"\u0000Maatwebsite\\LaravelNovaExcel\\Requests\\SerializedRequest\u0000resource\";s:13:\"subscriptions\";s:61:\"\u0000Maatwebsite\\LaravelNovaExcel\\Requests\\SerializedRequest\u0000lens\";N;}s:11:\"\u0000*\u0000resource\";s:52:\"App\\Nova\\Resources\\Program\\Subscription\\Subscription\";s:22:\"\u0000*\u0000serializedResources\";a:43854:{i:0;s:35:\"Laravel\\Nova\\Actions\\ActionResource\";i:1;s:35:\"Laravel\\Nova\\Actions\\ActionResource\";i:2;s:30:\"App\\Nova\\Resources\\Admin\\Admin\";i:3;s:32:\"App\\Nova\\Resources\\Clinic\\Clinic\";i:4;s:36:\"App\\Nova\\Resources\\Clinic\\ClinicUser\";i:5;s:31:\"App\\Nova\\Resources\\Course\\Block\";i:6;s:32:\"App\\Nova\\Resources\\Course\\Course\";i:7;s:36:\"App\\Nova\\Resources\\Course\\CourseUser\";i:8;s:34:\"App\\Nova\\Resources\\Course\\Exercise\";i:9;s:34:\"App\\Nova\\Resources\\Course\\Location\";i:10;s:33:\"App\\Nova\\Resources\\Course\\Message\";i:11;s:33:\"App\\Nova\\Resources\\Course\\Workout\";i:12;s:29:\"App\\Nova\\Resources\\Discipline\";i:13;s:23:\"App\\Nova\\Resources\\Link\";i:14;s:27:\"App\\Nova\\Resources\\Material\";i:15;s:32:\"App\\Nova\\Resources\\Program\\Block\";i:16;s:35:\"App\\Nova\\Resources\\Program\\Exercise\";i:17;s:34:\"App\\Nova\\Resources\\Program\\Program\";i:18;s:38:\"App\\Nova\\Resources\\Program\\ProgramUser\";i:19;s:45:\"App\\Nova\\Resources\\Program\\ProgramUserWorkout\";i:20;s:52:\"App\\Nova\\Resources\\Program\\Subscription\\Subscription\";i:21;s:59:\"App\\Nova\\Resources\\Program\\Subscription\\SubscriptionPayment\";i:22;s:32:\"App\\Nova\\Resources\\Program\\Theme\";i:23;s:34:\"App\\Nova\\Resources\\Program\\Workout\";i:24;s:34:\"App\\Nova\\Resources\\User\\Onboarding\";i:25;s:28:\"App\\Nova\\Resources\\User\\User\";i:26;s:24:\"App\\Nova\\Resources\\Video\";i:27;s:35:\"Laravel\\Nova\\Actions\\ActionResource\";i:28;s:30:\"App\\Nova\\Resources\\Admin\\Admin\";i:29;s:32:\"App\\Nova\\Resources\\Clinic\\Clinic\";i:30;s:36:\"App\\Nova\\Resources\\Clinic\\ClinicUser\";i:31;s:31:\"App\\Nova\\Resources\\Course\\Block\";i:32;s:32:\"App\\Nova\\Resources\\Course\\Course\";i:33;s:36:\"App\\Nova\\Resources\\Course\\CourseUser\";i:34;s:34:\"App\\Nova\\Resources\\Course\\Exercise\";i:35;s:34:\"App\\Nova\\Resources\\Course\\Location\";i:36;s:33:\"App\\Nova\\Resources\\Course\\Message\";i:37;s:33:\"App\\Nova\\Resources\\Course\\Workout\";i:38;

I would not expect App\Nova\Resources\Admin\Admin and App\Nova\Resources\Program\Block etc in there. It looks like it's serializing the entire Nova Object every time and appending it?

We played around with withChunkCount($i) and it helps a bit, but seems like a temporary fix, after more records in the database it started happening again.

Is there something we can do to optimize the serializing? Send less data to the queue?

Using allFields() method breaks export of relationship and computed fields

Prerequisites

  • Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • Checked that your issue isn't already filed.
  • Checked if no PR was submitted that fixes this problem.

Versions

  • PHP version: 7.2.14
  • Laravel version: 5.8.10
  • Nova version: 2.0.1
  • Package version: 3.1.11 and 1.1.3

Description

Using allFields() method breaks export of relationship and computed fields.

Steps to Reproduce

Ensure that your Resource includes a field that is defined with a BelongsTo relationship…

BelongsTo::make('User'),

…or field that returns a computed value…

Text::make('Random number', function () {
    return str_random();
}),

Use the allFields() method on the action as described in the documentation…

public function actions(Request $request)
{
    return [
        (new DownloadExcel)->allFields(),
    ];
}

Expected behavior:

The exported file should contain a representation of the relationship similar to how it appears on the Nova Resource index page. Similarly the file should contain the output generated by closure defined on the computed field.

Actual behavior:

The related record is represented in the Excel file as a foreign key. Computed fields are omitted.

Additional Information

This is already a known issue as indicated by a common made on a previous issue.

Are you using ->allFields() perhaps?

Originally posted by @patrickbrouwers in #26 (comment)

Given that the dev team has been aware of this since at least November 2018 I assume it is difficult or impractical to fix. However it would be useful to have this “feature” documented on the "Customizing Exports” page of the documentation and anywhere else that may be relevant.

Exported file contain Javascript content

Prerequisites

  • Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • Checked that your issue isn't already filed.
  • Checked if no PR was submitted that fixes this problem.

Versions

  • PHP version: 7.1.7
  • Laravel version: 5.7.26
  • Nova version: 1.3.1
  • Package version: 3.1 & 1.1

Description

When i try to export file, content is Javascript content

Steps to Reproduce

Expected behavior:

My data exported

Actual behavior:

Javascript code inside content

Additional Information

On my project i have json editor plugin loaded (cf: https://github.com/json-editor/json-editor). it seems it's Jsoneditor in content file. Maybe it's a conflict ?

peek 20-02-2019 14-24

File doesn’t download in Firefox

When using Firefox and running the DownloadExcel action no file is downloaded.

I am using 64.0a1 (2018-09-10) (64-bit) which is the nightly version which might be the problem. I don’t have the release version for testing.

export relations value

Thanks for this package, it's Awesome.
I want to ask you, if the package can export relation fields like (author name for the post), or is it planned?

[BUG] Invalid argument supplied for foreach()

Versions

  • PHP version:
  • Laravel version: v5.7.28
  • Nova version: v1.3.2
  • Package version: 3.1.11 - 1.1.3

Description

Hi,

I have a simple resource with three fields and when I try to Download the excel. I get this message

Invalid argument supplied for foreach()

When I the code this variable is always null in the ExportToExcel class :

$this->actionFields;

Steps to Reproduce

Install the package, add the action in the resource and test to Download Excel.

I have try on different resources and same bug each time.

Additional Information

If in the package when I try to change the ExportExcel class and replace the

return $this->actionFields;

by this it's work

return [];

About Exporting Select All

When you select all and then export, will it be all records in the database or just all records shown in the current page?

Does not export columns with empty value

Hello, thanks for this great package.

When I am asking to export all attributes from a resource like follows:

public function actions(Request $request)
    {
        return [
            (new DownloadExcel())->allFields()->withHeadings();
        ];
    }

it fails to export attributes with empty value. This consequently mangles the export data with mismatched column/data.

For example, if the a resource in database has the following rows:

+----+------------+------+---------------------+---------------------+
| id | brand      | year | created_at          | updated_at          |
+----+------------+------+---------------------+---------------------+
|  1 | Alfa Romeo | 2018 | 2018-12-14 08:43:51 | 2018-12-14 08:43:51 |
|  2 | Audi       | NULL | 2018-12-14 08:44:10 | 2018-12-14 08:45:05 |
+----+------------+------+---------------------+---------------------+

and I am using the following Nova resource fields (you see Year is not an index field):

public function fields(Request $request)
    {
        return [
            ID::make()->sortable(),
            Text::make('Brand'),
            Number::make('Year')->onlyOnForms()
        ];
    }

will eventually export:

ID,Brand,year,created_at,updated_at
1,Alfa Romeo,2018,2018-12-14 08:43:51,2018-12-14 08:43:51
2,Audi,2018-12-14 08:44:10,2018-12-14 08:45:05

First row has 5 columns but 2nd row has 4 columns.

Debugging the code, I see that this line:

https://github.com/Maatwebsite/Laravel-Nova-Excel/blob/4ecc6c0f815da56e2874d15e79735734930fea0a/src/Actions/ExportToExcel.php#L306

prevents to export attribute if it is empty.

Similar problem is referenced in #18 and #19.

  • PHP v7.2
  • Laravel v5.6
  • Nova v1.2
  • Laravel-Nova-Excel v1.1.1

[BUG] Lens download query using id when lens doesn't

Prerequisites

  • Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • Checked that your issue isn't already filed.
  • Checked if no PR was submitted that fixes this problem.

Versions

  • PHP version: 7.2
  • Laravel version: 5.7
  • Nova version: 1.1.3
  • Package version: 1.0.6

Description

The following error prevents lenses from being downloaded when joins & aggregation.
It seems the download action isn't using an identical query for lenses maybe

Steps to Reproduce

Make a query that doesn't group by the parent id
This lens is attached to an "orders" resource
And it gets the number of orders and the sum
The order id is unrelated and excluded
Which does not pose an issue for nova lenses

public static function query(LensRequest $request, $query)
{
    return $request->withOrdering($request->withFilters(
        $query
            // ->select('orders.id')
            ->addSelect('teams.name as team_name')
            ->addSelect(\DB::raw('count(orders.id) as orders_count'))
            ->addSelect(\DB::raw('sum(orders.total) as spend'))
            ->join('teams', 'orders.team_id', '=', 'teams.id')
            ->groupBy('teams.id')
    ));
}

Expected behavior:

Export the table with a join, aggregate & group by

Actual behavior:

Throws exception stating parent table id isn't included in the group by

[2018-09-28 10:02:29] local.ERROR: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'databasename.orders.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (SQL: select `teams`.`name` as `team_name`, count(orders.id) as orders_count, sum(orders.total) as spend from `orders` inner join `teams` on `orders`.`team_id` = `teams`.`id` where `orders`.`id` in () group by `teams`.`id` order by `orders`.`id` asc limit 200 offset 0) 

Additional Information

A lens is a report table. Not always will the id be assumed.
Most cases it will likely not be.

export PDF?

Hey there! Great package, love the Excel Downloads! Any chance it's possible to download a Nova Resource as a PDF?

Download doesn't apply sort order

Prerequisites

  • Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • Checked that your issue isn't already filed.
  • Checked if no PR was submitted that fixes this problem.

Versions

  • PHP version: 7.2
  • Laravel version: 5.7
  • Nova version: 1.1.4
  • Package version: 1.0.6

Description

When exporting the sort order of the overview is not kept. This makes exporting large lists quite hard.

Steps to Reproduce

Resource with 200 records, order by a value, set per page to 100, download.

Expected behavior:

Download the top 100 (in order)

Actual behavior:

It downloads the 10 ordered by ID

Request for lens support

When downloading from a nova lens, it does not use the lens columns but rather the main resource

The reason I think this is important to address is

  1. The user would expect the file to contain what they see
  2. Provides solution to downloading multiple formats of the resource data

I figured a work around to making a custom file for a specific case would be lenses

VERY useful to say "Go to lens > select specific export lens > click download action"

Lens query and raw select statements

Nova v1.0.16 & Nova Excel v1.0.4

When using lenses as described in the nova docs and adding columns like so

public static function query(LensRequest $request, $query)
{
    return $request->withOrdering($request->withFilters(
        $query->select([
            'id',
            \DB::raw('YEAR(`created_at`) AS `year`'),
            \DB::raw('QUARTER(`created_at`) AS `quarter`'),
            \DB::raw('MONTHNAME(`created_at`) AS `month`'),
        ])
    ));
}
public function fields(Request $request)
{
    return [
        ID::make('ID', 'id')->sortable(),
        Text::make('Year')->sortable(),
        Text::make('Quarter')->sortable(),
        Text::make('Month')->sortable(),
    ];
}

Although it displays as intended, the downloaded file only includes the ids

The raw selects are empty in the resulting file

Interface WithCustomChunkSize not found

Thanks so much for the great plugin! Unfortunately I have problems setting it up on my Users resource. Did I miss something?

screen shot 2018-08-30 at 14 38 08

Is Laravel-Excel a dependency? It's not in my project. Could be the issue, right?

Download failed - Server problem

When trying to download a file the browser would display Failed - Server problem.

Log

Type error: Too few arguments to function Symfony\Component\HttpFoundation\BinaryFileResponse::deleteFileAfterSend(), 0 passed in vendor/maatwebsite/laravel-nova-excel/src/Http/Controllers/ExcelController.php on line 31 and exactly 1 expected

Running on Mac, Valet with Laravel 5.6.

0.00 should not be left empty in the rows.

When exporting a column of data set as decimal(8.2) in MySQL, the column will only add data to the CSV file if the entry is greater than 0.00.

I also noticed that boolean false gets omitted as if it were null, as well. It sounds a lot like something somewhere is using empty() to check if something should be set to an empty string in the CSV.

I don't have time right now to look into it further, but hopefully the package maintainer or someone else will look into the issue. (FYI, to keep things simple, a 0 in lieu of a boolean false would be great in the CSV.)

question about withName() method

Versions

  • PHP version: 7.2.9
  • Laravel version: 5.8
  • Nova version: 2.0.3
  • Package version: 1.1.4

Description

The DownloadExcel action'name is 'Download Excel' by default, I want to display it Chinese like "下载表格",
Then I use the withName() method to change it, the action button is disabled。

// disabled with chinese
(new DownloadExcel)->withName('下载表格')
// abled with english
(new DownloadExcel)->withName('Download')

image

Export to PDF - using MPDF

I got this error when export to PDF

local.ERROR: unlink(C:\Users\user\AppData\Local\Temp\qtsingleapp-lineex-3e70-1-lockfile): Resource temporarily unavailable

  • I was install mpdf package
  • Publish excel config
  • Change config temp_path to another folder (not system temp folder)

---- To fix this issue as my temporary solution ----

  1. Open file ...\vendor\mpdf\mpdf\src\Cache.php

  2. Add this code to __construct
    `
    public function __construct($basePath, $cleanupInterval = 3600)
    {
    if (!$this->createBasePath($basePath)) {
    throw new \Mpdf\MpdfException(sprintf('Temporary files directory "%s" is not writable', $basePath));
    }

     $this->basePath = config('excel.exports.temp_path', $basePath); // <-- I add this code
    
     $this->cleanupInterval = $cleanupInterval;
    

    }
    `
    with this code, I can export as PDF file.


How to fix this issue and not hardcoded core source?
Thank you...

Nova 2.1 support

Hi guys,

Just a quick heads up, upgrading Nova to 2.1 fails because of this package does not support it yet.

No response from DownloadExcel

Installed correctly, php7.2, laravel 5.6.38, orion 1.0.13.
added to actions array on a simple model with just one string field and id field
select all models on index view, run download excel action. request is sent, query is executed, but no response is received and no success message returned. nothing in error logs.

haven't dug very deep to diagnose. does anyone one else have issues?

Undefined index: 0

First of al, great package, just what I needed! 🚀🤟

I keep getting a problem with some basic resources (whereas others work perfectly).

This is the error message:

Undefined offset: 0 at /Users/***/Workspace/***/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php:56

My actions look like this:

    public function actions(Request $request)
    {
        return [
            (new DownloadExcel())->withHeadings('#', 'description')
        ];
    }

The columns does exist in the database, there is also no difficult eagerloading or anything else involved, its just a (really) basic orders table with id, description, total, user_id and timestamps.

More stacktrace:

[2018-08-31 05:56:19] local.ERROR: Undefined offset: 0 {"userId":1,"email":"[email protected]","exception":"[object] (ErrorException(code: 0): Undefined offset: 0 at /Users/***/Workspace/***/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php:56)
[stacktrace]
#0 /Users/***/Workspace/***/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php(56): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8, 'Undefined offse...', '/Users/***...', 56, Array)
#1 /Users/***/Workspace/***/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php(34): PhpOffice\\PhpSpreadsheet\\Cell\\DefaultValueBinder::dataTypeForValue(Array)
#2 /Users/***/Workspace/***/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php(184): PhpOffice\\PhpSpreadsheet\\Cell\\DefaultValueBinder->bindValue(Object(PhpOffice\\PhpSpreadsheet\\Cell\\Cell), Array)
#3 /Users/***/Workspace/***/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Worksheet.php(2508): PhpOffice\\PhpSpreadsheet\\Cell\\Cell->setValue(Array)
#4 /Users/***/Workspace/***/vendor/maatwebsite/excel/src/Sheet.php(208): PhpOffice\\PhpSpreadsheet\\Worksheet\\Worksheet->fromArray(Array, NULL, 'A13', false)

Queued Export Failing on Export of hasMany related model

Problem

  • The queued export appears to be failing when conducting a QueuedExportof a hasMany related model. In our case, we have Clients hasMany Documents and we would like to export the Documents under the Client view. The parameters that we used are:
return (new QueuedExport)
                ->withDisk('s3')
                 ->withHeadings()
                 ->withChunkCount(200);
  • The job in the queue appears to fail and keeps re-attempting. We have traced the issue to where the AppendQueryToSheet job appears to be returning an error. The error appears to trace to $row on map($row) being an object and not an array.

https://github.com/Maatwebsite/Laravel-Nova-Excel/blob/806cafa2cf38de9a8f6c8cbc835445f406148b69/src/Actions/ExportToExcel.php#L227

Diagnosis

Any assistance is appreciated.

Version Used
Laravel-Nova-Excel: v1.10
Laravel: 5.7
PHP: 7.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.