phpexcel 添加图片

$objPHPExcel = new PHPExcel();
$objPHPExcel->createSheet();
$objPHPExcel->setActiveSheetIndex(1);
$sheet = $objPHPExcel->getActiveSheet();
$sheet->mergeCells('A1:Z1');
// 注意 添加图片前要设置单元格高度否者图片不显示
$sheet->getRowDimension(1)->setRowHeight(300);
$objPHPExcel->getSheet(1)->setTitle('图片');
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('图片');
$objDrawing->setDescription('图片');
$objDrawing->setPath($pic_path);
$objDrawing->setHeight(300);
$objDrawing->setCoordinates('A1');
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());

你可能感兴趣的:(php)