fix affichage totaux dans export Excel
This commit is contained in:
parent
f9b7126cc5
commit
4828686162
@ -153,10 +153,11 @@ foreach(range('P','Z') as $col) {
|
||||
foreach(range('A','B') as $col) {
|
||||
$spreadsheet->getActiveSheet()->setCellValue('A'.$col.($highestRow+2), '=SUM(A'.$col.'2:A'.$col.($highestRow).')');
|
||||
}
|
||||
// Do AA and AB
|
||||
// $spreadsheet->getActiveSheet()->setCellValue('AA'.($highestRow+2), '=SUM(AA2:AA'.($highestRow).')');
|
||||
|
||||
|
||||
|
||||
// Format the total
|
||||
$spreadsheet->getActiveSheet()->getStyle($coord.':AA'.($highestRow+2))->getFill()
|
||||
$spreadsheet->getActiveSheet()->getStyle($coord.':AB'.($highestRow+2))->getFill()
|
||||
->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
|
||||
->getStartColor()->setARGB('AAAAAAAA');
|
||||
|
||||
@ -168,6 +169,7 @@ if ($result = $mysqli->query($query)) {
|
||||
|
||||
$line = 1;
|
||||
/* fetch associative array */
|
||||
$prevSheet = null;
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$ser = $row['formdata'];
|
||||
$seru = unserialize($ser);
|
||||
@ -207,21 +209,27 @@ if ($result = $mysqli->query($query)) {
|
||||
foreach(range('P','Z') as $col) {
|
||||
$prevSheet->setCellValue($col.($highestRow+2), '=SUM('.$col.'2:'.$col.($highestRow).')');
|
||||
}
|
||||
// Do AA
|
||||
// Do AA and AB
|
||||
foreach(range('A','B') as $col) {
|
||||
$prevSheet->setCellValue('A'.$col.($highestRow+2), '=SUM(A'.$col.'2:A'.$col.($highestRow).')');
|
||||
}
|
||||
|
||||
// $prevSheet->setCellValue('AA'.($highestRow+2), '=SUM(AA2:AA'.($highestRow).')');
|
||||
// Format the total
|
||||
$prevSheet->getStyle($coord.':AA'.($highestRow+2))->getFill()
|
||||
$prevSheet->getStyle($coord.':AB'.($highestRow+2))->getFill()
|
||||
->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
|
||||
->getStartColor()->setARGB('BBBBBBBB');
|
||||
|
||||
}
|
||||
$prevSheet = $spreadsheet->getActiveSheet();
|
||||
$prevSheet = $myWorkSheet;
|
||||
$myWorkSheet = $spreadsheet->createSheet();
|
||||
$myWorkSheet->setTitle($fr[$sortName]);
|
||||
foreach (range('A','Z') as $col) {
|
||||
$myWorkSheet->getColumnDimension($col)->setAutoSize(true);
|
||||
}
|
||||
foreach (range('A','E') as $col) {
|
||||
$myWorkSheet->getColumnDimension('A'.$col)->setAutoSize(true);
|
||||
}
|
||||
$myWorkSheet
|
||||
->fromArray(
|
||||
$keys, // The data to set
|
||||
@ -231,6 +239,7 @@ if ($result = $mysqli->query($query)) {
|
||||
);
|
||||
$myWorkSheet->getStyle('1')->getFont()->setBold(true);
|
||||
$line=2;
|
||||
|
||||
$prevName = $fr[$sortName];
|
||||
}
|
||||
|
||||
@ -262,10 +271,12 @@ $spreadsheet->getActiveSheet()->setCellValue($coord, 'TOTAL');
|
||||
foreach(range('P','Z') as $col) {
|
||||
$spreadsheet->getActiveSheet()->setCellValue($col.($highestRow+2), '=SUM('.$col.'2:'.$col.($highestRow).')');
|
||||
}
|
||||
// Do AA
|
||||
$spreadsheet->getActiveSheet()->setCellValue('AA'.($highestRow+2), '=SUM(AA2:AA'.($highestRow).')');
|
||||
foreach(range('A','B') as $col) {
|
||||
$spreadsheet->getActiveSheet()->setCellValue('A'.$col.($highestRow+2), '=SUM(A'.$col.'2:A'.$col.($highestRow).')');
|
||||
}
|
||||
|
||||
// Format the total
|
||||
$spreadsheet->getActiveSheet()->getStyle($coord.':AA'.($highestRow+2))->getFill()
|
||||
$spreadsheet->getActiveSheet()->getStyle($coord.':AB'.($highestRow+2))->getFill()
|
||||
->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
|
||||
->getStartColor()->setARGB('AAAAAAAA');
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user