Nov 23, 2017
0
Level 4
How to set the grand total with col span using Maatwebsite/Laravel-Excel?
I pull the data from database and export to xls file, i showed header and content, but how can i include the grand total with colspan based on column to the excel?
// header, content
$someArray = [];$total_qr = ""; $total = "";
foreach ($results as $key => $r) {
$row = array();
$row['No.'] = $key+1;
foreach($groupOption as $go) {
if ($go == 1) {
$row['Name'] = $r->name;
}
if ($go == 2) {
$row['Address'] = $r->address;
}
}
//$row['Total'] = $r->total;
$paArray[] = $row;
}
$today = Carbon::now()->toDateString();
$myFile= Excel::create('Report_'. $today, function($excel) use ($someArray )
{
$excel->setTitle('Report');
$excel->sheet('Report', function($sheet) use ($someArray ) {
$sheet->fromArray($someArray , null, 'A1', true);
});
});
}
Currently, i show my header and content in excel. Butow can i set e.g. grand total at the end of the content with colspan?? Thanks.
Please or to participate in this conversation.