I'm trying to import excel files but it always give me this error:
PHPExcel_Exception
Row 2 is out of range (2 - 1)
I'm using Laravel 4 and here's my code:
public function postExcel()
{
$file = Input::file('file');
$destinationPath = public_path() .'/uploads/temp/';
$filename = str_replace(' ', '_', $file->getClientOriginalName());
$file->move($destinationPath, $filename);
$result = Excel::selectSheets('Sheet1')->load($destinationPath)->get();
echo "<pre>";
var_dump($result->toArray());
exit;
}
This is my dummy excel file:
I've tried to google this but for other it seems like it only occurs when the sheet is more than one, but it's not like that in my case.
You need to load($destinationPath . $filename)
, not load($destinationPath)
- the directory isn't an Excel file. :-)