Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88835

how to add footer with the value of total cost in laravel excel package

$
0
0

how to add footer with a value of total cost of the certain gathered value

data

    name       unitcost
  January       500
  February      1000

Controller

return Excel::download(new ExportReport($request->id), 'Report.xlsx');

Export Report

namespace App\Exports;
use DB;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Schema;

use Maatwebsite\Excel\Concerns\FromCollection;

 class ExportMonth implements FromCollection,WithHeadings
 {
/**
* @return \Illuminate\Support\Collection
*/
    protected $id;

    function __construct($id) {
           $this->id = $id;
    }

    public function collection()
    {
        return DB::Table($this->id)
        ->get();
    }
    public function headings(): array
    {
        return Schema::getColumnListing($this->id);
    }
 }

Expected Result something like this

enter image description here


Viewing all articles
Browse latest Browse all 88835

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>