• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFCONTENT

New Here ,
Jul 28, 2016 Jul 28, 2016

Copy link to clipboard

Copied

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">

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 28, 2016 Jul 28, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 29, 2016 Jul 29, 2016

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 29, 2016 Jul 29, 2016

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 29, 2016 Jul 29, 2016

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 30, 2016 Jul 30, 2016

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 29, 2016 Jul 29, 2016

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 30, 2016 Jul 30, 2016

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 30, 2016 Jul 30, 2016

Copy link to clipboard

Copied

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">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 30, 2016 Jul 30, 2016

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 03, 2016 Aug 03, 2016

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 03, 2016 Aug 03, 2016

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation