Line break does not occur in CSV file generated by IE

I use the following PHP code to create a 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 created by IE when opened in MS Excel shows all the data in one line.

PS:

  • Files created by other browsers (FF, Google Chrome) behave perfectly.
  • I use "\ n" for line breaks.
  • Using "\ r \ n" does not help
+4
source share
2 answers

Have you tried using \r\n as your newline? I know that some versions of IE have some weird problems when it comes to carriage returns.

0
source

Add \ r \ n and it should be included with double quotes

 'Line 1' . "\r\n" . 'Line 2' 
0
source

All Articles