1

Currently I can get the data inside of specific sheet in my excel file.

        $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);
        }

. This is the out put of the code

[{"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}]

I have this format

enter image description here

My problem is how can I sum up all the values of field weight ?

I'm using laravel/excel cyber-duck library

Pablo
  • 1,357
  • 1
  • 11
  • 40

0 Answers0