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

使用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!

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

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

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

p>

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

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

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

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

p>

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

p>

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

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.