Wednesday, March 15, 2017

PHPExcel_Exception "out of bounds index" using Laravel Excel

I am using laravelExcel to export ~6k to 9k rows of 19 columns but sometimes(only sometimes, have not toughed that code in a couple weeks) I get

"PHPExcel_Exception App\Jobs\ExportLeads You tried to set a sheet active by the out of bounds index: 1. The actual number of sheets is 1."

Code block:

    Excel::create($title, function($excel) use ($account, $date, $data) {
            // Set the title
            $excel->setTitle('Export ' . trans('export.of') . $date);

            // Set compagny
            $excel->setCompany('Foo');

            // Set description
            $excel->setDescription(trans('export.desc'));

            $excel->sheet('leads', function($sheet) use ($account, $data) {
                $sheet->with($data);
            });

        })->store('csv', $basePath . $monthPath);

I have a single sheet and reference it using the name, this is not in a loop.

$data is the array of data to export

EDIT: Forgot to add that I am using laravel 5.3 and Laravel Excel 2.1.10. this code is also in a job and not on an ajax request. its running at night every night



via Alexandre Pilon

Advertisement