Maatwebsite/Laravel-Excel: How to select sheets other than first sheet using selectSheetsByIndex?

Viewed 1655

Excel::selectSheets('GalleryPhotos')->load($path)->get(); causes an exception when the sheet "GalleryPhotos" has no rows. So, the alternative is to use selectSheetsByIndex instead of selectSheets. For example,

Excel::selectSheetsByIndex(0)->load($path)->get();

But I am encountering some strange issues.

When I use Excel::selectSheetsByIndex(0)->load($path)->get();, it works fine. But when I change that to Excel::selectSheetsByIndex(3)->load($path)->get(); (Please note that instead of selecting the first sheet, I am trying to select the fourth sheet.), it returns me an empty arrary. And any code after that to get data from the sheets return an empty array.

For example, Excel::selectSheets('GradeReports')->load($path)->get(); returns an empty array, if I use selectSheetsByIndex for any sheet other than the first sheet.

I am using Maatwebsite/Laravel-Excel v1.3.7 with Laravel 4.2.

0 Answers
Related