【问题标题】:How to insert an image, Report title and Headers into an excel worksheet using PHP XLSX Writer?如何使用 PHP XLSX Writer 将图像、报告标题和标题插入到 Excel 工作表中?
【发布时间】:2019-03-19 06:14:20
【问题描述】:

我想实现这样的报表标题。如果我使用$writer->writeSheetRow() 添加报告标题和副标题,那么$writer->writeSheetHeader() 不会显示标题行。此外,我无法将图像插入工作表。如果有任何示例代码,那将非常有帮助。提前致谢!

 

【问题讨论】:

    标签: php excel phpxlsxwriter


    【解决方案1】:

    在生成 Excel 之前添加以下代码:

    //locate where you have saved your image
    $image = imagecreatefromjpeg('images/officelogo.jpg');
    $objDrawing = new PHPExcel_Worksheet_MemoryDrawing();
    $objDrawing->setName('Sample image');$objDrawing->setDescription('Sample image');
    $objDrawing->setImageResource($image);
    $objDrawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG);
    $objDrawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT);
    $objDrawing->setHeight(150);
    //Then locate where shall the image be placed in the excel, it indicates the UPPER LEFT corner if the image
    $objDrawing->setCoordinates('A3');
    $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
    

    【讨论】:

    • 我认为您在给出的答案中使用了 PHPExcel。我需要用 php_xlsxwriter 来做这个
    猜你喜欢
    • 1970-01-01
    • 2020-12-06
    • 1970-01-01
    • 2018-03-27
    • 1970-01-01
    • 2011-09-16
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多