Browse Source

Exceles agregados

Jogibeda 5 months ago
parent
commit
5c6a3c6662

+ 156 - 0
modules/excel/controllers/ObraController.php

@@ -0,0 +1,156 @@
+<?php
+
+namespace app\modules\excel\controllers;
+use v1\models\ObraEmpleado;
+use v1\models\Usuario;
+use DateTime;
+use DateTimeZone;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Style\Alignment;
+use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
+use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
+use v1\models\Obra;
+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()	
+      ->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
+            ],
+        ],
+    ];
+      $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;
+        }
+    }
+}

+ 117 - 0
modules/excel/controllers/ObraEmpleadoController.php

@@ -0,0 +1,117 @@
+<?php
+
+namespace app\modules\excel\controllers;
+use v1\models\ObraEmpleado;
+use v1\models\Usuario;
+use DateTime;
+use DateTimeZone;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Style\Alignment;
+use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
+use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
+use v1\models\Obra;
+use Yii;
+use yii\web\Controller;
+
+class ObraEmpleadoController extends Controller {
+
+    public function actionExcelObraEmpleado($idObra) {
+      $obra = Obra::findOne($idObra);
+        $request = Yii::$app->request;
+        $query= ObraEmpleado::find()	
+        ->joinWith('empleado')
+        ->andWhere(['{{ObraEmpleado}}.[[eliminado]]'=>null])->andWhere(['{{ObraEmpleado}}.[[idObra]]'=>$idObra]);
+        $query->orderBy(['creado' => SORT_DESC]);
+        $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:J5');
+        $sheet->setCellValue('A5','Empleados relacionados 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:J8');
+      $sheet->setCellValue('A8', 'Nombre');
+      $sheet->getStyle('A8:J8')->applyFromArray( $headerStyle);
+      $cellBorderStyle = [
+        'borders' => [
+            'allBorders' => [
+                'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
+                'color' => ['argb' => 'FF000000'], // Color negro
+            ],
+        ],
+    ];
+      $row = 9;
+
+        foreach ($query->each() as $obraEmpleado) {
+            $empleado = $obraEmpleado->empleado; 
+            $sheet->mergeCells('A' . $row . ':J' . $row);
+            $sheet->setCellValue('A' . $row, $empleado->nombre); // Nombre del empleado
+            $sheet->getStyle('A' . $row . ':J' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+            $sheet->getStyle('A' . $row . ':J' . $row)->applyFromArray($cellBorderStyle);
+
+            $row++;
+        }
+       
+       
+        $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, "Empleados.xlsx");
+        } catch (\Exception $exception) {
+          return null;
+        }
+    }
+}

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

@@ -0,0 +1,146 @@
+<?php
+
+namespace app\modules\excel\controllers;
+use v1\models\ObraEmpleado;
+use v1\models\Usuario;
+use DateTime;
+use DateTimeZone;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Style\Alignment;
+use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
+use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
+use v1\models\Gasto;
+use v1\models\Obra;
+use v1\models\ObraHerramienta;
+use Yii;
+use yii\web\Controller;
+
+class ObraGastoController extends Controller {
+
+    public function actionExcelObraGasto($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 {
+          ob_start();
+          $writer->save("php://output");
+          $documento = ob_get_contents();
+          ob_clean();
+          Yii::$app->getResponse()->sendContentAsFile($documento, "Gasto.xlsx");
+        } catch (\Exception $exception) {
+          return null;
+        }
+    }
+}

+ 126 - 0
modules/excel/controllers/ObraHerramientaController.php

