Line break not happening in CSV file being generated by IE
I am using following PHP code to gene开发者_如何转开发rate CSV file:
header("Expires: 0");
header("Cache-control: private");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Description: File Transfer");
header("Content-Type: text/csv");
header("Content-disposition: attachment; filename=site_list.csv");
The CSV file is generated successfully in all browsers. But the file generated by IE, when opened with MS Excel, shows all the data in single line.
PS:
- Files generated by other browsers (FF, Google Chrome) are behaving perfectly.
- I am using "\n" for line breaks.
- Using "\r\n" does not help
Have you tried using \r\n
as your newline? I know some versions of IE have some weird issues when it comes to carriage returns.
Add \r\n and it should be included by double quotes
'Line 1' . "\r\n" . 'Line 2'
精彩评论