作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我在核心 PHP 工作。我需要以粗体格式制作标题文本并保持正常文本格式。.xls 文件将从 PHP 导出。
我没有在我的项目中使用任何插件。我需要在不使用任何插件的情况下完成这个。但我无法解决这个问题。
我的代码如下,
//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";
导出文件工作正常。但我无法使标题为粗体。
如有任何帮助,我们将不胜感激。
最佳答案
一个可能的选择是让您的 PHP 代码生成一个 HTML 表格模型,其中包括您在特定单元格上的格式设置。然后让 PHP 将文件保存为 XLS 文档,Excel 应该能够打开应用格式的文件。
这可能不是最优雅的解决方案,但它 looks like has been done before .
关于php - 如何在 PHP 导出的 .xls 文件中制作粗体文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13689810/
我是一名优秀的程序员,十分优秀!