How do I get csv file to download on IE? Works on firefox

后端 未结 12 535
梦如初夏
梦如初夏 2020-12-02 10:10

I\'m struggling with an odd error. I have a simple web app that grabs stuff from a DB then outputs it as a downloadable csv file. It works on firefox and chrome, but IE fail

12条回答
  •  天涯浪人
    2020-12-02 10:31

    If you are trying to accomplish this task (getting a CSV file to download in IE8) using Salesforce.com (in which case your front-end is Visualforce and you can't set all of the headers, only some of them), here's what you need:

    
         
    
    

    The key pieces here are cache=true, which, in conjunction with the default expires=0 attribute, achieves the following headers:

    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: public");
    

    And then the contentType of application/octet-stream --- doing text/csv fails for IE8.

提交回复
热议问题