How to insert / paste images into dynamically generated MS Excel file using PHP?

I need to export a report to an Excel file using PHP ie on the fly. I am actually getting data from MySQL and presenting it in HTML tables.

I can export all of this data to Excel file format except images. I am unable to point the source of the image to an absolute url because that file should work standalone as well.

Is there any way to insert / paste images into this Excel file without using any library, that is, just PHP code or a library that doesn't require PEAR / PECL extensions. I am using a LAMP stack, so COM is not an option.

+1


source to share


1 answer


I'm not sure if you're thinking about not using PEAR, but there is a modified version ( PHP Excel Creator Library ) of PEAR Excel Writer Spreadsheet that doesn't have any dependencies on the rest of the PEARs.

I know that the original PEAR version has a Worksheet :: insertBitmap () method . You will need to convert your images to bitmaps if you haven't already (perhaps using GD in PHP)



If you are on Windows and have decent access to the server, you can also try using COM to talk to Excel and generate the file that way.

+1


source







All Articles