2

I am trying to import an excel file using laravel-excel so I used this algorithm

$result = Excel::load('public/uploads/test.xlsx',function($reader){

})->get();

but I get the following error : PHPExcel_Exception in RowIterator.php line 125: Row 2 is out of range (2 - 1)

NikiC
  • 100,734
  • 37
  • 191
  • 225
undefined
  • 161
  • 3
  • 16

2 Answers2

7

I think i'm getting too late to answer. Though author gets solved by deleting extra sheets. There is an option with package where you can select specific sheet to read.

$result = Excel::selectSheets('Sheet1')->load('public/uploads/test.xlsx',function($reader){

})->get();

For more details check http://www.maatwebsite.nl/laravel-excel/docs/import for Selecting sheets and columns

Hope this may Help !

Shravan Sharma
  • 989
  • 8
  • 17
1

Here is another solution.

$results = Excel::selectSheetsByIndex(0)->load($currentPath)->get();

You can select sheet by index number.

Piyush
  • 3,947
  • 9
  • 36
  • 69