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