CodeIgniter Forums

Full Version: Export text and image of a table into xls
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

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: