Laravel 4 Excel 导入失败
Laravel 4 Excel import fails
我正在尝试导入 excel 个文件,但它总是给我这个错误:
PHPExcel_Exception
Row 2 is out of range (2 - 1)
我正在使用 Laravel 4,这是我的代码:
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;
}
这是我的虚拟 excel 文件:
我试过 google 这个,但对于其他人来说,它似乎只在 sheet 大于 1 时才会发生,但在我的情况下并非如此。
您需要 load($destinationPath . $filename)
,而不是 load($destinationPath)
- 该目录不是 Excel 文件。 :-)
我正在尝试导入 excel 个文件,但它总是给我这个错误:
PHPExcel_Exception
Row 2 is out of range (2 - 1)
我正在使用 Laravel 4,这是我的代码:
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;
}
这是我的虚拟 excel 文件:
我试过 google 这个,但对于其他人来说,它似乎只在 sheet 大于 1 时才会发生,但在我的情况下并非如此。
您需要 load($destinationPath . $filename)
,而不是 load($destinationPath)
- 该目录不是 Excel 文件。 :-)