首先到网上先下载PHPExcel
下载后解压得到这两个文件
下载后引用该文件
最后编写相关代码:
首先是图片插入导出
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName(‘Photo‘);
$objDrawing->setDescription(‘Photo‘);
$objDrawing->setPath("./1.jpg");
$objDrawing->setHeight(375);
$objDrawing->setWidth(270);
$objDrawing->setCoordinates(‘L2‘);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
//打印图片
其次是居中
$objPHPExcel->getActiveSheet()->getStyle(‘A1:K55‘)//改行表示A1-K55的单元格都居中
->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
时间: 2024-10-24 02:05:42