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 ');