Response.ContentType application/vnd.ms-excel xls stopped working

Chris Boozer picture Chris Boozer · Jul 19, 2016 · Viewed 28.7k times · Source

I've done some pretty deep searching on this issue with no luck. It seems that in the past couple of days the output to XLS from HTML has stopped working on many legacy (read: Classic ASP) systems I support. I've been able reproduce this on multiple servers, multiple independent source code from Office 2010 through Office 2016. I've looked at everything I can think of without success so I'm curious to know if there is something I might be overlooking. I'm starting to think this may be a bad Office update that is the culprit.

Sample of what works and has been working for many years:

<%

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment;filename=TestExcel.xls"

%>

<html>
    <body>
        <table>
            <thead>
                <tr>
                    <th>column 1 header</th>
                    <th>column 2 header</th>
                </tr>
            </thead>

            <tbody>
                <tr>
                    <td>column 1 value</td>
                    <td>column 2 value</td>
                </tr>
            </tbody>

            <tfoot>
                <tr>
                    <td>Footer 1</td>
                    <td>Footer 2</td>

                </tr>

            </tfoot>
        </table>
    </body>
</html>

What is curious is that the XLS file is in fact created but when it is opened Excel opens but not file is present.

Even more curious is that when you open the XLS file with some text editor (notepad for example) and just File->Save As it opens without issue.

Answer

xelvis42 picture xelvis42 · Jul 19, 2016

The issue is related to Microsoft Security Update KB3115262 for Excel that was released July 12, 2016. The security update information can be found in Microsoft Security Bulletin MS16-088 - Critical.

I've found three workarounds (in my order of preference):

  • Instead of clicking Open, save the file and then open it
  • In Excel Trust Center > Trust Center Settings > Protected View, uncheck the top two options. This is potentially unsafe.
  • Uninstall the security update.

Below are several links regarding the issue for further perusal. https://social.technet.microsoft.com/Forums/en-US/d2d84793-9920-45e3-baef-5027a4ac1ae0/kb3170008-for-office-2016-breaks-functionality-ms16088?forum=officeitpro

https://technet.microsoft.com/library/security/MS16-088

https://salesforce.stackexchange.com/questions/131404/end-user-cannot-open-a-xls-report-exported-from-salesforce

Export HTML Table to Excel- Doesn't Open in Office 2010