gpt4 book ai didi

php - 如何在 PHP 导出的 .xls 文件中制作粗体文本

转载 作者:可可西里 更新时间:2023-11-01 12:59:12 25 4
gpt4 key购买 nike

我在核心 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 .

I can see why many people suggest using a plugin.

关于php - 如何在 PHP 导出的 .xls 文件中制作粗体文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13689810/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com