簡體   English   中英

無法打印Excel文件值

[英]Can't print Excel file values

我需要讀取一個Excel文件並將其記錄在我的數據庫中。 我正在使用Laravel + Maatwebsite / Laravel-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($ result)

object(Maatwebsite \\ Excel \\ Collections \\ RowCollection)#634(2){[“標題”:受保護] =>字符串(9)“工作表” [“項目”:受保護] => array(161){[0] = > object(Maatwebsite \\ Excel \\ Collections \\ CellCollection)#646(2){[“標題”:protected] => NULL [“ items”:protected] => array(1){[0] => NULL}} 1 =>

您可以通過以下方式循環結果:

// Loop through all sheets
$reader->each(function($sheet) {

    // Loop through all rows
    $sheet->each(function($row) {

    });

});

http://www.maatwebsite.nl/laravel-excel/docs/import上,您可以找到更多信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM