$historyStockProducts] = $this->data; return view( "Excel.StockProducts.Export", compact("historyStockProducts") ); } public function styles(Worksheet $sheet) { $lastRow = $sheet->getHighestDataRow(); $lastContent = $lastRow - 1; $sheet->setCellValue("G$lastRow", "=SUM(G5:G$lastContent)"); $sheet ->getStyle("G") ->getNumberFormat() ->setFormatCode("#,###"); return [ 1 => [ "font" => ["bold" => true, "size" => 12], "alignment" => [ "vertical" => "center", "horizontal" => "center", ], ], 2 => [ "font" => ["bold" => true, "size" => 12], "alignment" => [ "vertical" => "center", "horizontal" => "center", ], ], 4 => [ "font" => ["bold" => true], ], $lastRow => [ "font" => ["bold" => true, "size" => 12], ], ]; } }