Ver código fonte

General excel

Jogibeda 5 meses atrás
pai
commit
9bfec61e3b

+ 238 - 137
modules/excel/controllers/ObraController.php

@@ -10,147 +10,248 @@ use PhpOffice\PhpSpreadsheet\Style\Alignment;
 use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
 use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
 use v1\models\Obra;
+use v1\models\ObraHerramienta;
 use Yii;
 use yii\web\Controller;
 
-class ObraController extends Controller {
-
-    public function actionExcelObra($idObra) {
-      $obra = Obra::findOne($idObra);
-        $request = Yii::$app->request;
-       
-        $spreadsheet = new Spreadsheet();
-        $sheet = $spreadsheet->getActiveSheet();
-        $sheet->setTitle('Empleados');
-
-        $BASEPATH = \Yii::getAlias('@app') . "/web";
-        $logo = $BASEPATH . '/img/logos/edesarrollos-unicolor-azul.png';
-        $fechaInicio = (new DateTime($obra->fechaInicio))->format('d-m-Y');
-        $fechaFin = (new DateTime($obra->fechaFinal))->format('d-m-Y');
-        $drawing = new Drawing();
-        $drawing->setName('Logotipo');
-        $drawing->setDescription('Logotipo de la empresa');
-        $drawing->setPath($logo);
-        $drawing->setHeight(70);
-        $drawing->setCoordinates('A1');
-        $drawing->setOffsetX(10);
-        $drawing->setOffsetY(10);
-        $drawing->setWorksheet($sheet);
-
-        $sheet->mergeCells('A5:N5');
-        $sheet->setCellValue('A5','Obra: ' . $obra->nombre);
-        $sheet->mergeCells('A6:G6');
-        $sheet->setCellValue('A6','Fecha Inicial: ' .$fechaInicio);
-        $sheet->mergeCells('H6:N6');
-        $sheet->setCellValue('H6','Fecha Final: ' .$fechaFin);
-        $sheet->getStyle('A5')->getFont()->setBold(true);
-        $sheet->getStyle('A5')->getFont()->setSize(16);
-
-        $headerStyle = [
-            'font' => [
-                'bold' => true,
-                'color' => ['argb' => 'FFFFFFFF'] // Letras en blanco
-            ],
-            'alignment' => [
-                'horizontal' => Alignment::HORIZONTAL_CENTER,
-                'vertical' => Alignment::VERTICAL_CENTER,
-                'wrapText' => true
-            ],
-            'fill' => [
-                'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
-                'startColor' => ['argb' => 'FF625FF5'] // Fondo azul (con opacidad FF)
-            ],
-            'borders' => [
-                'allBorders' => [
-                    'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
-                    'color' => ['argb' => 'FF020073'], // Bordes azul oscuro (con opacidad FF)
-                ],
-            ],
-        ];
-        
-        
-        
-        // Aplicar el borde a las celdas combinadas
-        $sheet->getStyle('A5:N5')->applyFromArray( $headerStyle);
-        $sheet->getStyle('A6:G6')->applyFromArray( $headerStyle);
-        $sheet->getStyle('H6:N6')->applyFromArray( $headerStyle);
-      
-        //Empleados
-      $empleados= ObraEmpleado::find()	
+class ObraController extends Controller
+{
+
+  public function actionExcelObra($idObra)
+  {
+    $obra = Obra::findOne($idObra);
+    $request = Yii::$app->request;
+
+    $spreadsheet = new Spreadsheet();
+    $sheet = $spreadsheet->getActiveSheet();
+    $sheet->setTitle('Informacion General');
+
+    $BASEPATH = \Yii::getAlias('@app') . "/web";
+    $logo = $BASEPATH . '/img/logos/edesarrollos-unicolor-azul.png';
+    $fechaInicio = (new DateTime($obra->fechaInicio))->format('d-m-Y');
+    $fechaFin = (new DateTime($obra->fechaFinal))->format('d-m-Y');
+    $drawing = new Drawing();
+    $drawing->setName('Logotipo');
+    $drawing->setDescription('Logotipo de la empresa');
+    $drawing->setPath($logo);
+    $drawing->setHeight(70);
+    $drawing->setCoordinates('A1');
+    $drawing->setOffsetX(10);
+    $drawing->setOffsetY(10);
+    $drawing->setWorksheet($sheet);
+
+    $sheet->mergeCells('A5:N5');
+    $sheet->setCellValue('A5', 'Obra: ' . $obra->nombre);
+    $sheet->mergeCells('A6:G6');
+    $sheet->setCellValue('A6', 'Fecha Inicial: ' . $fechaInicio);
+    $sheet->mergeCells('H6:N6');
+    $sheet->setCellValue('H6', 'Fecha Final: ' . $fechaFin);
+    $sheet->getStyle('A5')->getFont()->setBold(true);
+    $sheet->getStyle('A5')->getFont()->setSize(16);
+
+    $headerStyle = [
+      'font' => [
+        'bold' => true,
+        'color' => ['argb' => 'FFFFFFFF'] // Letras en blanco
+      ],
+      'alignment' => [
+        'horizontal' => Alignment::HORIZONTAL_CENTER,
+        'vertical' => Alignment::VERTICAL_CENTER,
+        'wrapText' => true
+      ],
+      'fill' => [
+        'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
+        'startColor' => ['argb' => 'FF625FF5'] // Fondo azul (con opacidad FF)
+      ],
+      'borders' => [
+        'allBorders' => [
+          'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
+          'color' => ['argb' => 'FF020073'], // Bordes azul oscuro (con opacidad FF)
+        ],
+      ],
+    ];
+
+
+
+    // Aplicar el borde a las celdas combinadas
+    $sheet->getStyle('A5:N5')->applyFromArray($headerStyle);
+    $sheet->getStyle('A6:G6')->applyFromArray($headerStyle);
+    $sheet->getStyle('H6:N6')->applyFromArray($headerStyle);
+
+    //Empleados
+    $empleados = ObraEmpleado::find()
       ->joinWith('empleado')
-      ->andWhere(['{{ObraEmpleado}}.[[eliminado]]'=>null])->andWhere(['{{ObraEmpleado}}.[[idObra]]'=>$idObra]);
-      $empleados->orderBy(['creado' => SORT_DESC]);
-      
-      $sheet->mergeCells('A8:G8');
-      $sheet->setCellValue('A8', 'Empleados');
-      $sheet->getStyle('A8:G8')->applyFromArray( $headerStyle);
-      $sheet->mergeCells('A9:D9');
-      $sheet->setCellValue('A9', 'Nombre');
-      $sheet->getStyle('A9:D9')->applyFromArray( $headerStyle);
-      $sheet->mergeCells('E9:G9');
-      $sheet->setCellValue('E9', 'Fecha Alta');
-      $sheet->getStyle('E9:G9')->applyFromArray( $headerStyle);
-      $cellBorderStyle = [
-        'borders' => [
-            'allBorders' => [
-                'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
-                'color' => ['argb' => 'FF000000'], // Color negro
-            ],
+      ->andWhere(['{{ObraEmpleado}}.[[eliminado]]' => null])->andWhere(['{{ObraEmpleado}}.[[idObra]]' => $idObra]);
+    $empleados->orderBy(['creado' => SORT_DESC]);
+
+    $sheet->mergeCells('A8:G8');
+    $sheet->setCellValue('A8', 'Empleados');
+    $sheet->getStyle('A8:G8')->applyFromArray($headerStyle);
+    $sheet->mergeCells('A9:D9');
+    $sheet->setCellValue('A9', 'Nombre');
+    $sheet->getStyle('A9:D9')->applyFromArray($headerStyle);
+    $sheet->mergeCells('E9:G9');
+    $sheet->setCellValue('E9', 'Fecha Alta');
+    $sheet->getStyle('E9:G9')->applyFromArray($headerStyle);
+    $cellBorderStyle = [
+      'borders' => [
+        'allBorders' => [
+          'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
+          'color' => ['argb' => 'FF000000'], // Color negro
         ],
+      ],
     ];
-      $row = 10;
-
-        foreach ($empleados->each() as $obraEmpleado) {
-            $empleado = $obraEmpleado->empleado; 
-            $sheet->mergeCells('A' . $row . ':D' . $row);
-            $sheet->setCellValue('A' . $row, $empleado->nombre); 
-            $sheet->getStyle('A' . $row . ':D' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
-            $sheet->getStyle('A' . $row . ':D' . $row)->applyFromArray($cellBorderStyle);
-
-          
-            $sheet->mergeCells('E' . $row . ':G' . $row);
-            $sheet->setCellValue('E' . $row, $empleado->fechaAlta); 
-            $sheet->getStyle('E' . $row . ':G' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
-            $sheet->getStyle('E' . $row . ':G' . $row)->applyFromArray($cellBorderStyle);
-            $row++;
-        }
-
-   //Herramientas
-
-
-
-/*
-      // Aplicar el borde a las celdas combinadas
-      $sheet->getStyle('A5:J5')->applyFromArray( $headerStyle);
-      $sheet->getStyle('A6:E6')->applyFromArray( $headerStyle);
-      $sheet->getStyle('F6:J6')->applyFromArray( $headerStyle);
-       
-      $sheet->mergeCells('A8:B8');
-      $sheet->getStyle('A8:B8')->applyFromArray( $headerStyle);
-      $sheet->setCellValue('A8', 'Gasto total');
-      
-      $sheet->mergeCells('C8:D8');
-      $sheet->getStyle('C8:D8')->applyFromArray( $headerStyle);
-      $sheet->setCellValue('C8', 'Pago total');
-       
-      $sheet->mergeCells('E8:G8');
-      $sheet->getStyle('E8:G8')->applyFromArray( $headerStyle);
-      $sheet->setCellValue('E8', 'Pago total');
-
-      $sheet->mergeCells('H8:J8');
-      $sheet->getStyle('E8:F8')->applyFromArray( $headerStyle);
-      $sheet->setCellValue('E8', 'Pago total');
-*/
-        $sheet->getStyle('A5')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
-        $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
-        try {
-          ob_start();
-          $writer->save("php://output");
-          $documento = ob_get_contents();
-          ob_clean();
-          Yii::$app->getResponse()->sendContentAsFile($documento, "Obra.xlsx");
-        } catch (\Exception $exception) {
-          return null;
-        }
+    $rowEmpleados = 10;
+
+    foreach ($empleados->each() as $obraEmpleado) {
+      $empleado = $obraEmpleado->empleado;
+      $fecha = (new DateTime($empleado->fechaAlta))->format('d-m-Y');
+
+      $sheet->mergeCells('A' . $rowEmpleados  . ':D' . $rowEmpleados);
+      $sheet->setCellValue('A' . $rowEmpleados, $empleado->nombre);
+      $sheet->getStyle('A' . $rowEmpleados  . ':D' . $rowEmpleados)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+      $sheet->getStyle('A' . $rowEmpleados  . ':D' . $rowEmpleados)->applyFromArray($cellBorderStyle);
+
+
+      $sheet->mergeCells('E' . $rowEmpleados  . ':G' . $rowEmpleados);
+      $sheet->setCellValue('E' . $rowEmpleados, $fecha);
+      $sheet->getStyle('E' . $rowEmpleados  . ':G' . $rowEmpleados)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+      $sheet->getStyle('E' . $rowEmpleados  . ':G' . $rowEmpleados)->applyFromArray($cellBorderStyle);
+      $rowEmpleados++;
+    }
+
+    //Herramientas
+    $query = ObraHerramienta::find()
+      ->joinWith('herramienta')
+      ->andWhere(['{{ObraHerramienta}}.[[eliminado]]' => null])->andWhere(['{{ObraHerramienta}}.[[idObra]]' => $idObra]);
+    $query->orderBy(['creado' => SORT_DESC]);
+    $sheet->mergeCells('H8:N8');
+    $sheet->setCellValue('H8', 'Herramientas');
+    $sheet->getStyle('H8:N8')->applyFromArray($headerStyle);
+    $sheet->mergeCells('H9:K9');
+    $sheet->setCellValue('H9', 'Herramienta');
+    $sheet->getStyle('H9:K9')->applyFromArray($headerStyle);
+    $sheet->mergeCells('L9:N9');
+    $sheet->setCellValue('L9', 'Cantidad');
+    $sheet->getStyle('L9:N9')->applyFromArray($headerStyle);
+    $rowHerramientas = 10;
+
+    foreach ($query->each() as $obraHerramienta) {
+      $herramienta = $obraHerramienta->herramienta;
+      $sheet->mergeCells('H' .  $rowHerramientas . ':K' .  $rowHerramientas);
+      $sheet->setCellValue('H' .  $rowHerramientas, $herramienta->nombre); // Nombre del empleado
+      $sheet->getStyle('H' .  $rowHerramientas . ':K' .  $rowHerramientas)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+      $sheet->getStyle('H' .  $rowHerramientas . ':K' .  $rowHerramientas)->applyFromArray($cellBorderStyle);
+
+      $sheet->mergeCells('L' .  $rowHerramientas . ':N' .  $rowHerramientas);
+      $sheet->setCellValue('L' .  $rowHerramientas, $obraHerramienta->cantidad); // Nombre del empleado
+      $sheet->getStyle('L' .  $rowHerramientas . ':N' .  $rowHerramientas)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+      $sheet->getStyle('L' .  $rowHerramientas . ':N' .  $rowHerramientas)->applyFromArray($cellBorderStyle);
+
+      $rowHerramientas++;
+    }
+
+//Totales
+$totalesController = new \v1\controllers\ObraController('totales', Yii::$app);
+
+$totalGasto = $totalesController->actionTotalGasto($idObra);
+$totalPago = $totalesController->actionTotalPago($idObra);
+$totalNomina = $totalesController->actionTotalNomina($idObra);
+$totalRubro = $totalesController->actionTotalRubro($idObra);
+$saldo = $totalesController->actionSaldo($totalGasto, $totalNomina, $totalPago);
+$ejercidoObra = $totalesController->actionEjercidoObra($totalGasto, $totalRubro);
+$ejercer = $totalesController->actionEjercer($totalRubro, $totalPago);
+
+    $startRowTotales = max($rowEmpleados, $rowHerramientas) + 2;
+
+// Gasto total
+$sheet->mergeCells("A{$startRowTotales}:B{$startRowTotales}");
+$sheet->getStyle("A{$startRowTotales}:B{$startRowTotales}")->applyFromArray($headerStyle);
+$sheet->setCellValue("A{$startRowTotales}", 'Gasto total');
+$sheet->mergeCells("A" . ($startRowTotales + 1) . ":B" . ($startRowTotales + 1)); // Merge en la fila de resultados
+$sheet->setCellValue("A" . ($startRowTotales + 1), $totalGasto);
+$sheet->getStyle("A" . ($startRowTotales + 1))->getNumberFormat()->setFormatCode('"$"#,##0');
+$sheet->getStyle("A" . ($startRowTotales + 1). ":B" . ($startRowTotales + 1))->applyFromArray($cellBorderStyle);
+
+// Pago total
+$sheet->mergeCells("C{$startRowTotales}:D{$startRowTotales}");
+$sheet->getStyle("C{$startRowTotales}:D{$startRowTotales}")->applyFromArray($headerStyle);
+$sheet->setCellValue("C{$startRowTotales}", 'Pago total');
+$sheet->mergeCells("C" . ($startRowTotales + 1) . ":D" . ($startRowTotales + 1)); // Merge en la fila de resultados
+$sheet->setCellValue("C" . ($startRowTotales + 1), $totalPago);
+$sheet->getStyle("C" . ($startRowTotales + 1))->getNumberFormat()->setFormatCode('"$"#,##0');
+$sheet->getStyle("C" . ($startRowTotales + 1). ":D". ($startRowTotales + 1))->applyFromArray($cellBorderStyle);
+
+// Nómina total
+$sheet->mergeCells("E{$startRowTotales}:F{$startRowTotales}");
+$sheet->getStyle("E{$startRowTotales}:F{$startRowTotales}")->applyFromArray($headerStyle);
+$sheet->setCellValue("E{$startRowTotales}", 'Nómina total');
+$sheet->mergeCells("E" . ($startRowTotales + 1) . ":F" . ($startRowTotales + 1)); // Merge en la fila de resultados
+$sheet->setCellValue("E" . ($startRowTotales + 1), $totalNomina);
+$sheet->getStyle("E" . ($startRowTotales + 1))->getNumberFormat()->setFormatCode('"$"#,##0');
+$sheet->getStyle("E" . ($startRowTotales + 1).":F". ($startRowTotales + 1))->applyFromArray($cellBorderStyle);
+
+// Rubro de Obra total
+$sheet->mergeCells("G{$startRowTotales}:H{$startRowTotales}");
+$sheet->getStyle("G{$startRowTotales}:H{$startRowTotales}")->applyFromArray($headerStyle);
+$sheet->setCellValue("G{$startRowTotales}", 'Rubro de Obra total');
+$sheet->mergeCells("G" . ($startRowTotales + 1) . ":H" . ($startRowTotales + 1)); // Merge en la fila de resultados
+$sheet->setCellValue("G" . ($startRowTotales + 1), $totalRubro);
+$sheet->getStyle("G" . ($startRowTotales + 1))->getNumberFormat()->setFormatCode('"$"#,##0');
+$sheet->getStyle("G" . ($startRowTotales + 1). ":H". ($startRowTotales + 1))->applyFromArray($cellBorderStyle);
+
+// Saldo total
+$sheet->mergeCells("I{$startRowTotales}:J{$startRowTotales}");
+$sheet->getStyle("I{$startRowTotales}:J{$startRowTotales}")->applyFromArray($headerStyle);
+$sheet->setCellValue("I{$startRowTotales}", 'Saldo total');
+$sheet->mergeCells("I" . ($startRowTotales + 1) . ":J" . ($startRowTotales + 1)); // Merge en la fila de resultados
+$sheet->setCellValue("I" . ($startRowTotales + 1), $saldo);
+$sheet->getStyle("I" . ($startRowTotales + 1))->getNumberFormat()->setFormatCode('"$"#,##0');
+$sheet->getStyle("I" . ($startRowTotales + 1). ":J" . ($startRowTotales + 1))->applyFromArray($cellBorderStyle);
+
+// Ejercido obra
+$sheet->mergeCells("K{$startRowTotales}:L{$startRowTotales}");
+$sheet->getStyle("K{$startRowTotales}:L{$startRowTotales}")->applyFromArray($headerStyle);
+$sheet->setCellValue("K{$startRowTotales}", 'Ejercido obra');
+$sheet->mergeCells("K" . ($startRowTotales + 1) . ":L" . ($startRowTotales + 1)); // Merge en la fila de resultados
+$sheet->setCellValue("K" . ($startRowTotales + 1), $ejercidoObra);
+$sheet->getStyle("K" . ($startRowTotales + 1))->getNumberFormat()->setFormatCode('"$"#,##0');
+$sheet->getStyle("K" . ($startRowTotales + 1). ":L". ($startRowTotales + 1))->applyFromArray($cellBorderStyle);
+
+// Por ejercer
+$sheet->mergeCells("M{$startRowTotales}:N{$startRowTotales}");
+$sheet->getStyle("M{$startRowTotales}:N{$startRowTotales}")->applyFromArray($headerStyle);
+$sheet->setCellValue("M{$startRowTotales}", 'Por ejercer');
+$sheet->mergeCells("M" . ($startRowTotales + 1) . ":N" . ($startRowTotales + 1)); // Merge en la fila de resultados
+$sheet->setCellValue("M" . ($startRowTotales + 1), $ejercer);
+$sheet->getStyle("M" . ($startRowTotales + 1))->getNumberFormat()->setFormatCode('"$"#,##0');
+$sheet->getStyle("M" . ($startRowTotales + 1). ":N" . ($startRowTotales + 1))->applyFromArray($cellBorderStyle);
+
+$excelGasto= new \app\modules\excel\controllers\ObraGastoController('totales', Yii::$app);
+$sheetGasto = $excelGasto->actionExcelGasto($idObra);
+$spreadsheet->addSheet($sheetGasto);
+
+$excelPago= new \app\modules\excel\controllers\ObraPagoController('totales', Yii::$app);
+$sheetPago = $excelPago->actionExcelPago($idObra);
+$spreadsheet->addSheet($sheetPago);
+
+$excelNomina= new \app\modules\excel\controllers\ObraNominaController('totales', Yii::$app);
+$sheetNomina = $excelNomina->actionExcelNomina($idObra);
+$spreadsheet->addSheet($sheetNomina);
+
+$excelRubro= new \app\modules\excel\controllers\ObraRubroController('totales', Yii::$app);
+$sheetRubro = $excelRubro->actionExcelRubro($idObra);
+$spreadsheet->addSheet($sheetRubro);
+    $sheet->getStyle('A5')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
+    $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
+    try {
+      ob_start();
+      $writer->save("php://output");
+      $documento = ob_get_contents();
+      ob_clean();
+      Yii::$app->getResponse()->sendContentAsFile($documento, "Obra.xlsx");
+    } catch (\Exception $exception) {
+      return null;
     }
-}
+  }
+}

+ 124 - 0
modules/excel/controllers/ObraGastoController.php

@@ -142,5 +142,129 @@ class ObraGastoController extends Controller {
         } catch (\Exception $exception) {
           return null;
         }
+        
     }
+    public function actionExcelGasto($idObra) {
+        $obra = Obra::findOne($idObra);
+          $request = Yii::$app->request;
+          $query= Gasto::find()	
+          ->joinWith('conceptosObra')
+          ->andWhere(['{{Gasto}}.[[eliminado]]'=>null])->andWhere(['{{Gasto}}.[[idObra]]'=>$idObra]);
+          $query->orderBy(['creado' => SORT_DESC]);
+          $spreadsheet = new Spreadsheet();
+          $sheet = $spreadsheet->getActiveSheet();
+          $sheet->setTitle('Gastos de la obra');
+  
+          $BASEPATH = \Yii::getAlias('@app') . "/web";
+          $logo = $BASEPATH . '/img/logos/edesarrollos-unicolor-azul.png';
+          $fechaInicio = (new DateTime($obra->fechaInicio))->format('d-m-Y');
+          $fechaFin = (new DateTime($obra->fechaFinal))->format('d-m-Y');
+          $drawing = new Drawing();
+          $drawing->setName('Logotipo');
+          $drawing->setDescription('Logotipo de la empresa');
+          $drawing->setPath($logo);
+          $drawing->setHeight(70);
+          $drawing->setCoordinates('A1');
+          $drawing->setOffsetX(10);
+          $drawing->setOffsetY(10);
+          $drawing->setWorksheet($sheet);
+  
+          $sheet->mergeCells('A5:J5');
+          $sheet->setCellValue('A5','Gastos relacionado a la obra: ' . $obra->nombre);
+          $sheet->mergeCells('A6:E6');
+          $sheet->setCellValue('A6','Fecha Inicial: ' .$fechaInicio);
+          $sheet->mergeCells('F6:J6');
+          $sheet->setCellValue('F6','Fecha Final: ' .$fechaFin);
+          $sheet->getStyle('A5')->getFont()->setBold(true);
+          $sheet->getStyle('A5')->getFont()->setSize(16);
+  
+          $headerStyle = [
+            'font' => [
+                'bold' => true,
+                'color' => ['argb' => 'FFFFFFFF'] // Letras en blanco
+            ],
+            'alignment' => [
+                'horizontal' => Alignment::HORIZONTAL_CENTER,
+                'vertical' => Alignment::VERTICAL_CENTER,
+                'wrapText' => true
+            ],
+            'fill' => [
+                'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
+                'startColor' => ['argb' => 'FF625FF5'] // Fondo azul (con opacidad FF)
+            ],
+            'borders' => [
+                'allBorders' => [
+                    'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
+                    'color' => ['argb' => 'FF020073'], // Bordes azul oscuro (con opacidad FF)
+                ],
+            ],
+        ];
+        
+        
+        
+        // Aplicar el borde a las celdas combinadas
+        $sheet->getStyle('A5:J5')->applyFromArray( $headerStyle);
+        $sheet->getStyle('A6:E6')->applyFromArray( $headerStyle);
+        $sheet->getStyle('F6:J6')->applyFromArray( $headerStyle);
+         
+        $sheet->mergeCells('A8:C8');
+        $sheet->setCellValue('A8', 'Concepto Obra');
+        $sheet->getStyle('A8:C8')->applyFromArray( $headerStyle);
+        $sheet->mergeCells('D8:E8');
+        $sheet->setCellValue('D8', 'Cantidad');
+        $sheet->getStyle('D8:E8')->applyFromArray( $headerStyle);
+        $sheet->mergeCells('F8:G8');
+        $sheet->setCellValue('F8', 'Fecha Compra');
+        $sheet->getStyle('F8:G8')->applyFromArray( $headerStyle);
+        $sheet->mergeCells('H8:J8');
+        $sheet->setCellValue('H8', 'Descripción');
+        $sheet->getStyle('H8:J8')->applyFromArray( $headerStyle);
+        $cellBorderStyle = [
+          'borders' => [
+              'allBorders' => [
+                  'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
+                  'color' => ['argb' => 'FF000000'], // Color negro
+              ],
+          ],
+      ];
+        $row = 9;
+  
+          foreach ($query->each() as $obraGasto) {
+              $fecha = (new DateTime($obraGasto->fechaCompra))->format('d-m-Y');
+  
+              $gasto = $obraGasto->conceptosObra; 
+              $sheet->mergeCells('A' . $row . ':C' . $row);
+             $sheet->setCellValue('A' . $row, $gasto->concepto); 
+              $sheet->getStyle('A' . $row . ':C' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+              $sheet->getStyle('A' . $row . ':C' . $row)->applyFromArray($cellBorderStyle);
+  
+              $sheet->mergeCells('D' . $row . ':E' . $row);
+              $sheet->setCellValue('D' . $row, $obraGasto->cantidad); 
+              $sheet->getStyle('D' . $row . ':E' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+              $sheet->getStyle('D' . $row . ':E' . $row)->applyFromArray($cellBorderStyle);
+              $sheet->getStyle('D' . $row)
+              ->getNumberFormat()
+              ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
+              $sheet->mergeCells('F' . $row . ':G' . $row);
+              $sheet->setCellValue('F' . $row, $fecha); 
+              $sheet->getStyle('F' . $row . ':G' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+              $sheet->getStyle('F' . $row . ':G' . $row)->applyFromArray($cellBorderStyle);
+              
+              $sheet->mergeCells('H' . $row . ':J' . $row);
+              $sheet->setCellValue('H' . $row, $obraGasto->descripcion);
+              $sheet->getStyle('H' . $row . ':J' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+              $sheet->getStyle('H' . $row . ':J' . $row)->applyFromArray($cellBorderStyle);
+              $row++;
+          }
+         
+         
+          $sheet->getStyle('A5')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
+          $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
+          try {
+           return $sheet;
+          } catch (\Exception $exception) {
+            return null;
+          }
+          
+      }
 }

+ 120 - 0
modules/excel/controllers/ObraNominaController.php

@@ -136,4 +136,124 @@ class ObraNominaController extends Controller {
           return null;
         }
     }
+
+
+    public function actionExcelNomina($idObra) {
+        $obra = Obra::findOne($idObra);
+          $request = Yii::$app->request;
+          $query= Nomina::find()	
+          ->joinWith('empleado')
+          ->andWhere(['{{Nomina}}.[[eliminado]]'=>null])->andWhere(['{{Nomina}}.[[idObra]]'=>$idObra]);
+          $query->orderBy(['creado' => SORT_DESC]);
+          $spreadsheet = new Spreadsheet();
+          $sheet = $spreadsheet->getActiveSheet();
+          $sheet->setTitle('Nomina de la obra');
+  
+          $BASEPATH = \Yii::getAlias('@app') . "/web";
+          $logo = $BASEPATH . '/img/logos/edesarrollos-unicolor-azul.png';
+          $fechaInicio = (new DateTime($obra->fechaInicio))->format('d-m-Y');
+          $fechaFin = (new DateTime($obra->fechaFinal))->format('d-m-Y');
+          $drawing = new Drawing();
+          $drawing->setName('Logotipo');
+          $drawing->setDescription('Logotipo de la empresa');
+          $drawing->setPath($logo);
+          $drawing->setHeight(70);
+          $drawing->setCoordinates('A1');
+          $drawing->setOffsetX(10);
+          $drawing->setOffsetY(10);
+          $drawing->setWorksheet($sheet);
+  
+          $sheet->mergeCells('A5:J5');
+          $sheet->setCellValue('A5','Nomina relacionado a la obra: ' . $obra->nombre);
+          $sheet->mergeCells('A6:E6');
+          $sheet->setCellValue('A6','Fecha Inicial: ' .$fechaInicio);
+          $sheet->mergeCells('F6:J6');
+          $sheet->setCellValue('F6','Fecha Final: ' .$fechaFin);
+          $sheet->getStyle('A5')->getFont()->setBold(true);
+          $sheet->getStyle('A5')->getFont()->setSize(16);
+  
+          $headerStyle = [
+            'font' => [
+                'bold' => true,
+                'color' => ['argb' => 'FFFFFFFF'] // Letras en blanco
+            ],
+            'alignment' => [
+                'horizontal' => Alignment::HORIZONTAL_CENTER,
+                'vertical' => Alignment::VERTICAL_CENTER,
+                'wrapText' => true
+            ],
+            'fill' => [
+                'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
+                'startColor' => ['argb' => 'FF625FF5'] // Fondo azul (con opacidad FF)
+            ],
+            'borders' => [
+                'allBorders' => [
+                    'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
+                    'color' => ['argb' => 'FF020073'], // Bordes azul oscuro (con opacidad FF)
+                ],
+            ],
+        ];
+        
+        
+        
+        // Aplicar el borde a las celdas combinadas
+        $sheet->getStyle('A5:J5')->applyFromArray( $headerStyle);
+        $sheet->getStyle('A6:E6')->applyFromArray( $headerStyle);
+        $sheet->getStyle('F6:J6')->applyFromArray( $headerStyle);
+         
+        $sheet->mergeCells('A8:C8');
+        $sheet->setCellValue('A8', 'Concepto Obra');
+        $sheet->getStyle('A8:C8')->applyFromArray( $headerStyle);
+        $sheet->mergeCells('D8:F8');
+        $sheet->setCellValue('D8', 'Cantidad');
+        $sheet->getStyle('D8:F8')->applyFromArray( $headerStyle);
+        $sheet->mergeCells('G8:J8');
+        $sheet->setCellValue('G8', 'Fecha Inicio y Fecha Fin');
+        $sheet->getStyle('G8:J8')->applyFromArray( $headerStyle);
+        
+        $cellBorderStyle = [
+          'borders' => [
+              'allBorders' => [
+                  'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
+                  'color' => ['argb' => 'FF000000'], // Color negro
+              ],
+          ],
+      ];
+        $row = 9;
+  
+          foreach ($query->each() as $obraNomina) {
+              $fechaInicio = (new DateTime($obraNomina->fechaInicio))->format('d-m-Y');
+              $fechaFin = (new DateTime($obraNomina->fechaFin))->format('d-m-Y');
+  
+              $empleado = $obraNomina->empleado; 
+              $sheet->mergeCells('A' . $row . ':C' . $row);
+             $sheet->setCellValue('A' . $row, $empleado->nombre);
+              $sheet->getStyle('A' . $row . ':C' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+              $sheet->getStyle('A' . $row . ':C' . $row)->applyFromArray($cellBorderStyle);
+  
+              $sheet->mergeCells('D' . $row . ':F' . $row);
+              $sheet->setCellValue('D' . $row, $obraNomina->montoPagado); 
+              $sheet->getStyle('D' . $row . ':F' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+              $sheet->getStyle('D' . $row . ':F' . $row)->applyFromArray($cellBorderStyle);
+              $sheet->getStyle('D' . $row)
+              ->getNumberFormat()
+              ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
+              $sheet->mergeCells('G' . $row . ':J' . $row);
+              $sheet->setCellValue('G' . $row, $fechaInicio . ' al ' .$fechaFin); 
+              $sheet->getStyle('G' . $row . ':J' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+              $sheet->getStyle('G' . $row . ':J' . $row)->applyFromArray($cellBorderStyle);
+              
+              
+              $row++;
+          }
+         
+         
+          $sheet->getStyle('A5')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
+          $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
+          try {
+           return $sheet;
+          } catch (\Exception $exception) {
+            return null;
+          }
+      }
 }

+ 125 - 1
modules/excel/controllers/ObraPagoController.php

@@ -144,4 +144,128 @@ class ObraPagoController extends Controller {
           return null;
         }
     }
-}
+
+
+    public function actionExcelPago($idObra) {
+        $obra = Obra::findOne($idObra);
+          $request = Yii::$app->request;
+          $query= Pago::find()	
+          ->joinWith('conceptosObra')
+          ->andWhere(['{{Pago}}.[[eliminado]]'=>null])->andWhere(['{{Pago}}.[[idObra]]'=>$idObra]);
+          $query->orderBy(['creado' => SORT_DESC]);
+          $spreadsheet = new Spreadsheet();
+          $sheet = $spreadsheet->getActiveSheet();
+          $sheet->setTitle('Pagos de la obra');
+  
+          $BASEPATH = \Yii::getAlias('@app') . "/web";
+          $logo = $BASEPATH . '/img/logos/edesarrollos-unicolor-azul.png';
+          $fechaInicio = (new DateTime($obra->fechaInicio))->format('d-m-Y');
+          $fechaFin = (new DateTime($obra->fechaFinal))->format('d-m-Y');
+          $drawing = new Drawing();
+          $drawing->setName('Logotipo');
+          $drawing->setDescription('Logotipo de la empresa');
+          $drawing->setPath($logo);
+          $drawing->setHeight(70);
+          $drawing->setCoordinates('A1');
+          $drawing->setOffsetX(10);
+          $drawing->setOffsetY(10);
+          $drawing->setWorksheet($sheet);
+  
+          $sheet->mergeCells('A5:J5');
+          $sheet->setCellValue('A5','Pagos relacionado a la obra: ' . $obra->nombre);
+          $sheet->mergeCells('A6:E6');
+          $sheet->setCellValue('A6','Fecha Inicial: ' .$fechaInicio);
+          $sheet->mergeCells('F6:J6');
+          $sheet->setCellValue('F6','Fecha Final: ' .$fechaFin);
+          $sheet->getStyle('A5')->getFont()->setBold(true);
+          $sheet->getStyle('A5')->getFont()->setSize(16);
+  
+          $headerStyle = [
+            'font' => [
+                'bold' => true,
+                'color' => ['argb' => 'FFFFFFFF'] // Letras en blanco
+            ],
+            'alignment' => [
+                'horizontal' => Alignment::HORIZONTAL_CENTER,
+                'vertical' => Alignment::VERTICAL_CENTER,
+                'wrapText' => true
+            ],
+            'fill' => [
+                'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
+                'startColor' => ['argb' => 'FF625FF5'] // Fondo azul (con opacidad FF)
+            ],
+            'borders' => [
+                'allBorders' => [
+                    'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
+                    'color' => ['argb' => 'FF020073'], // Bordes azul oscuro (con opacidad FF)
+                ],
+            ],
+        ];
+        
+        
+        
+        // Aplicar el borde a las celdas combinadas
+        $sheet->getStyle('A5:J5')->applyFromArray( $headerStyle);
+        $sheet->getStyle('A6:E6')->applyFromArray( $headerStyle);
+        $sheet->getStyle('F6:J6')->applyFromArray( $headerStyle);
+         
+        $sheet->mergeCells('A8:C8');
+        $sheet->setCellValue('A8', 'Concepto Obra');
+        $sheet->getStyle('A8:C8')->applyFromArray( $headerStyle);
+        $sheet->mergeCells('D8:E8');
+        $sheet->setCellValue('D8', 'Cantidad');
+        $sheet->getStyle('D8:E8')->applyFromArray( $headerStyle);
+        $sheet->mergeCells('F8:G8');
+        $sheet->setCellValue('F8', 'Fecha Pago');
+        $sheet->getStyle('F8:G8')->applyFromArray( $headerStyle);
+        $sheet->mergeCells('H8:J8');
+        $sheet->setCellValue('H8', 'Descripción');
+        $sheet->getStyle('H8:J8')->applyFromArray( $headerStyle);
+        $cellBorderStyle = [
+          'borders' => [
+              'allBorders' => [
+                  'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
+                  'color' => ['argb' => 'FF000000'], // Color negro
+              ],
+          ],
+      ];
+        $row = 9;
+  
+          foreach ($query->each() as $obraPago) {
+              $fecha = (new DateTime($obraPago->fechaPago))->format('d-m-Y');
+  
+              $gasto = $obraPago->conceptosObra; 
+              $sheet->mergeCells('A' . $row . ':C' . $row);
+             $sheet->setCellValue('A' . $row, $gasto->concepto);
+              $sheet->getStyle('A' . $row . ':C' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+              $sheet->getStyle('A' . $row . ':C' . $row)->applyFromArray($cellBorderStyle);
+  
+              $sheet->mergeCells('D' . $row . ':E' . $row);
+              $sheet->setCellValue('D' . $row, $obraPago->cantidad); 
+              $sheet->getStyle('D' . $row . ':E' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+              $sheet->getStyle('D' . $row . ':E' . $row)->applyFromArray($cellBorderStyle);
+              $sheet->getStyle('D' . $row)
+              ->getNumberFormat()
+              ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
+              $sheet->mergeCells('F' . $row . ':G' . $row);
+              $sheet->setCellValue('F' . $row, $fecha); 
+              $sheet->getStyle('F' . $row . ':G' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+              $sheet->getStyle('F' . $row . ':G' . $row)->applyFromArray($cellBorderStyle);
+              
+              $sheet->mergeCells('H' . $row . ':J' . $row);
+              $sheet->setCellValue('H' . $row, $obraPago->descripcion);
+              $sheet->getStyle('H' . $row . ':J' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+              $sheet->getStyle('H' . $row . ':J' . $row)->applyFromArray($cellBorderStyle);
+              $row++;
+          }
+         
+         
+          $sheet->getStyle('A5')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
+          $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
+          try {
+           return $sheet;
+          } catch (\Exception $exception) {
+            return null;
+          }
+      }
+  }

+ 124 - 0
modules/excel/controllers/ObraRubroController.php

@@ -142,4 +142,128 @@ class ObraRubroController extends Controller {
           return null;
         }
     }
+
+    public function actionExcelRubro($idObra) {
+        $obra = Obra::findOne($idObra);
+          $request = Yii::$app->request;
+          $query= ObraRubro::find()	
+          ->joinWith('conceptoObra')
+          ->andWhere(['{{ObraRubro}}.[[eliminado]]'=>null])->andWhere(['{{ObraRubro}}.[[idObra]]'=>$idObra]);
+          $query->orderBy(['creado' => SORT_DESC]);
+          $spreadsheet = new Spreadsheet();
+          $sheet = $spreadsheet->getActiveSheet();
+          $sheet->setTitle('Rubro de la obra');
+  
+          $BASEPATH = \Yii::getAlias('@app') . "/web";
+          $logo = $BASEPATH . '/img/logos/edesarrollos-unicolor-azul.png';
+          $fechaInicio = (new DateTime($obra->fechaInicio))->format('d-m-Y');
+          $fechaFin = (new DateTime($obra->fechaFinal))->format('d-m-Y');
+          $drawing = new Drawing();
+          $drawing->setName('Logotipo');
+          $drawing->setDescription('Logotipo de la empresa');
+          $drawing->setPath($logo);
+          $drawing->setHeight(70);
+          $drawing->setCoordinates('A1');
+          $drawing->setOffsetX(10);
+          $drawing->setOffsetY(10);
+          $drawing->setWorksheet($sheet);
+  
+          $sheet->mergeCells('A5:J5');
+          $sheet->setCellValue('A5','Rubro relacionado a la obra: ' . $obra->nombre);
+          $sheet->mergeCells('A6:E6');
+          $sheet->setCellValue('A6','Fecha Inicial: ' .$fechaInicio);
+          $sheet->mergeCells('F6:J6');
+          $sheet->setCellValue('F6','Fecha Final: ' .$fechaFin);
+          $sheet->getStyle('A5')->getFont()->setBold(true);
+          $sheet->getStyle('A5')->getFont()->setSize(16);
+  
+          $headerStyle = [
+            'font' => [
+                'bold' => true,
+                'color' => ['argb' => 'FFFFFFFF'] // Letras en blanco
+            ],
+            'alignment' => [
+                'horizontal' => Alignment::HORIZONTAL_CENTER,
+                'vertical' => Alignment::VERTICAL_CENTER,
+                'wrapText' => true
+            ],
+            'fill' => [
+                'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
+                'startColor' => ['argb' => 'FF625FF5'] // Fondo azul (con opacidad FF)
+            ],
+            'borders' => [
+                'allBorders' => [
+                    'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
+                    'color' => ['argb' => 'FF020073'], // Bordes azul oscuro (con opacidad FF)
+                ],
+            ],
+        ];
+        
+        
+        
+        // Aplicar el borde a las celdas combinadas
+        $sheet->getStyle('A5:J5')->applyFromArray( $headerStyle);
+        $sheet->getStyle('A6:E6')->applyFromArray( $headerStyle);
+        $sheet->getStyle('F6:J6')->applyFromArray( $headerStyle);
+         
+        $sheet->mergeCells('A8:C8');
+        $sheet->setCellValue('A8', 'Concepto Obra');
+        $sheet->getStyle('A8:C8')->applyFromArray( $headerStyle);
+        $sheet->mergeCells('D8:E8');
+        $sheet->setCellValue('D8', 'Cantidad');
+        $sheet->getStyle('D8:E8')->applyFromArray( $headerStyle);
+        $sheet->mergeCells('F8:G8');
+        $sheet->setCellValue('F8', 'Fecha Compra');
+        $sheet->getStyle('F8:G8')->applyFromArray( $headerStyle);
+        $sheet->mergeCells('H8:J8');
+        $sheet->setCellValue('H8', 'Descripción');
+        $sheet->getStyle('H8:J8')->applyFromArray( $headerStyle);
+        
+        $cellBorderStyle = [
+          'borders' => [
+              'allBorders' => [
+                  'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
+                  'color' => ['argb' => 'FF000000'], // Color negro
+              ],
+          ],
+      ];
+        $row = 9;
+  
+          foreach ($query->each() as $obraRubro) {
+              $fecha = (new DateTime($obraRubro->fechaCompra))->format('d-m-Y');
+  
+              $gasto = $obraRubro->conceptoObra; 
+              $sheet->mergeCells('A' . $row . ':C' . $row);
+             $sheet->setCellValue('A' . $row, $gasto->concepto); 
+              $sheet->getStyle('A' . $row . ':C' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+              $sheet->getStyle('A' . $row . ':C' . $row)->applyFromArray($cellBorderStyle);
+  
+              $sheet->mergeCells('D' . $row . ':E' . $row);
+              $sheet->setCellValue('D' . $row, $obraRubro->cantidad); 
+              $sheet->getStyle('D' . $row . ':E' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+              $sheet->getStyle('D' . $row . ':E' . $row)->applyFromArray($cellBorderStyle);
+              $sheet->getStyle('D' . $row)
+              ->getNumberFormat()
+              ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
+              $sheet->mergeCells('F' . $row . ':G' . $row);
+              $sheet->setCellValue('F' . $row, $fecha); 
+              $sheet->getStyle('F' . $row . ':G' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+              $sheet->getStyle('F' . $row . ':G' . $row)->applyFromArray($cellBorderStyle);
+              
+              $sheet->mergeCells('H' . $row . ':J' . $row);
+              $sheet->setCellValue('H' . $row, $obraRubro->descripcion);
+              $sheet->getStyle('H' . $row . ':J' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+              $sheet->getStyle('H' . $row . ':J' . $row)->applyFromArray($cellBorderStyle);
+              $row++;
+          }
+         
+         
+          $sheet->getStyle('A5')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
+          $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
+          try {
+           return $sheet;
+          } catch (\Exception $exception) {
+            return null;
+          }
+      }
 }