-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: ErrorException: Undefined variable: sheetExport #4065
Comments
The error you're encountering seems to be related to an undefined variable $writer->write($sheetExport, $this->temporaryFile, $this->writerType); It appears that there's a typo or a variable naming issue. The correct variable name should be $sheetExports = [$this->export]; However, within the loop, you are iterating over foreach ($sheetExports as $sheetIndex => $sheetExport) {
$sheet = $writer->addNewSheet($sheetIndex);
$sheet->open($sheetExport);
} So, when you try to access $writer->write($sheetExports, $this->temporaryFile, $this->writerType); Here's the corrected version of the public function handle(Writer $writer)
{
(new LocalizeJob($this->export))->handle($this, function () use ($writer) {
$writer->open($this->export);
$sheetExports = [$this->export];
if ($this->export instanceof WithMultipleSheets) {
$sheetExports = $this->export->sheets();
}
// Pre-create the worksheets
foreach ($sheetExports as $sheetIndex => $sheetExport) {
$sheet = $writer->addNewSheet($sheetIndex);
$sheet->open($sheetExport);
}
// Write to temp file with empty sheets.
$writer->write($sheetExports, $this->temporaryFile, $this->writerType);
});
} Make sure to replace the problematic line with the corrected one, and the error should be resolved. |
Thank you for your answer, this part of the code is the source code, documents for maatwebsite/excel/SRC/Jobs/QueueExport. PHP, I directly modify the source code is not very good @horgolzari98 |
Sounds like your sheets() method doesn't return sheet objects. |
I nested a layer of laravel job synchronously and put it on the queue and executed it on the cli @patrickbrouwers |
I'm not sure I understand what you mean. Can you show the code of the sheets() method |
Closing as this is a usage error. I've added a more explicit exception when this happens. |
Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?
What version of Laravel Excel are you using?
3.1.26
What version of Laravel are you using?
5.8.38
What version of PHP are you using?
7.3.33
Describe your issue
How can the issue be reproduced?
What should be the expected behaviour?
norlmal
The text was updated successfully, but these errors were encountered: