donglin8467
2017-05-18 12:45
浏览 624
已采纳

使用php xlsx writer在字符串中创建excel换行符

I'm using php xlsx writer (https://github.com/mk-j/PHP_XLSXWriter) to create my excel file and try to figure out how to force excel to make a line break.

My source data contains html tags (<br />) and i want to replace them with the correct formular. The replace function is working but i need how the string needs to be formated to force the break.

The line wrap option at format cells is enabled for the column as shown in the picture below (excel is installed german at the moment - please don't hate me for that)

enter image description here

What i tried so far is using CHAR(10) and CHAR(13) - altough CHAR(13) should be for mac and i am on windows.

I tried the following inputs to get my line break working. Also i tried all of the combinations with and instead of CHAR(10) and CHAR(13)

="text"&CHAR(10)&"text"
='text'&CHAR(10)&'text'
=text&CHAR(10)&text

The data was entered in the formular row in excel (picture below) - i think this is the only possible location to enter this isn't it?

enter image description here

Whatever i try my output always looks like this:

enter image description here

Any suggestions what i could do?
Thanks for your help!

图片转代码服务由CSDN问答提供 功能建议

我正在使用php xlsx writer( https://github.com/mk-j/PHP_XLSXWriter )创建我的excel文件并尝试弄清楚如何强制excel进行换行。

我的源数据包含html标签(&lt; br /&gt; ),我想用正确的公式替换它们。 替换函数正在工作,但我需要如何格式化字符串以强制中断。

格式单元格的换行选项已为列启用,如下图所示( excel目前已安装德语 - 请不要因此而讨厌我。

我到目前为止尝试的是使用 CHAR(10) CHAR(13) - altough CHAR(13)应该用于mac和i 我在Windows上。

我尝试了以下输入以使我的换行工作正常。 我还尝试了所有与 的组合,而不是 CHAR(10) CHAR(13)

 <代码> = “文本” &安培; CHAR(10)及 “文本” \ N = '文本' 和; CHAR(10)及 '文本'  
 =文本&amp; CHAR(10)&amp; text 
   
 
 

数据输入excel中的公式行(下图) - 我认为这是唯一的 可能的位置进入这个不是​​吗?

< img src =“https://i.stack.imgur.com/H9Dol.png”alt =“在此处输入图像说明”>

无论我尝试输出总是 看起来像这样:

我可以做什么建议?
谢谢你的帮助!

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dsk88199 2017-05-23 07:18
    已采纳

    The question got answered in https://github.com/mk-j/PHP_XLSXWriter/issues/114. There was a release of a new brunch supporting new line character which fixed the problem.

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题