11 Replies Latest reply on Aug 3, 2016 10:19 AM by EddieLotter

    CFCONTENT

    cpham

      The code is no longer worked on some Chrome/IE browsers. It will open Excel but nothing loads.

       

      <cfheader name="Content-Disposition" value="inline; filename=Report.xls">

      <cfcontent type="application/vnd.msexcel">

        • 1. Re: CFCONTENT
          EddieLotter Level 3

          If "nothing loads" then you're probably not emitting anything that Excel can interpret.

           

          I use this type of scenario for certain reports and it works in Chrome, IE 11 and Chrome under Windows 10.

           

          To troubleshoot, comment out the two lines that you showed and then browse to the page. What do you see in your Web browser?

           

          Cheers

          Eddie

          • 2. Re: CFCONTENT
            coylo

            I am using Coldfusion 11 Standard and this exact same thing started happening about a week ago with me. MS Excel will open but nothing loads.  if i open the same .xls file with Open Office or even MS Word it will actually display the data.

            • 3. Re: CFCONTENT
              cpham Level 1

              I used the bottom example as a test. Remove the two lines and the table shows up on the page but not in MS Excel.

               

              <cfheader name="Content-Disposition" value="inline; filename=acmesalesQ1.xls">

              <cfcontent type="application/vnd.msexcel">

               

              <table border="2">

              <tr><td>Month</td><td>Quantity</td><td>$ Sales</td></tr>

              <tr><td>January</td><td>80</td><td >$245</td></tr>

              <tr><td>February</td><td>100</td><td>$699</td></tr>

              <tr><td>March</td><td>230</td><td >$2036</td></tr>

              <tr><td>Total</td><td>=Sum(B2..B4)</td><td>=Sum(C2..C4)</td></tr>

              </table>

              • 4. Re: CFCONTENT
                WolfShade Level 4

                Swap out your CFCONTENT with the following, and let me know if it works.

                <cfcontent type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">

                 

                HTH,

                 

                ^_^

                 

                UPDATE:  Upon further viewing of the thread, so far, I am curious.  I've never tried using a table to populate an Excel sheet.  I've always dropped to CFSCRIPT and used the SpreadsheetNew() function.  If you use SpreadsheetSetCellValue(), you get granular control over data and format, and can do some pretty spiffy stuff.

                • 5. Re: CFCONTENT
                  cpham Level 1

                  Unfortunately, it didn't work. This issue just started this week. It was working fin before.

                   

                  The reason why using a table is to populate is the user has two options to view report: Browser or Excel.

                  • 6. Re: CFCONTENT
                    BKBK Adobe Community Professional & MVP

                    cpham wrote:

                     

                    The code is no longer worked on some Chrome/IE browsers. It will open Excel but nothing loads.

                     

                    <cfheader name="Content-Disposition" value="inline; filename=Report.xls">

                    <cfcontent type="application/vnd.msexcel">

                    The correct MIME type for XLS files is application/vnd.ms-excel.

                    • 7. Re: CFCONTENT
                      BKBK Adobe Community Professional & MVP

                      WolfShade wrote:

                       

                      Swap out your CFCONTENT with the following, and let me know if it works.

                      1. <cfcontenttype="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">

                      That looks like the one for XLSX files.

                      • 8. Re: CFCONTENT
                        BKBK Adobe Community Professional & MVP

                        cpham wrote:

                         

                        Unfortunately, it didn't work. This issue just started this week. It was working fin before.

                         

                        I can imagine that the problem started only recently. The cause is likely to be Microsoft Office's security update of July 12, 2016.

                         

                        One workaround to enable you to view the contents of the Excel file is as follows:

                         

                        Go to

                         

                        Excel Options => Trust Center => Trust Center Settings => Protected View

                         

                        => Uncheck the checkbox "Enable Protected View for files originating from the Internet".

                         

                        Warning:

                        Use the suggestion I have given here at your own risk. Microsoft put the security settings in place for a reason.

                        This workaround is only a temporary solution, to be used for connections you trust. Return the settings to their most secure level afterwards.

                        • 9. Re: CFCONTENT
                          BKBK Adobe Community Professional & MVP

                          Alternative solution

                           

                          <cfscript>

                          //Create a new Spreadsheet object

                          mySheet = SpreadsheetNew();

                           

                          //Insert row data to sheet, with each row starting at column 1.

                          SpreadsheetAddRow(mySheet,"Month,Quantity,$ Sales",1,1);

                          SpreadsheetAddRow(mySheet,"January,80,$245",2,1);

                          SpreadsheetAddRow(mySheet,"February,100,$699",3,1);

                          SpreadsheetAddRow(mySheet,"March,230,$2036",4,1);

                          SpreadsheetAddRow(mySheet,"Total,=Sum(B2..B4),=Sum(C2..C4)",5,1);

                          </cfscript>

                           

                          <!--- Write the spreadsheet to a file, replacing any existing file. --->

                          <cfspreadsheet action="write" filename="#expandpath('acmeFile.xls')#" overwrite="yes" name="mySheet">

                          <cfheader name="Content-Disposition" value="inline; filename=acmeFile.xls">

                          <cfcontent type="application/vnd.ms-excel" file="#expandpath('acmeFile.xls')#" deletefile="yes">

                          • 10. Re: CFCONTENT
                            cpham Level 1

                            I’ve changed the settings for Excel. And it loads.

                             

                            Trust Center> Trust Center Settings > Protected View. Unchecked -  Enable Protected View for files originating from the Internet.

                            • 11. Re: CFCONTENT
                              EddieLotter Level 3

                              That is what BKBK said in a previous post, but it's worth heeding his bolded warning. It's also worth noting that if this is not an internal app then you have no control over your external users' computer settings.

                               

                              Cheers

                              Edde