7 Replies Latest reply on May 20, 2009 1:05 PM by idesdema

    Internet Explorer no longer opens tab-delimited files (in Excel)

    Grant Level 1

      I'm generating tab-delimited files that open as spreadsheets in Excel.  This works fine in Firefox but does not work in Internet Explorer.  It used to work fine in IE also before upgrading to Microsoft Office 2007.

       

      The error I'm getting is "Microsoft Office Excel cannot access the file..."

       

      Here are the critical lines in my ColdFusion page:

       

      <!--- tell browser it's an Excel file --->
      <CFCONTENT TYPE="application/vnd.ms-excel">

       

      <!--- tell Internet Explorer to open as Excel file --->
      <CFHEADER NAME="Content-Disposition" VALUE="filename=mycontent.xls">

       

      then I'm outputting the tab-delimited data.

       

      When I go to the URL, IE prompts me to open or save the file but I can't even save the file (it says "Internet Explorer cannot download myfile.cfm from myserver.com") so maybe the problem is with a new version/patch of IE (I have IE 7 on Windows XP).  Again, this works fine in Firefox but unfortunately, most of my users use IE so I have to get this working in IE.

       

      Any idea how to make this work with IE/MS Office 2007?

       

      Thanks.

        • 1. Re: Internet Explorer no longer opens tab-delimited files (in Excel)
          craigkaminsky Level 3

          Grant,

           

          I've used the following code skeleton to successfully download XLS files (CSV, TXT, too) on systems with IE7 and Office 2007 installed (from IE, that is):

           

          <!--- Tell the browser to expect an Excel file attachment. --->

          <cfheader name="content-disposition" value="attachment; filename=filename.xls" />

          <cfcontent type="application/excel" />

           

          Try changing your type to applicaion/excel in cfcontent and add attachment; to your value attribute in cfheader.

           

          Best,

          Craig

          • 2. Re: Internet Explorer no longer opens tab-delimited files (in Excel)
            Grant Level 1

            Thanks, but that didn't work.  If I put in "attachment;" and/or change the content type, I immediately get the "cannot access the file" error.  It doesn't even get to the point where it prompts to open or save the file.

            • 3. Re: Internet Explorer no longer opens tab-delimited files (in Excel)
              craigkaminsky Level 3

              Can you post a little of the code related to creating the tab-delimited content? Are you grabbing the file from the server or creating the content dynamically to send to the user? It may well be an IE security thing but there should certainly be a way 'around' it.

              • 4. Re: Internet Explorer no longer opens tab-delimited files (in Excel)
                Grant Level 1

                Below is how it is being done.  This worked perfectly for years. MS Office 2007 does complain that the file extension does not match the data format (it's a tab delimited text file but I'm pretending it's an Excel file so they'll be prompted to view it as a spreadsheet in Excel) but you just click open and it works fine.  This issue with IE is new.  Let me know if you have any more ideas.

                 

                 

                <CFSETTING ENABLECFOUTPUTONLY="Yes" SHOWDEBUGOUTPUT="No">

                <!--- variables used for separating cells with tabs, and for new rows --->
                <CFSET tabchar=chr(9)>
                <CFSET newline=chr(13) & chr(10)>

                 

                <!--- tell browser it's an Excel file --->
                <CFCONTENT TYPE="application/vnd.ms-excel">

                 

                <!--- tell Internet Explorer to open as Excel file --->
                <CFHEADER NAME="Content-Disposition" VALUE="filename=myfile.xls">

                 

                <!--- get data --->
                <CFQUERY NAME="getinfo" DATASOURCE="mydsn">
                    select fieldone, fieldtwo
                    from mytable
                </CFQUERY>

                 

                <!--- output column headings --->
                <CFOUTPUT><CFLOOP INDEX="q" LIST="fieldone,fieldtwo">#q##tabchar#</CFLOOP>#newline#</CFOUTPUT>

                 

                <!--- output database records --->
                <CFOUTPUT QUERY="getinfo">#getinfo.fieldone##tabchar##getinfo.fieldtwo##newline#</CFOUTPUT>

                • 5. Re: Internet Explorer no longer opens tab-delimited files (in Excel)
                  craigkaminsky Level 3

                  Grant,

                   

                  I ran a few tests in IE7 and IE8 this afternoon on both a Windows/IIS install and a Mac/Apache install. I was able to download the page from IE 7 and 8 without any errors. It would appear that there is a security setting of some sort (either installed with Office 2007

                   

                  Using the code you posted as a base, statically typing in data where you had the query, I changed the CFCONTENT tag from this

                  <cfcontent type="application/vnd.ms-excel">

                  <cfheader name="Content-Disposition" value="filename=myfile.xls">

                   

                  to

                  <cfcontent type="text/plain">

                  <cfheader name="Content-Disposition" value="attachment;filename=myfile.xls">

                   

                  For both browsers, I was also prompted to download the file (and it saved properly). Perhaps this might be worth a shot (altering the MIME Type away from an Office type) as a test.

                   

                  Did you also try, essentially, removing all security from IE?

                  • 6. Re: Internet Explorer no longer opens tab-delimited files (in Excel)
                    Dan Bracuk Level 5

                    Try moving your query up in your code so that it runs prior to cfheader/cfcontent.

                    • 7. Re: Internet Explorer no longer opens tab-delimited files (in Excel)
                      idesdema Level 1

                      Having the same problem.  I changed around the cfcontent type and when its just "excel" it returns all my data but on the browser screen.  When I change it to msexcel it then gives me a file not found error.