Opening excel files from the internet opens a blank excel window

后端 未结 7 932
一生所求
一生所求 2021-01-12 08:42

A method in dumping a GridView to an Excel file to download/open from the internet was recently broken with new Windows Updates.

My code dumps from a GridView to an

相关标签:
7条回答
  • 2021-01-12 09:27

    Solution 3

    • Go into the properties of the file (R click - properties)
    • Click 'Unblock'
    • Click 'Apply'
    0 讨论(0)
  • 2021-01-12 09:32

    Try doing following:

    Replace "attachment" from

    Response.AddHeader("content-disposition","attachment;filename=GridViewExport.xls")
    

    with "inline"

    Response.AddHeader("content-disposition","inline;filename=GridViewExport.xls")
    

    It may help!

    Content-Disposition:What are the differences between "inline" and "attachment"?

    0 讨论(0)
  • 2021-01-12 09:39

    Just thought I'd mention there is a third solution:

    Add the site generating the .xls to your Trusted Sites list. I had to add about a dozen websites via GPO, because our CIO is refusing to roll back the KB... =(

    0 讨论(0)
  • 2021-01-12 09:42

    Having same issue. An update blocked this exporting to excel activity and not all of my world wide users have permissions to unblock. It affects 2010 and 2013 .xls. My thought it to address the Content type. Have you tried switching your Content Type from application/vnd.ms-excel to application/vnd.openxmlformats-officedocument.spreadsheetml.sheet and using xlsx instead?

    0 讨论(0)
  • 2021-01-12 09:44

    Solution 1

    1) Open Excel Go to File Options

    2) Click Trust Center -> Trust Center Settings

    3) Go to Protected View. there are 3 options that show that were all clicked. Uncheck the first option that reads -- "Enable Protected View for files originating from the Internet". In some cases as reported in the comments below both the 1st and 2nd options need to be unchecked (Thanks @mosheb)

    Solution 2

    Uninstall these Windows Updates:

    • Windows Update KB3115262 (Excel 2013)
    • Windows Update KB3115130 (Excel 2010)
    0 讨论(0)
  • 2021-01-12 09:44

    changing the security options was unfortunately not an option, but it turns out that if you export to CSV instead of XLS then the file will open in Excel ignoring the trust center stuff.

    We're in Classic ASP, so we change the page from exporting an HTML table format to CSV and changed our header and contenttype to this:

    Response.AddHeader "content-disposition", "attachment; filename=search_results.csv"
    Response.ContentType = "text/csv"
    

    and did line breaks with: Response.Write (chr(10))

    0 讨论(0)
提交回复
热议问题