Problem with automatically opening an Excel file without first downloading

23 views
Skip to first unread message

Marcel van Langen - Morloff

unread,
Aug 11, 2016, 6:47:44 AM8/11/16
to Railo
Hello,

I have a question, and I hope you can help! I have a piece of code that generates HTML content (a simple table) via cfsavecontent and then gives it to the user using cfcontent en cfheader. Unfortunately, when the user directly opens the offered file (using "Open with Microsoft Excel)", Excel won't show the file. But when the user downloads the file and then opens it (the same file!), Excel opens it without a problem! Hope you can shed some light on this. My code is this:

<cfsavecontent variable="variables.outputFileContent"><table id="formulier"><tr><td><b>Geslacht</b></td><td><b>Aanhef 1</b></td></tr></table></cfsavecontent>

Obviously, I've cut out a large part of the coding itself. I've used comments to strip out the spaces (but that didn't change it either)... The file is presented using the following code:

<cfcontent type="application/application/vnd.ms-excel;" reset="yes" />
<cfheader name="Content-Disposition" value="inline;filename=exportfile_name_unique.xls" />
<cfoutput>#variables.outputFileContent#</cfoutput><cfabort>

Perhaps you can help me, many thanks in advance!

Marcel

Peter Boughton

unread,
Aug 11, 2016, 6:18:45 PM8/11/16
to ra...@googlegroups.com
You're setting the Content-Type to "application/application/vnd.ms-excel;" which is invalid.

Marcel van Langen - Morloff

unread,
Aug 23, 2016, 9:00:44 AM8/23/16
to Railo
Thanks Peter, I fixed that. It didn't change functionality though. I also tried removing all whitespace from the resulting table, but that didn't change it either. It seems it had something to do with a specific browser setting. In these settings the user could determine whether he trusted files from unknown sources. Changing that fixed this problem.
Reply all
Reply to author
Forward
0 new messages