Copy link to clipboard
Copied
Hopefully this just a quick oversight...
I've basically got a page set up that pulls data from a sql db and displays the data into a two column table.
At the top of the page I have
<cfcontent type="application/vnd.ms-excel">
<cfheader name="Content-Disposition" value="filename=file.xls">
Now the routine works pefectly on my end. I'm prompted to save the excel file or open it. Upon either path, when I open the excel file it displays on my side just fine.
However, upon passing the file to other team members they are receiving one or two errors.
Error #1: The file you are trying to open, 'file.xls', 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?
Error #2: Missing File: ...<path>\file\sheet001.htm
I had one person run a repair in excel and the output was that Excel indicated that it was a web page.
Alternatively I could do the xml to excel code but I'd like to keep things quick and simple. I'm sure I'm just missing something simple like an attribute but searching on these errors doesn't appear to bring up any relative results.
Ideas?
Copy link to clipboard
Copied
I highly doubt you are sucessfully creating a binary excel file type out of ColdFusion's text generating capabilities.
I suspect you are creating a text comma delimited, aka CSV, text file. Which just happens to also be automatically opened by MsExcel on most peoples machine, if they have that program installed.
Thus your mine type should be text/csv, not applicaiton/vnd.ms-excell as the latter is a binary format propitary to Microsoft.
Secondly you probably want your header to read something like this:
<cfheader name="Content-Disposition" value="attachment;filename=file.csv">
HTH
Ian
Copy link to clipboard
Copied
There is a solution. Download Ben Nadel's POI Utility cfcs to your server and use the Excel one to create your excel output. It's not perfect, but it's a lot better than simply using cfcontent.
This link gets you started. http://www.bennadel.com/blog/865-POIUtility-cfc-Examples-For-Reading-And-Writing-Excel-Files-In-Cold...
Copy link to clipboard
Copied
Might be related....
We had an issue with a vb6 program that was unable to open an excel template. It would work fine when run locally but if we executed from ColdFusion through the website it just would hang on the open of the excel template. The environment is Office 2007, Coldfusion 9 (64) and Windows 2008 (64). The architecture has change from Windows 2003 to Windows 2008.
We resolved the problem by adding the following folder with write priv for the account accessing it.
Windows 2008 x64 needs the following folder added.
C:\Windows\SysWOW64\config\systemprofile\Desktop
Windows 2008 x86 needs the following folder added.
C:\Windows\System32\config\systemprofile\Desktop
The Desktop folder seems to be necessary in the systemprofile folder to open files by Excel.
Windows 2003 had the folder.
I got the fix from the following link.