Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using cfheader and cfcontent to create an open office spreadhseet file

Posted on 2010-11-24
5
Medium Priority
?
1,083 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

CHALLENGE LAB: Troubleshooting Connectivity Issues

Goal: Fix the connectivity issue in the lab's AWS environment so that you can SSH into the provided EC2 instance.  

Question has a verified solution.

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

Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
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 …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

722 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