1

I'm trying to export xlsx file that includes around 100,000 rows for 12 months each sheet take one month in laravel 8 using Maatwebsite Excel This process takes around 15~30 mint, So I use a queue in laravel excel in order to keep the job run in the background and notify the user when it finishes. During the process php artisan queue:work --memory=10240 it stops and it shows this error in terminal

enter image description here

If I run php artisan queue:work the process will stop and the job still in jobs table when I run it again it fail and it shows in failed_jobs table with this error

Illuminate\Queue\MaxAttemptsExceededException: Maatwebsite\Excel\Jobs\AppendQueryToSheet has been attempted too many times or run too long. The job may have previously timed out.

What I try to dose and not work with me

1- changing memory_limit post_max_size upload_max_filesize in php.ini I use WAMP SERVER enter image description here

2- changing th memory_limit => 6000000 and chunk_size => 1100 in config/excel.php.

Also, I notice all exported files stop at size 555KB enter image description here

The code to export use queue

class MarkupAccountsYears

<?php

  namespace App\Exports;

  use App\Models\markupPreCalculate;
  use Maatwebsite\Excel\Concerns\FromQuery;
  use Maatwebsite\Excel\Concerns\WithTitle;

  class MarkupAccountsYears implements FromQuery, WithTitle
  {
    

    
    private $month;
    private $year;

    public function __construct(int $year, int $month)
    {
        $this->month = $month;
        $this->year  = $year;
    }


    public function query()
    {   >orderBy('TimeMsc');
       $finalItem = ['real'];
       return markupPreCalculate::query()->select('TimeMsc', '****', 'Login', 'Full_Name', 
        'Group', '****', '****', '****', '****', '****', '****')
         ->whereYear('TimeMsc', $this->year)
         ->whereMonth('TimeMsc', $this->month)
         ->orderBy('TimeMsc')
         ->where(function ($query) use ($finalItem) {
                foreach($finalItem as $keyword){
                  

                          if(is_numeric($keyword))
                          {
                            $query->orwhere('Login', '=',  $keyword);
                          }else
                          {
                            $query->orwhere('Group', 'like',  '%' . $keyword . '%');
                          }
                }
               
            });
    }

      /**
     * @return string
     */
    public function title(): string
    {
        return 'Month ' . $this->month;
    }
}

class MarkupAccount

<?php

namespace App\Exports;

use Illuminate\Contracts\Queue\ShouldQueue;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
use Maatwebsite\Excel\Concerns\Exportable;

class MarkupAccount implements WithMultipleSheets, ShouldQueue
{
    
    use Exportable;
 
    protected $year;
    
    public function __construct(int $year)
    {
        $this->year = $year;
    }

    /**
     * @return array
     */
    public function sheets(): array
    {
      
        $sheets = [];

       for ($month = 1; $month <= 1; $month++) {
            $sheets[] = new MarkupAccountsYears($this->year, $month);
        }
        
        return $sheets;
    }
}

Class MarkupAccount

<?php

namespace App\Exports;

use Illuminate\Contracts\Queue\ShouldQueue;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
use Maatwebsite\Excel\Concerns\Exportable;


class MarkupAccount implements WithMultipleSheets, ShouldQueue
{
    
    use Exportable;
 
    protected $year;
    
    public function __construct(int $year)
    {
        $this->year = $year;
    }

    /**
     * @return array
     */
    public function sheets(): array
    {
      
        $sheets = [];

       for ($month = 1; $month <= 1; $month++) {
            $sheets[] = new MarkupAccountsYears($this->year, $month);
        }
        
        return $sheets;
    }
}

Controller

public function downloadExcl(){  
  (new MarkupAccount(2021))->queue('test'.time().'.xlsx')->chain([dump("Done")]);
}

Is there any way to solve this issue or I'm doing something wrong?

1 Answer 1

-1

I fix the problem by increasing the memory_limit in php.ini in php folder, I was editing the php.ini in the apache folder

%wamp%\bin\php\phpx.x.x\php.ini not under %wamp%\bin\apache\apachex.x.x\php.ini

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

Comments

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.