I am working in core PHP. I need to make header text in bold format and remains normal text format. The .xls file will be export from PHP.
I am not using any plug-in in my project. I need to complete this without using any plug-in. But i unable to solve this.
My code as follows,
//header part cration
while($r=mysql_fetch_array($exe))
{
//need to set bold. But it is not working. it giving error
//$header .= "<b>".$r['question']."</b>"."\t ";
$header .=.$r['question']."\t ";
}
//body part cration
while($r=mysql_fetch_array($exe))
{
$data .= $r['answer']."\t ";
//code continuous...
}
and Exporting code as follows,
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=reports.xls");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n\n$data";
Exporting file working fine. But i unable to make headers are bold.
Please any help much be appreciated.
One potential option would be to have your PHP code generate an HTML table model that includes your formatting on specific cells. Then have PHP save the file as an XLS document and Excel should be able to open that with the formatting applied.
It might not be the most elegant solution, but it looks like has been done before.
I can see why many people suggest using a plugin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With