Phpexcel export more than one picture, how to solve

Source: Internet
Author: User
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 ');
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.