2015-10-23 73 views
0

我需要讀取Excel文件並將其記錄在我的數據庫中。我正在使用Laravel + Maatwebsite/Laravel-excel來閱讀文件。隨着我目前的代碼,我沒有錯誤,但沒有數據在瀏覽器中顯示:無法打印Excel文件值

<?php 

namespace App\Http\Controllers; 

use Illuminate\Http\Request; 
use App\Http\Requests; 
use App\Http\Controllers\Controller; 
Use Excel; 

class ImportController extends Controller 
{ 
    public function index() 
    { 
     Excel::load('test.xls', function($reader) { 
      $result = $reader->get(); 

      foreach ($result as $key => $value) { 
       echo $value->situation; 
      } 


     })->get(); 

    } 
} 

的var_dump($結果)

對象(Maatwebsite \ EXCEL \收藏\ RowCollection)#634( 2){[「title」:protected] => string(9)「Worksheet」[「items」:protected] => array(161){[0] => object(Maatwebsite \ Excel \ Collections \ CellCollection)#646 (2){[「title」:protected] => NULL [「items」:protected] => array(1){[0] => NULL}} 1 =>

+0

你在'result'上做了'var_dump'嗎? – messy

+0

@messy更新。 – PlayHardGoPro

回答