简体   繁体   English

Laravel Excel-仅返回行的第一列

[英]Laravel Excel - Only returns first column of row

I'm trying to import Excel-data by Laravel Excel ( http://www.maatwebsite.nl/laravel-excel/docs ). 我正在尝试通过Laravel Excel( http://www.maatwebsite.nl/laravel-excel/docs )导入Excel数据。 I'm using Laravel 4.2. 我正在使用Laravel 4.2。

But i only get the first column of the row in the result, seems strange to me, and I get figure out why. 但是我只得到结果行的第一列,这对我来说似乎很奇怪,而且我知道原因。

Excel::selectSheetsByIndex(0)->load("fileName.xlsx", function($reader) {
    $reader->skip(14);
    dd($reader->first());
});

I get this result: 我得到这个结果:

object(Maatwebsite\Excel\Collections\CellCollection)#19057 (2) {
  ["title":protected]=> NULL ["items":protected]=> array(2) {
    ["flik_1_personal"]=> string(7) "Annika " [0]=> NULL
  }
}

Since the Excel-file looks lite this (the row): 由于Excel文件看起来很简洁,因此该行(行): 在此处输入图片说明

I expected to get all the cells however this is not the case. 我希望得到所有细胞,但事实并非如此。 Does anyone know why this is happening? 有人知道为什么会这样吗? Thanks! 谢谢!

Update Looks like it's because I don't have any "headers" for the other cells (except first name, which is shown in the result). 更新看起来是因为我没有其他单元格的“标头”(名字除外,结果中显示了名字)。 Is there a setting for getting the cells value, without "headers"? 是否有一个获取单元格值的设置,而没有“标题”?

try this 尝试这个

Excel::selectSheetsByIndex(0)->load($file, function($reader) {

            foreach ($reader->toArray() as $row) {
                                            $bb[] = $row;
                                        }
            echo '<pre>';print_r($bb );echo '</pre>';  die();


        });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM