Start Export
Header ("Content-type:application/vnd.ms-excel");
Header ("Content-disposition:attachment;filename=xueyuan_list_data.xls");
Echo mb_convert_encoding (' remarks ', ' GBK ', ' UTF-8 '). " \ t ";
$xuhao = 1;
foreach ($arr _xueyuan_list as $arr)
{
echo "\ n";
Echo $xuhao. "\ t";
Echo mb_convert_encoding ($arr [' Beizhu '], ' GBK ', ' UTF-8 '). " \ t ";
$xuhao = $xuhao + 1;
}
Since the data Beizhu at the time of submission is textarea, so beizhu this field will contain a newline character, when exported, once the content has a newline, then the second line will be displayed to the Excel table in another row, But what I want is beizhu. All the content in this field is only displayed in the "Remarks" box in the Excel table, what should I do?
Reply to discussion (solution)
$beizhu = mb_convert_encoding ($arr [' Beizhu '], ' GBK ', ' UTF-8 '); $beizhu = ' ". Preg_replace ("/[\r\n]+/", "\ n", $beizhu). "'"; Echo $beizhu. " \ t ";
The return line break will be replaced with newline characters (Linux documents are not required, but considering that the document may come from Windows or MAC, doing it is no harm)
Then wrap it up in a standard CSV format (fields are enclosed in double quotes)
Tested without replacing the carriage return line
Just wrap the output string in double quotes.
Yes, thank you.