How to export multiple images in phpexcel-php Tutorial

Source: Internet
Author: User
Phpexcel exports multiple images. at the end of this post, nzr_dream edits phpexcel & nbsp; export Image & nbsp; at 2015-01-2917: 11: 16; I have read the materials on the internet & nbsp; they all export an image. I want to export an image in the first column of each line. how to implement this? below is an export method, export multiple images in phpexcel

This post was last edited by nzr_dream on 17:11:16

Export images in phpexcel
After reading the materials online, I export an image. I want to export an image in the first column of each line. how can I achieve this? below is an export method. how can I add it? When other data is exported, the image paths are saved to the $ data two-dimensional array. Note: the class library has been imported. Wait...

// Write to excel
Function 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. = "_00000000date0000.xlsx ";

// Create a new PHP Excel Object
$ ObjPHPExcel = new PHPExcel ();
$ ObjProps = $ objPHPExcel-> getProperties ();

// Set the header
$ Key = ord ("");
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) {// write row
$ Span = ord ("");
Foreach ($ rows as $ keyName => $ value) {// write a column
$ J = chr ($ span );
// I want to add the image code here but it is not successful. what should I do? please prompt

// $ ObjDrawing = new PHPExcel_Worksheet_Drawing ();
// $ ObjDrawing-> setName ('test ');
// $ ObjDrawing-> setDescription ('test ');
// $ ObjDrawing-> setPath ($ data ['imgurl']);
// $ ObjDrawing-> setHeight (36 );
// $ ObjDrawing-> setCoordinates (''); what should I write here ??
// $ ObjDrawing-> setWorksheet ($ objActSheet );


$ ObjActSheet-> setCellValue ($ j. $ column, $ value );
$ Span ++;
}
$ Column ++;
}
// Rename the table
$ ObjPHPExcel-> getActiveSheet ()-> setTitle ('records ');
$ FileName = iconv ("UTF-8", "gb2312", $ fileName );
$ ObjWriter = PHPExcel_IOFactory: createWriter ($ objPHPExcel, 'excel2007 ');
$ ObjWriter-> save ($ fileName); // Run in script mode and save it in the current directory
Exit;
}

------ Solution ----------------------
1. in the exported image code commented out by you, you use full-width quotation marks and 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.