How to solve the problem of line breaks in cells when PHP generates excel_PHP tutorial

WBOY
Release: 2016-07-21 15:34:09
Original
858 people have browsed it

Open the source code and open it. The method of using line breaks in the string is "Name:{$name}nAddress:{$adress}nCity:{$city}nCountry:{$country}n..."
Since "n" cannot achieve the purpose of line break, change it to "rn" and see.
Modify=》Submit=》Test
The result is still no line break! ! ! !
Is it an operating system compatibility issue? ?
Directly use the php runtime constant PHP_EOL instead of "rn"
Modify => Submit => Test
The result is still no line break! ! ! !
What’s going on? There's no way this won't solve OS compatibility issues with newlines.
Look at how this xls file is generated using php.
Looking at the code to generate excel, Oh My Lady gaga, it turns out to be in html format, but the file suffix is ​​written as xls. Since it is in html format, it should be able to produce line breaks.
Continue
Modify => Submit => Test
The result is that the line can be changed. What a joy. The problem is finally solved.
I was very happy when I told the boss that the problem was solved.

After a quarter of an hour, the boss ran over and said: "The problem with the line break effect has been solved, but look, the data is difficult to copy."
. . . .
Omit communication N sentences.
Copy the data in a cell and paste it into word. Oh My Lady gaga, why is there a border? ? ? ?
What exactly is the problem? ? Using n and rn will not cause line breaks, and using
will have the effect, but new problems will arise. . . What to do?
No choice, use BAIDU google.
Finally, Huang Tian paid off and found the answer to the question.
Append CSS stylebr {mso-data-placement:same-cell;} in the