1

我正在尝试导入 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 文件: 虚拟excel

我试过用谷歌搜索,但对于其他人来说,它似乎只在工作表不止一张时才会发生,但在我的情况下并非如此。

4

1 回答 1

1

您需要load($destinationPath . $filename),而不是load($destinationPath)- 该目录不是 Excel 文件。:-)

于 2015-07-15T03:59:21.947 回答