View Full Version : Format Excel file Generated from PHP Code

11-05-2009, 01:58 AM
I have been developing a simple php file which can generate a Calc file (Calc is like Excel for Linux). Although, we have many pre-built classes like Spreadsheet_Excel_Writer already available, I wish to develop my own. After all, we are here to learn right?

So, I have a simple tab delimited data outputted as calc file (or .xls file) like:

header("Content-Type: application/octet-stream");
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=report.xls");
header("Pragma: no-cache");
header("Expires: 0");

echo "Name\tAge\tGender\tAddress\n";
echo "Jack\t21\tMale\tWA\n";

The above works great! However I was trying some formatting where I am now stuck.

I tried :

echo "<b>Jack</b>\t"; //***...etc, i.e. using html tags for bold

...but the html tags arent parsed at all.

also I tried embedding picture file by :

echo "<img src='jack.jpg />";

...which failed too.

Could you turn me toward the right direction?