php - 在通过 html 生成的 excel 单元格中添加新行

标签 php html excel newline

我正在尝试在 php 中使用 html 生成一个 excel 文件,并使用 excel 内容类型进行响应。除了单元格中的新行外,一切正常。它们没有保存下来。 我试过 ; ;\r\n ,chr(13).chr(10) 它没有用。 我正在尝试通过 Microsoft Excel 的 alt + enter 获得相同的结果。

我在单元格中生成如下内容:

 http:\\www.example.com\blah
 (Link)
 http:\\www.example.com\blah2
 (Event) ...

这些必须在一个单元格中,并且将链接文本转换为超链接会很棒 :)。

最佳答案

我在这里找到了解决方案:http://www.bennadel.com/blog/1095-maintaining-line-breaks-in-an-html-excel-file.htm

The solution I found is to add into a stylesheet:

br {mso-data-placement:same-cell;}

关于php - 在通过 html 生成的 excel 单元格中添加新行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4025754/

相关文章:

javascript - 如何将 iFrame 的部分 URL 更改为随机字符串?

html - 来自 javascript 时的 css 样式问题

excel - 运行时错误 : 13 showing while looking through #N/A string

excel - 检测 Word VBA 中包含 '-' 的单词

javascript - 在 json_to_sheet 之后使用 XLSX js 对列进行排序和过滤

php - Chrome自定义标签-安卓-用户代理

php - 服务器无缘无故地杀死了我的 CakePHP 控制台应用程序

php - 如果某个字符串在 PHP 中匹配,则在回显某些文本时使函数发生

php - 我是 OOP/PHP 的新手。类中可见性和可扩展性的实用性是什么?

html - 我怎样才能水平对齐链接