3

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.

Debiprasad
  • 5,895
  • 16
  • 67
  • 95
  • Probably not relevant, but still - Excel may have hidden worksheets. They are not visible, but when selected by an index - it could return an empty worksheet thus the empty array. – Didzis Nov 20 '20 at 12:14

0 Answers0