首页 > 解决方案 > cyberduck 汇总列值 laravel/excel

问题描述

目前我可以在我的 excel 文件中获取特定工作表内的数据。

        $excel = Importer::make('Excel');
        $excel->hasHeader(true);
        $excel->load($savePath.$fileName);
        $excel->setSheet(6);
        $collection = $excel->getCollection();

        if(sizeof($collection[0]) == 5){
            $arr4 = json_decode($collection,true);

            if(count($arr) > 0){
                return $arr;

            }else{
                return redirect()
            ->back()
            ->with(['errors'=> [0=> 'Please provide correct format for Task List Sheet']])
            ->with('modal',$modal);
            }
        }else{
            $return redirect()
            ->back()
            ->with(['errors'=> [0=> 'Please provide correct format for Task List Sheet']])
            ->with('modal',$modal);
        }

. 这是代码的输出

[{"task_title":"Task 1","work_breakdown_structure":"Description 1","weight":2,"planned_days":5,"actual_days":5},{"task_title":"Task 2","work_breakdown_structure":"Description 2","weight":2,"planned_days":5,"actual_days":5},{"task_title":"Task 3","work_breakdown_structure":"Description 3","weight":2,"planned_days":5,"actual_days":5},{"task_title":"Task 4","work_breakdown_structure":"Description 4","weight":2,"planned_days":5,"actual_days":5},{"task_title":"Task 5","work_breakdown_structure":"Description 5","weight":2,"planned_days":5,"actual_days":5}]

我有这种格式

在此处输入图像描述

我的问题是如何sum up获得 field 的所有值weight

我在用着laravel/excel cyber-duck library

标签: phpexcellaravelcyberduck

解决方案


推荐阅读