PHP generates an Excel file and controls the linefeed in the Excel cell. Mantis has a function to export the bug to Excel. However, in the current Mantis version, when exporting the excel file, "Abstract, description, problem reproduction step description: PHP generates an Excel file to control the line break in an Excel cell
The company uses Mantis to manage bugs. Mantis has a function to export bugs to Excel,
However, in the current mantis version, when exporting an excel file, "Abstract, description, problem reproduction step description, additional information, comment", and so on,
When submitting a bug, the carriage return and line breaks were lost. because there was no format, it was inconvenient to read in excel,
?
This is the problem,
When using php to make an excel file, how can I write a line break in an excel cell to control the format of the cell.
?
I tried it. \ r \ n is invalid when generating an excel file and will be filtered and tuned.
However
The effect is not a line break in the cell, but a new cell.
Google, to achieve the goal of wrapping in cells, you need to insert the following string
?
'
'
?
?
In addition, I found another interesting problem during my investigation.
As mentioned above, when using php to generate an excel file, \ r \ n does not have any line breaks. to control line breaks, you need to use html tags.
However, if \ r \ n is mixed in
Middle,
As shown below, \ r \ n at this time is equivalent to
To create a new cell in the excel file.
Write
..........\r\n
..........\r\n
..........\r\n
?
This behavior is clearly not what we want,
So we should replace them all like below.
$p_new_lines = array("\r\n", "\n", "\r","\r\n", "","
","
","
","
");$p_change_line_in_excel_cell = '
';$p_result = str_replace( $p_new_lines,$p_change_line_in_excel_cell,$p_input);
?
?
?
?