admin管理员组

文章数量:1344241

I'm having trouble converting an Excel file to a PDF. The PDF file is created, but nothing is in it.

Here's my code.

    <?php 

    require_once '../../excel/vendor/autoload.php';
    require_once "../conexion.php"; 
    
    use PhpOffice\PhpSpreadsheet\IOFactory;

    $obj = new Conexion();
    $conexion = $obj -> conectar();

    $sql="SELECT * FROM servicios WHERE id='6'";
    $result=mysqli_query($conexion,$sql);
    $mostrar = mysqli_fetch_row($result); 
    
    $filename = '../../documento/OT.xlsx';
    $spreadsheet = IOFactory::load($filename);
    $worksheet = $spreadsheet->getActiveSheet();
    $worksheet->mergeCells('C4:E4')->setCellValue("C4","Presupuesto No. ".$mostrar[0]);
    $worksheet->mergeCells('H11:I11')->setCellValue("H11",date('d/m/Y',strtotime($mostrar[1])));
    $worksheet->mergeCells('H12:I12')->setCellValue("H12",$mostrar[2]);
    $worksheet->mergeCells('H13:I13')->setCellValue("H13",$mostrar[3]);
    $worksheet->mergeCells('E14:I14')->setCellValue("E14",$mostrar[4]);
    $worksheet->mergeCells('C15:I15')->setCellValue("C15",'Atención : '.$mostrar[5]);
    $worksheet->setCellValue("I19",$mostrar[7]);

    $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Mpdf');
    $writer->save("05featuredemo.pdf");
?>

本文标签: phpConvert Excel file to PDF with PhpspreadsheetStack Overflow