Excel Problem...

114 views
Skip to first unread message

hofar...@houseoffusion.com

unread,
Aug 20, 2014, 5:15:35 PM8/20/14
to ColdFusion Technical Talk

I've got an application running on CF8 that's been successfully
generating Excel reports for a good amount of time.
Recently, the user upgraded Office (using 2013 now) - and now it no
longer functions for them.

Pretty simple stuff:

<cfsetting enablecfoutputonly="Yes">
<cfheader name="Content-Disposition" value="inline; filename=report.xls">
<cfcontent type="application/vnd.ms-excel"><cfoutput>
<!--- table of crap goes here --->

... with cftry and things where needed to catch errors...

I don't use Excel on my machine, but the file opens perfectly for me in
Open Office Calc - just as it has been for years.
For the user though - file is pushed to them as normal, Excel opens -
and THEN you get a generic error (Something like "Sorry, there's been an
error") - which doesn't tell you anything...

Kinda at a loss. What am I missing? Is there some security setting
inside Excel that's changed from one version to the next that needs
tweaking, or what?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359171

hofar...@houseoffusion.com

unread,
Aug 24, 2014, 12:17:12 PM8/24/14
to ColdFusion Technical Talk

So what is the specific error? Is it in CF or Excel. If Excel are you getting this message?
""The file you are trying to open, '[filename]', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?" (Yes | No | Help)"

If so there's a new security "feature" in Excel According to this MSDN blog:
http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/03/11/excel-2007-extension-warning.aspx
"The alert is a new security feature in Excel 2007 called Extension Hardening, which ensures that the file content being opened matches the extension type specified in the shell command that is attempting to open the file. Because the MIME types listed above are associated with the .XLS extension, the file must be in XLS (BIFF8) file format to open without this warning prompt. "

The solution is to use the newer spreadsheet functions and upgrade to a more recent version of CF or Railo. This might be a good idea anyhow since CF8 is being EOL'd by the end of the year.

These two sites offer some solutions if you cannot use the new Spreadsheet functions in CF, however the solutions are not all that pretty.

http://devblog.grinn.net/2008/06/file-you-are-trying-to-open-is-in.html
http://stackoverflow.com/questions/940045/how-to-suppress-the-file-corrupt-warning-at-excel-download

hth,
larry
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359181

hofar...@houseoffusion.com

unread,
Aug 24, 2014, 7:56:16 PM8/24/14
to ColdFusion Technical Talk

> So what is the specific error? Is it in CF or Excel. If Excel are you getting this message?

Excel actually opens. So, it's an Excel error. However, it just says
"There's an error" with no further information. I *wish* it was the
error below, because then I'd have something to go on.

> ""The file you are trying to open, '[filename]', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?" (Yes | No | Help)"

At this moment in time, upgrading the site in question to a new server
isn't an option. I'll review the other options suggested though.

Thanks!
> If so there's a new security "feature" in Excel According to this MSDN blog:
> http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/03/11/excel-2007-extension-warning.aspx
> http://devblog.grinn.net/2008/06/file-you-are-trying-to-open-is-in.html
> http://stackoverflow.com/questions/940045/how-to-suppress-the-file-corrupt-warning-at-excel-download
>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359186

hofar...@houseoffusion.com

unread,
Aug 24, 2014, 8:12:43 PM8/24/14
to ColdFusion Technical Talk

Have you tried naming the spreadsheet with an xlsx extension.

<cfheader name="content-disposition"
value="attachment;filename=spreadsheet.xlsx">
<cfcontent type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359187

hofar...@houseoffusion.com

unread,
Aug 27, 2014, 3:11:50 PM8/27/14
to ColdFusion Technical Talk

You might also try saving the output as CSV and opening it in excel that way. Its an annoying workaround but may work.

AS for CF8, ask about Railo then - its FOSS, and is faster than ACF.
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359211

hofar...@houseoffusion.com

unread,
Aug 28, 2014, 11:58:08 AM8/28/14
to ColdFusion Technical Talk

Have you tried Ben Nadel's "CreateXlsFromQuery"? It creates a true Excel file which should be able to be opened in 2013. We are still on 2010 so I have not been able to test it but it's worth a try.

The original code can be found at: http://www.bennadel.com/blog/469-creating-microsoft-excel-files-using-coldfusion-and-poi.htm.
Another using XML is located at: http://www.bennadel.com/blog/917-creating-excel-files-with-coldfusion-xml-and-poi.htm.

Dave

-----Original Message-----
From: Larry Lyons [mailto:larry...@gmail.com]
Sent: Wednesday, August 27, 2014 3:12 PM
To: cf-talk
Subject: Re: Excel Problem...


You might also try saving the output as CSV and opening it in excel that way. Its an annoying workaround but may work.

AS for CF8, ask about Railo then - its FOSS, and is faster than ACF.

> > So what is the specific error? Is it in CF or Excel. If Excel are
> you getting this message?
>
> Excel actually opens. So, it's an Excel error. However, it just says
> "There's an error" with no further information. I *wish* it was the
> error below, because then I'd have something to go on.
>
> > ""The file you are trying to open, '[filename]', is in a different
> format than specified by the file extension. Verify that the file is
> not corrupted and is from a trusted source before opening the file. Do
> you want to open the file now?" (Yes | No | Help)"
>
> At this moment in time, upgrading the site in question to a new server
>
> isn't an option. I'll review the other options suggested though.
>
> Thanks!
> > If so there's a new security "feature" in Excel According to this
> MSDN blog:
> > http://blogs.msdn.
c> om/b/vsofficedeveloper/archive/2008/03/11/excel-2007-extension-warning.
> aspx
> > http://devblog.grinn.net/2008/06/file-you-are-trying-to-open-is-in.
> html
> > http://stackoverflow.
com/questi> ons/940045/how-to-suppress-the-file-corrupt-warning-at-excel-download
> >



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359215
Reply all
Reply to author
Forward
0 new messages