Welcome Guest, Not a member yet? Register   Sign In
Export text and image of a table into xls
#1

Hi,

These are my data:

ID     Name     Photo
1      Ada        (image in blob)
2      Billy        (image in blob)
3      Charles   (image in blob)

I have no problem display them in actual pages,but not able to export all of them into xls,only text (such as ID,Name)show inside the excel but not the photo,which appear as blank cell only.

Here my code(without controller and model of course):

Code:
<?php
header("Content-Disposition: inline; filename=empdata.xls");
header("Content-Type: application/octet-stream");
header("Expires: 0");
header("Pragma: no-cache");
?>

<table border="1">
  <tr>
         <th>ID</th>
         <th>NAME</th>
         <th>PHOTO</th>
   </tr>
         <?php foreach ($emp as $row) { ?>
   <tr>
         <td><?php echo $row->ID;?></td>
         <td><?php echo $row->Name;?></td>
         <td height="170"><img src="data:image/jpeg;base64,<?php echo  base64_encode($row->Photo);?>" width="140" height="170"></td>
   </tr>
        <?php } ?>
</table>

May I know what was I missing?Need to programmatically draw the image?
Reply
#2

If i were you i would probably use something like PhpSpreadsheet to generate my file.

See relevant documentation on how to add an image below:
https://phpspreadsheet.readthedocs.io/en...-worksheet
Reply




Theme © iAndrew 2016 - Forum software by © MyBB