Solved

Using cfheader and cfcontent to create an open office spreadhseet file

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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

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…
PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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