Home > Backend Development > PHP Tutorial > PHPExcel导出插入图片和居中问题

PHPExcel导出插入图片和居中问题

WBOY
Release: 2016-06-23 13:32:40
Original
2827 people have browsed it

首先到网上先下载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);

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template