SpartnerNL / Laravel-Excel

🚀 Supercharged Excel exports and imports in Laravel
https://laravel-excel.com
MIT License
12.3k stars 1.93k forks source link

[Bug]: Error when importing xlsx file with queue. #3610

Closed carlosoberto88 closed 2 years ago

carlosoberto88 commented 2 years ago

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

What version of Laravel are you using?

5.8

What version of PHP are you using?

7.2

Describe your issue

I'm trying to import a large xlsx file with queues with the following command:

(new MassivesHitImport($this->massivesId))->queue(storage_path('app/public/casablanca.xlsx'))->allOnQueue('reports');

But I get the following error:

ErrorException: simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found in /var/www/html/pruebashitcr/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php:133 Stack trace:

0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'simplexmlload...', '/var/www/html/p...', 133, Array)

1 /var/www/html/pruebashitcr/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php(133): simplexml_load_string('\x01\x00\t\x00\x00\x03@G\x00\x00\x10\x00\xC5\x00\x00...', 'SimpleXMLElemen...', 12, 'http://schemas....')

2 /var/www/html/pruebashitcr/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php(236): PhpOffice\PhpSpreadsheet\Reader\Xlsx->loadZip('docProps/thumbn...', 'http://schemas....')

3 /var/www/html/pruebashitcr/vendor/maatwebsite/excel/src/Reader.php(347): PhpOffice\PhpSpreadsheet\Reader\Xlsx->listWorksheetInfo('/tmp/laravel-ex...')

4 /var/www/html/pruebashitcr/vendor/maatwebsite/excel/src/ChunkReader.php(36): Maatwebsite\Excel\Reader->getTotalRows()

5 /var/www/html/pruebashitcr/vendor/maatwebsite/excel/src/Reader.php(105): Maatwebsite\Excel\ChunkReader->read(Object(App\Imports\MassivesHitImport), Object(Maatwebsite\Excel\Reader), Object(Maatwebsite\Excel\Files\LocalTemporaryFile))

6 /var/www/html/pruebashitcr/vendor/maatwebsite/excel/src/Excel.php(146): Maatwebsite\Excel\Reader->read(Object(App\Imports\MassivesHitImport), '/var/www/html/p...', 'Xlsx', NULL)

7 /var/www/html/pruebashitcr/vendor/maatwebsite/excel/src/Concerns/Importable.php(39): Maatwebsite\Excel\Excel->import(Object(App\Imports\MassivesHitImport), '/var/www/html/p...', NULL, 'Xlsx')

8 /var/www/html/pruebashitcr/vendor/maatwebsite/excel/src/Concerns/Importable.php(98): App\Imports\MassivesHitImport->import('/var/www/html/p...', NULL, NULL)

9 /var/www/html/pruebashitcr/app/Jobs/MassivesHit.php(69): App\Imports\MassivesHitImport->queue('/var/www/html/p...')

10 [internal function]: App\Jobs\MassivesHit->handle()

11 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)

12 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()

13 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))

14 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Container/Container.php(576): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)

15 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)

16 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Bus\Dispatcher->Illuminate\Bus{closure}(Object(App\Jobs\MassivesHit))

17 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(App\Jobs\MassivesHit))

18 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))

19 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(49): Illuminate\Bus\Dispatcher->dispatchNow(Object(App\Jobs\MassivesHit), false)

20 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(88): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\DatabaseJob), Array)

21 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(337): Illuminate\Queue\Jobs\Job->fire()

22 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(283): Illuminate\Queue\Worker->process('database', Object(Illuminate\Queue\Jobs\DatabaseJob), Object(Illuminate\Queue\WorkerOptions))

23 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(118): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\DatabaseJob), 'database', Object(Illuminate\Queue\WorkerOptions))

24 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(102): Illuminate\Queue\Worker->daemon('database', 'reports,default', Object(Illuminate\Queue\WorkerOptions))

25 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(86): Illuminate\Queue\Console\WorkCommand->runWorker('database', 'reports,default')

26 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()

27 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)

28 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()

29 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))

30 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Container/Container.php(576): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)

31 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\Container\Container->call(Array)

32 /var/www/html/pruebashitcr/vendor/symfony/console/Command/Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

33 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

34 /var/www/html/pruebashitcr/vendor/symfony/console/Application.php(1009): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

35 /var/www/html/pruebashitcr/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

36 /var/www/html/pruebashitcr/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

37 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Console/Application.php(90): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

38 /var/www/html/pruebashitcr/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(133): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

39 /var/www/html/pruebashitcr/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

40 {main}

How can the issue be reproduced?

The error occurs when I run the following command:

(new MassivesHitImport($this->massivesId))->queue(storage_path('app/public/casablanca.xlsx'))->allOnQueue('reports');

What should be the expected behaviour?

The file should import while using queues.

patrickbrouwers commented 2 years ago

According to simplexml which is used by phpspreadsheet there's something wrong with your xlsx file.

carlosoberto88 commented 2 years ago

According to simplexml which is used by phpspreadsheet there's something wrong with your xlsx file.

Could it be that the xlsx file is in Spanish which has some special characters? for example CANTÓN, Póliza.

imagen
patrickbrouwers commented 2 years ago

Specials chars shouldn't be an issue. I do see \x01\x00\t\x00\x00\x03@G\x00\x00\x10\x00\xC5\x00\x00 in the stacktrace, that doesn't look right.

carlosoberto88 commented 2 years ago

It appears to be an issue when I want to queue the import, if I use "toArray" or "toCollection" it works perfectly.

patrickbrouwers commented 2 years ago

Sounds like PhpSpreadsheet's chunk reading (read filter) can't deal with this specific file then. I'm afraid I can't fix that in this package.

stale[bot] commented 2 years ago

This bug report has been automatically closed because it has not had recent activity. If this is still an active bug, please comment to reopen. Thank you for your contributions.