ソースを参照

Filtro de fechas con y sin horas para excel

Nermosis 3 年 前
コミット
9ed17e2203
共有1 個のファイルを変更した9 個の追加5 個の削除を含む
  1. 9 5
      application/controllers/ExportXls.php

+ 9 - 5
application/controllers/ExportXls.php ファイルの表示

@@ -315,8 +315,12 @@ class ExportXls extends CI_Controller
315 315
         if ($fecha != "0000-00-00" && $fecha != "0000-00-00 00:00:00") {
316 316
             $fechaFormat = new DateTime($fecha);
317 317
             $fechaFinal = \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($fechaFormat);
318
-        } else {
319
-            $fechaFinal = "00/00/0000";
318
+        } else if ($fecha === "0000-00-00") {
319
+            //$fechaFinal = "00/00/0000";
320
+            $fechaFinal = "";
321
+        } else if ($fecha === "0000-00-00 00:00:00") {
322
+            //$fechaFinal = "00/00/0000 00:00";
323
+            $fechaFinal = "";
320 324
         }
321 325
 
322 326
         return $fechaFinal;
@@ -439,14 +443,12 @@ class ExportXls extends CI_Controller
439 443
                     ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME);
440 444
                 $sheet->SetCellValue('J' . $aux, $datos['smeawardedIndicator']);
441 445
                 $sheet->SetCellValue('K' . $aux, $datos['contract_id']);
442
-                $sheet->SetCellValue('L' . $aux, $datos['contract_issueDate']);
443 446
                 $sheet->SetCellValue('L' . $aux, $this->formatFechas($datos['contract_issueDate']));
444 447
                 $sheet->getStyle('L' . $aux)
445 448
                     ->getNumberFormat()
446 449
                     ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME);
447 450
                 $sheet->SetCellValue('M' . $aux, $datos['partyIdentification']);
448 451
                 $sheet->SetCellValue('N' . $aux, $datos['partyName']);
449
-                $sheet->SetCellValue('O' . $aux, $datos['TaxExclusiveAmount']);
450 452
 
451 453
                 $aux++;
452 454
             }
@@ -490,6 +492,9 @@ class ExportXls extends CI_Controller
490 492
                     ->getNumberFormat()
491 493
                     ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DDMMYYYY);
492 494
                 $sheet->SetCellValue('O' . $aux, $datos['documentAvailablePeriod_EndTime']);
495
+                $sheet->getStyle('O' . $aux)
496
+                    ->getNumberFormat()
497
+                    ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DDMMYYYY);
493 498
 
494 499
                 $aux++;
495 500
             }
@@ -821,7 +826,6 @@ class ExportXls extends CI_Controller
821 826
         $spreadsheet->getActiveSheet()->SetCellValue('L1', 'Fecha de formalización');
822 827
         $spreadsheet->getActiveSheet()->SetCellValue('M1', 'Adjudicatario CIF');
823 828
         $spreadsheet->getActiveSheet()->SetCellValue('N1', 'Nombre Adjudicatario');
824
-        $spreadsheet->getActiveSheet()->SetCellValue('O1', 'Importe de adjudicación sin impuestos');
825 829
 
826 830
         return $spreadsheet;
827 831
     }