Solved

Using cfheader and cfcontent to create an open office spreadhseet file

Posted on 2010-11-24
5
1,063 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 500 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

861 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