开发者

PHP: How to embed image in an excel column generated from PHP?

开发者 https://www.devze.com 2022-12-08 20:51 出处:网络
I am echoing TSV data and turning it into an excel file via header() This works fine, but 1 of the column开发者_如何学JAVAs needs to be an image. How can I embed the image as one of the columns?

I am echoing TSV data and turning it into an excel file via header()

This works fine, but 1 of the column开发者_如何学JAVAs needs to be an image. How can I embed the image as one of the columns?

Thanks!


Well, put simply, you can't. A TSV is a plain text (text/plain) file, not an 'Excel file'. An excel file is a binary representation of a spreadsheet, and although Excel can read a TSV and present it as tabular data, it's not this advanced binary form which can contain images.

You would have to create a 'proper' Excel xls file using one of the available libraries. I've used PHPExcel in the past and I think it supports adding images.


I don't believe there is anyway to use TSV data, and get Excel to display an image.

However, I have had success in using Spreadsheet_Excel_Writer from PEAR, and it supports inserting images (bitmaps). Also supports nice formatting, etc, etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消