2012-12-03 56 views
6

我正在使用核心PHP。 我需要使粗體格式的標題文本保持正常文本格式。 .xls文件將從PHP導出。如何在PHP中使用粗體文本導出.xls文件

我沒有在我的項目中使用任何插件。我需要在不使用任何插件的情況下完成此操作。 但我無法解決這個問題。

我的代碼如下,

//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... 
} 

和導出代碼如下,

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"; 

導出文件工作的罰款。但我無法使標題大膽。

請任何幫助,不勝感激。

+5

看看使用[PHP的Excel](http://phpexcel.codeplex.com/)。它會讓你的生活更輕鬆。 – Kermit

+0

@njk請不要插入任何插件。 – VijayS91

+0

爲什麼你需要做這個沒有任何插件(你實際上是指額外的庫)? – Bojangles

回答