Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using cfheader and cfcontent to create an open office spreadhseet file

Posted on 2010-11-24
5
Medium Priority
?
1,092 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
ID: 34204191
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
ID: 34204513
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 2000 total points
ID: 34204658
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_
ID: 34207656
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_
ID: 34209545
>> 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

916 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