From: soufiane Date: Tue, 4 Nov 2025 10:15:48 +0000 (+0100) Subject: wip #7828 @0:20 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=cd12c3290fc95037b6d8b3a48d9f3ab0e3591de8;p=fluidbook-toolbox.git wip #7828 @0:20 --- diff --git a/app/Http/Controllers/Admin/Operations/FluidbookCollection/AuditLinksOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookCollection/AuditLinksOperation.php index a43802bb7..5911754d3 100644 --- a/app/Http/Controllers/Admin/Operations/FluidbookCollection/AuditLinksOperation.php +++ b/app/Http/Controllers/Admin/Operations/FluidbookCollection/AuditLinksOperation.php @@ -37,65 +37,74 @@ trait AuditLinksOperation ->getNumberFormat() ->setFormatCode( NumberFormat::FORMAT_TEXT - ); - $sheet = $excel->getActiveSheet(); - $sheetname_error = "Erreurs"; - $sheet->setTitle($sheetname_error); + ); - $excel->getActiveSheet()->getProtection()->setSheet(true); - $excel->getDefaultStyle()->getProtection()->setLocked(false); + $index = 0; + foreach ($links as $key => $link) { + $sheet = $excel->createSheet($index); + $sheetname = ucfirst($key); + $sheet->setTitle($sheetname); - foreach ($links as $sheets) {} - $line = 1; - $columns = 0; - $c = 0; - - for ($i = 1; $i < sizeof($errorKeys); $i++) { - $c++; - $columns = max($columns, $c); - $cell = $sheet->getCellByColumnAndRow($c, $line); - $cell->setValue($errorKeys[$i]); - $style = $sheet->getStyleByColumnAndRow($c, $line); - $style->getFont()->setBold(true); - $style->getAlignment()->setVertical(Alignment::VERTICAL_CENTER); - } + $line = 1; + $columns = 0; + $c = 0; - $maxColSize = []; - - for ($i = 0; $i < sizeof($errorlinks); $i++) { - $c = 1; - $line++; - foreach ($errorlinks[$i] as $k => $value) { - if($k === "id") { - continue; - } + for ($i = 1; $i < sizeof($errorKeys); $i++) { + $c++; $columns = max($columns, $c); - $maxColSize[$c][] = strlen($value); - $sheet->getCellByColumnAndRow($c, $line)->setValue($value); + $cell = $sheet->getCellByColumnAndRow($c, $line); + $cell->setValue($errorKeys[$i]); $style = $sheet->getStyleByColumnAndRow($c, $line); - if ($k !== "new_url") { - $style->getProtection()->setLocked(Protection::PROTECTION_PROTECTED); - } + $style->getFont()->setBold(true); $style->getAlignment()->setVertical(Alignment::VERTICAL_CENTER); - $style->getAlignment()->setWrapText(false); - $c++; } - } - $j = 1; - for ($i = 0; $i <= $columns; $i++) { - if (array_key_exists($j, $maxColSize)) { - if (max($maxColSize[$j]) > 50) { - $sheet->getColumnDimensionByColumn($j)->setWidth(100); + $maxColSize = []; + + for ($i = 0; $i < sizeof($link); $i++) { + $c = 1; + $line++; + foreach ($link[$i] as $k => $value) { + if($k === "id") { + continue; + } + $columns = max($columns, $c); + $maxColSize[$c][] = strlen($value); + $sheet->getCellByColumnAndRow($c, $line)->setValue($value); + $style = $sheet->getStyleByColumnAndRow($c, $line); + if ($k !== "new_url") { + $style->getProtection()->setLocked(Protection::PROTECTION_PROTECTED); + } + $style->getAlignment()->setVertical(Alignment::VERTICAL_CENTER); + $style->getAlignment()->setWrapText(false); + $c++; + } + } + + $j = 1; + for ($i = 0; $i <= $columns; $i++) { + if (array_key_exists($j, $maxColSize)) { + if (max($maxColSize[$j]) > 50) { + $sheet->getColumnDimensionByColumn($j)->setWidth(100); + } else { + $sheet->getColumnDimensionByColumn($j)->setAutoSize(true); + } } else { $sheet->getColumnDimensionByColumn($j)->setAutoSize(true); } - } else { - $sheet->getColumnDimensionByColumn($j)->setAutoSize(true); + $j++; } - $j++; + + $index++; } + $excel->setActiveSheetIndex(0); + $excel->getActiveSheet()->getProtection()->setSheet(true); + $excel->getDefaultStyle()->getProtection()->setLocked(false); + + // Il y a une feuille "Worksheet" qui apparait alors qu'elle a pas été invitée + $excel->removeSheetByIndex(2); + // Direct download $tmpfile = Files::tempnam() . '.xlsx'; $writer = new Xlsx($excel);