Phpexcel Exporting multiple pictures
This post was last edited by Nzr_dream on 2015-01-29 17:11:16
Phpexcel Exporting pictures
I read the information on the Internet is to export a picture, I want to export the first column of each row is a picture, how to implement, below is an export method, how should I join? The other data are exported, and the picture does not come out, the path information of the picture is saved to the $data two-dimensional array. Note: The class library has been imported. Wait...
Writing to Excel
function Getexcel ($fileName, $HEADARR, $data) {
if (Empty ($data) | |!is_array ($DATA)) {
Die ("Data must is a array");
}
if (empty ($fileName)) {
Exit
}
$date = Date ("Y_m_d h:i:s", Time ());
$fileName. = "_{$date}.xlsx";
Create a new Phpexcel object
$objPHPExcel = new Phpexcel ();
$objProps = $objPHPExcel->getproperties ();
Set up the table header
$key = Ord ("A");
foreach ($headArr as $v) {
$colum = Chr ($key);
$objPHPExcel->setactivesheetindex (0)->setcellvalue ($colum. ' 1 ', $v);
$key + = 1;
}
Table Data
$column = 2;
$objActSheet = $objPHPExcel->getactivesheet ();
foreach ($data as $key = + $rows) {//Line write
$span = Ord ("A");
foreach ($rows as $keyName = + $value) {//Column write
$j = Chr ($span);
I want to add the image here code but not successful, how to write, please prompt
$objDrawing = new phpexcel_worksheet_drawing ();
$objDrawing->setname (' Test ');
$objDrawing->setdescription (' Test ');
$objDrawing->setpath ($data [' Imgurl ']);
$objDrawing->setheight (36);
$objDrawing->setcoordinates ("); What should be written here??
$objDrawing->setworksheet ($objActSheet);
$objActSheet->setcellvalue ($j. $column, $value);
$span + +;
}
$column + +;
}
Renaming a table
$objPHPExcel->getactivesheet ()->settitle (' record ');
$fileName = Iconv ("Utf-8", "gb2312", $fileName);
$objWriter = Phpexcel_iofactory::createwriter ($objPHPExcel, ' Excel2007 ');
$objWriter->save ($fileName); Script run, save in current directory
Exit
}
------to solve the idea----------------------
1, you commented out of the exported image of the code, you use full-width quotation marks, should be changed to half-width
2, $objDrawing->setcoordinates (' Here is the cell id ');