【发布时间】:2019-03-19 06:14:20
【问题描述】:
我想实现这样的报表标题。如果我使用$writer->writeSheetRow() 添加报告标题和副标题,那么$writer->writeSheetHeader() 不会显示标题行。此外,我无法将图像插入工作表。如果有任何示例代码,那将非常有帮助。提前致谢!
【问题讨论】:
标签: php excel phpxlsxwriter
我想实现这样的报表标题。如果我使用$writer->writeSheetRow() 添加报告标题和副标题,那么$writer->writeSheetHeader() 不会显示标题行。此外,我无法将图像插入工作表。如果有任何示例代码,那将非常有帮助。提前致谢!
【问题讨论】:
标签: php excel phpxlsxwriter
在生成 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());
【讨论】: