MIME-Type for Excel XML (ASP.NET 3.5)

前端 未结 3 493
终归单人心
终归单人心 2020-12-19 05:50

I use CarlosAG-Dll which creates a XML-Excel-file for me (inside a MemoryStream).

Response.ContentType = \"application/vnd.ms-excel\";
Response.AppendHeader(         


        
3条回答
  •  爱一瞬间的悲伤
    2020-12-19 06:21

    The security warning is NOT about the MIME type - it is a client-side security setting you can't disable from the server side !

    Another point - change Response.AppendHeader("content-disposition", "myfile.xml"); to:

    Response.AppendHeader("content-disposition", "attachment; filename=myfile.xlsx");
    

    OR

    Response.AppendHeader("content-disposition", "inline; filename=myfile.xlsx");
    

    For reference see http://www.ietf.org/rfc/rfc2183.txt

    EDIT - as per comment:

    IF the format is not XLSX (Excel 2007 and up) then use myfile.xls in the above code.

提交回复
热议问题