->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);