Trouble inserting images (from blob mysql) in worksheet

Topics: User Forum
Dec 15, 2010 at 5:10 AM
Edited Dec 19, 2010 at 9:56 AM

hi, 

I need to produce an excel file with data from mysql 

There is name , id code, email and a picture which is store in a blob in mysql

problem is that i cannot use a setpath that change with every entry of the bd. so i get a file without image when i get a file. 

so in my script, when i use $lien to set info inside setpath($lien), nothing goes out, if i change it for  setpath('portrait.jpg') it's work but every time with the same image which isn't what  i need, image need to be different for each entry....  

here is the code :

//---- r�cup�ration des �tudiants ayant fait le choix de cette activit� ----// 
$sql2 = "SELECT * FROM participants WHERE code_act='$act' AND  code_semestre='S11011' ORDER BY participants.id ASC" ; 
$req2 = mysql_query($sql2) or die('Erreur SQL !<br>'.$sql2.'<br>'.mysql_error());
//---- Affichage des informations ----//
for($e = 0 ; $e < mysql_num_rows($req2) ; $e++) {
$row2 = mysql_fetch_assoc($req2);
$id = $row2['identifiant'];
$sql3 = "SELECT * FROM tmp_ETU_A_JOUR WHERE COD_ETU='$id' "; 
$req3 = mysql_query($sql3); 
$row3 = mysql_fetch_assoc($req3); 
$nom = utf8_encode($row3['LIB_NOM_PAT_IND']);
$prenom = utf8_encode($row3['LIB_PR1_IND']);
$mel = $row3['MAIL_UVSQ'];
$sexe = $row3['COD_SEX_ETU'];
$img = $row3['IMG_ETU'];
$image = imagecreatefromstring($img);
$temp = tmpfile(); 
$lien ='trombi/'.$id.'.jpg';
imagejpeg($image, $lien, '100');
$ligne = $e+1;
$B= 'B'.$ligne;
$C= 'C'.$ligne;
$D= 'D'.$ligne;
$E= 'E'.$ligne;
$F= 'F'.$ligne;
$G= 'G'.$ligne;
$objPHPExcel->getActiveSheet()->setCellValue($B,$id);
$objPHPExcel->getActiveSheet()->setCellValue($C,$nom);
$objPHPExcel->getActiveSheet()->setCellValue($D,$prenom);
$objPHPExcel->getActiveSheet()->setCellValue($E,$mel);
$objPHPExcel->getActiveSheet()->setCellValue($F,$sexe);
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('img');
$objDrawing->setDescription('img');
$objDrawing->setPath($lien);
$objDrawing->setHeight(36);
$objDrawing->setCoordinates($G);
$objDrawing->setOffsetX(-10);
$objDrawing->setWorksheet($sheet);
/*$objDrawing = new PHPExcel_Worksheet_MemoryDrawing();
$objDrawing->setName('test');
$objDrawing->setDescription('');
$objDrawing->setImageResource($lien);
$objDrawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG);
$objDrawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT);
$objDrawing->setHeight(36);
$objDrawing->setWorksheet($sheet);*/
//$ligne++;
imagedestroy($image);

}

hop you can help me 

thanks