@@ -0,0 +1,126 @@
+<?php
+
+namespace app\modules\excel\controllers;
+use v1\models\ObraEmpleado;
+use v1\models\Usuario;
+use DateTime;
+use DateTimeZone;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+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 ObraHerramientaController extends Controller {
+
+    public function actionExcelObraHerramienta($idObra) {
+      $obra = Obra::findOne($idObra);
+        $request = Yii::$app->request;
+        $query= ObraHerramienta::find()	
+        ->joinWith('herramienta')
+        ->andWhere(['{{ObraHerramienta}}.[[eliminado]]'=>null])->andWhere(['{{ObraHerramienta}}.[[idObra]]'=>$idObra]);
+        $query->orderBy(['creado' => SORT_DESC]);
+        $spreadsheet = new Spreadsheet();
+        $sheet = $spreadsheet->getActiveSheet();
+        $sheet->setTitle('Herramientas 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','Herramientas relacionadas 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:D8');
+      $sheet->setCellValue('A8', 'Herramienta');
+      $sheet->getStyle('A8:D8')->applyFromArray( $headerStyle);
+      $sheet->mergeCells('E8:J8');
+      $sheet->setCellValue('E8', 'Cantidad');
+      $sheet->getStyle('E8:J8')->applyFromArray( $headerStyle);
+      $cellBorderStyle = [
+        'borders' => [
+            'allBorders' => [
+                'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
+                'color' => ['argb' => 'FF000000'], // Color negro
+            ],
+        ],
+    ];
+      $row = 9;
+
+        foreach ($query->each() as $obraHerramienta) {
+            $herramienta = $obraHerramienta->herramienta; 
+            $sheet->mergeCells('A' . $row . ':D' . $row);
+            $sheet->setCellValue('A' . $row, $herramienta->nombre); // Nombre del empleado
+            $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 . ':J' . $row);
+            $sheet->setCellValue('E' . $row, $obraHerramienta->cantidad); // Nombre del empleado
+            $sheet->getStyle('E' . $row . ':J' . $row)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_JUSTIFY);
+            $sheet->getStyle('E' . $row . ':J' . $row)->applyFromArray($cellBorderStyle);
+
+            $row++;
+        }
+       
+       
+        $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, "Herramientas.xlsx");
+        } catch (\Exception $exception) {
+          return null;
+        }
+    }
+}

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

@@ -0,0 +1,139 @@
+<?php
+
+namespace app\modules\excel\controllers;
+use DateTime;
+use DateTimeZone;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Style\Alignment;
+use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
+use v1\models\Nomina;
+use v1\models\Obra;
+use v1\models\Pago;
+use Yii;
+use yii\web\Controller;
+
+class ObraNominaController extends Controller {
+
+    public function actionExcelObraNomina($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 {
+          ob_start();
+          $writer->save("php://output");
+          $documento = ob_get_contents();
+          ob_clean();
+          Yii::$app->getResponse()->sendContentAsFile($documento, "Nomina.xlsx");
+        } catch (\Exception $exception) {
+          return null;
+        }
+    }
+}

+ 147 - 0
modules/excel/controllers/ObraPagoController.php

@@ -0,0 +1,147 @@
+<?php
+
+namespace app\modules\excel\controllers;
+use v1\models\ObraEmpleado;
+use v1\models\Usuario;
+use DateTime;
+use DateTimeZone;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Style\Alignment;
+use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
+use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
+use v1\models\Gasto;
+use v1\models\Obra;
+use v1\models\ObraHerramienta;
+use v1\models\Pago;
+use Yii;
+use yii\web\Controller;
+
+class ObraPagoController extends Controller {
+
+    public function actionExcelObraPago($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 {
+          ob_start();
+          $writer->save("php://output");
+          $documento = ob_get_contents();
+          ob_clean();
+          Yii::$app->getResponse()->sendContentAsFile($documento, "Pago.xlsx");
+        } catch (\Exception $exception) {
+          return null;
+        }
+    }
+}

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

@@ -0,0 +1,145 @@
+<?php
+
+namespace app\modules\excel\controllers;
+use DateTime;
+use DateTimeZone;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Style\Alignment;
+use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
+use v1\models\Nomina;
+use v1\models\Obra;
+use v1\models\ObraRubro;
+use v1\models\Pago;
+use Yii;
+use yii\web\Controller;
+
+class ObraRubroController extends Controller {
+
+    public function actionExcelObraRubro($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 {
+          ob_start();
+          $writer->save("php://output");
+          $documento = ob_get_contents();
+          ob_clean();
+          Yii::$app->getResponse()->sendContentAsFile($documento, "Rubro.xlsx");
+        } catch (\Exception $exception) {
+          return null;
+        }
+    }
+}