views:

243

answers:

1

I am using following PHP code to generate 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
A: 

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.

Mark B