Solved

Using cfheader and cfcontent to create an open office spreadhseet file

Posted on 2010-11-24
5
1,048 Views
Last Modified: 2012-05-10
Hi,
I am using cfheader and cfcontent to send page output to an excel spreadsheet but need to now send to an open office spreadsheet but when trying to open an excel file creating using CF open office defaults to open in writer.
Has anyone got a quick fix for this?

Regards
Leigh
0
Comment
Question by:Lmillard
  • 2
  • 2
5 Comments
 
LVL 8

Expert Comment

by:pdd1lan
Comment Utility
Lmillard, try it below.

<cfquery name="hello">
      select var1, var2 from helloworld
</cfquery>

<cfsetting enablecfoutputonly="Yes">
<cfsavecontent variable="sFileContent">
<table>
     <tr><td>myVar1</td></tr>
    <cfoutput query="hello">
 
      <tr><td>#var1#</td></tr>

    </cfoutput>
  </table>

<CFHEADER NAME="Content-Disposition" VALUE="attachment;filename=myExcelfile.xls">
<cfcontent type="application/vnd.ms-excel"><cfoutput>#sFileContent#</cfoutput>
0
 

Author Comment

by:Lmillard
Comment Utility
I have amended the header to as you showed but I still have to resave the file as excel before being able to open in open office calc. It still defaults to writer for some reason.
0
 
LVL 8

Accepted Solution

by:
pdd1lan earned 500 total points
Comment Utility
when you generate excel page, it generates in CF web server, so the file saves in the temp of CF web server by default.  I don't think you can save directly to your locally drive in your PC, manually save the excel into your PC might be a case.
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
If it's not a true spreadsheet then you're usually at the mercy of client settings. From what little I know,  open office determines what happens when it encounters an html file disguised as an Excel spreadsheet.  I found a few threads that say some versions of OO will open it, and others won't

http://www.oooforum.org/forum/viewtopic.phtml?t=25275
http://www.oooforum.org/forum/viewtopic.phtml?t=106953
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
>> then you're usually at the mercy of client settings

Well... truthfully you're always at the mercy of client settings. But true excel files have a better chance of being interpreted correctly than faux-excel files (ie html)
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now