Home > Backend Development > PHP Tutorial > phpexcel 导出多张图片

phpexcel 导出多张图片

WBOY
Release: 2016-06-23 13:40:25
Original
1498 people have browsed it

phpexcel 导出图片
   我在网上看了资料  都是导出一张图片,我想导出每行第一列是一个图片,如何实现,下边是一个导出的方法,我应该怎么加入哪?其他的数据都导出来了,就图片出不来,图片的路径信息保存到了$data二维数组下  。注:类库已导入。坐等。。。

//写入excelfunction getExcel($fileName,$headArr,$data){    if(empty($data) || !is_array($data)){        die("data must be a array");    }    if(empty($fileName)){        exit;    }    $date = date("Y_m_d h:i:s",time());    $fileName .= "_{$date}.xlsx";     //创建新的PHPExcel对象    $objPHPExcel = new PHPExcel();    $objProps = $objPHPExcel->getProperties();         //设置表头    $key = ord("A");    foreach($headArr as $v){        $colum = chr($key);        $objPHPExcel->setActiveSheetIndex(0) ->setCellValue($colum.'1', $v);        $key += 1;    }    	//表数据    $column = 2;    $objActSheet = $objPHPExcel->getActiveSheet();    foreach($data as $key => $rows){ //行写入		$span = ord("A");        foreach($rows as $keyName=>$value){// 列写入            $j = chr($span);           //我想在此处加入图片的code但是不成功,应该怎么写,请提示下            // $objDrawing = new PHPExcel_Worksheet_Drawing();            // $objDrawing->setName(‘test’);            // $objDrawing->setDescription(‘test’);            // $objDrawing->setPath($data['imgurl']);            // $objDrawing->setHeight(36);            // $objDrawing->setCoordinates('');      这里应该怎么写??            // $objDrawing->setWorksheet($objActSheet);            $objActSheet->setCellValue($j.$column, $value);            $span++;        }        $column++;    }	//重命名表    $objPHPExcel->getActiveSheet()->setTitle('记录');	$fileName = iconv("utf-8", "gb2312", $fileName);	$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');	$objWriter->save($fileName); //脚本方式运行,保存在当前目录	exit;}
Copy after login


回复讨论(解决方案)

1、被你注释掉的导出图片的代码中,你使用了全角的引号,应改为半角的
2、$objDrawing->setCoordinates('这里是单元格标识');

1、被你注释掉的导出图片的代码中,你使用了全角的引号,应改为半角的
2、$objDrawing->setCoordinates('这里是单元格标识');



1.全角是我发帖时贴过来的 = =
2.$objDrawing->setCoordinates('这里是单元格标识'); 这个标示在那个循环里应该怎么赋值,我想放在第一列里。
Related labels:
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