• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Export text and image of a table into xls


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):

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

<table border="1">
         <?php foreach ($emp as $row) { ?>
         <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>
        <?php } ?>

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

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:

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

Users browsing this thread:
1 Guest(s)

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.