Estoy usando Phpspreadsheet en una pagina para exportar excel. Funciona en localhost pero en un host no, me sale el error "Esta página no funciona HTTP ERROR 500".
Este es mi código.
<?php
require '../vendor/autoload.php';
$id_c_dep_sesion = $_GET['user_creacion'];
$fecha1 = $_GET['fecha1'];
$fecha2 = $_GET['fecha2'];
$cargo = $_GET['cargo'];
$usuario = $_GET['usuario'];
$fecha2 = date("Y-m-d");
//sumo 1 día
date("Y-m-d",strtotime($fecha2."+ 1 days"));
use PhpOffice\PhpSpreadsheet\SpreadSheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use \PhpOffice\PhpSpreadsheet\IOFactory;
use \PhpOffice\PhpSpreadsheet\Style\Alignment;
$spreadsheet = new SpreadSheet();
$spreadsheet->getProperties()->setCreator("Eucaliptus")->setTitle("Mi Excel");
$spreadsheet->setActiveSheetIndex(0);
$hojaActiva = $spreadsheet->getActiveSheet();
$spreadsheet->getDefaultStyle()->getFont()->setName('Arial');
$spreadsheet->getDefaultStyle()->getFont()->setSize(9);
//---------------------------
$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing();
$drawing->setName('Paid');
$drawing->setDescription('Paid');
$drawing->setPath('../public/imagenes/eucaliptuslogo.png'); /* put your path and image here */
$drawing->setCoordinates('A1');
$drawing->setOffsetX(0);
$drawing->setRotation(0);
//$drawing->getShadow()->setVisible(true);
//$drawing->getShadow()->setDirection(5);
$drawing->setWorksheet($spreadsheet->getActiveSheet());
//-----------------------
//------------
$hojaActiva->setCellValue('A1','EMPRESA INDUSTRIAL EUCALIPTUS - COSSMIL');
$spreadsheet->getActiveSheet()->mergeCells('A1:I1'); // conbina celdas
$hojaActiva->setCellValue('A2','AREA: PLANIFICACIÓN');
$spreadsheet->getActiveSheet()->mergeCells('A2:I2'); // conbina celdas
$hojaActiva->setCellValue('A3','RESUMEN EJECUTIVO SEMANAL DEL:');
$spreadsheet->getActiveSheet()->mergeCells('A3:I3'); // conbina celdas
$spreadsheet->getActiveSheet()->mergeCells('A4:I4'); // conbina celdas
//centrear texto en celda
$spreadsheet->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
$spreadsheet->getActiveSheet()->getStyle('A2')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
$spreadsheet->getActiveSheet()->getStyle('A3')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="Mi excel.xlsx"');
header('Cache-Control: max-age=0');
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
$writer->save('php://output');
?>