Ok thanks for sharing, for now ill keep it (with some modifications
like you suggests to enable excel popup) as it is, or might try the
http://www.bennadel.com/projects/poi-utility.htm component as it seems
perfect to do a wide range of stuff with excel, the easy way :) So
also for future plugins a nice tool to have.

Thanks for your time!

On Nov 3, 8:48 pm, "Tomek Kott" <[EMAIL PROTECTED]> wrote:
> Hi Marco,
>
> Sure, let me clarify. In general I believe all you need is something like
> your example. I just wanted to point out that I did things a little bit
> differently, mostly so that if I needed to run some search/replaces in the
> output content I could do so with a variable. The following is code verbatim
> for what I use.
>
>     <cfset oFormtoolUtil = createObject("component",
> "farcry.core.packages.farcry.formtools") />
>     <cfset sqlColumns="objectid,formid,datetimecreated" />
>     <cfset stRecordset = oFormtoolUtil.getRecordset(sqlColumns=sqlColumns,
> sqlWhere="formID IN '#form.formSelect#'", typename="idlFormLog",
> bCheckVersions=true) />
>
>     <cfset bRunOnce="0">
>     <cfset TabChar = Chr(9)>
>     <cfset NewLine = Chr(13) & Chr(10)>
>     <cfset myHTML = createObject("java","java.lang.StringBuffer")>
>
>         <cfloop query="stRecordset.q">
>             <cfset myHTML.append("<tr>")>
>             <cfset oFormtoolLogUtil = createObject("component",
> "farcry.core.packages.farcry.formtools") />
>             <cfset sqlColumns="title,value" />
>             <cfset stLogRecordset =
> oFormtoolLogUtil.getRecordset(sqlColumns=sqlColumns, sqlWhere="formLogID IN
> '#objectID#'", typename="idlFormLogItem", bCheckVersions=true) />
>             <cfloop query="stLogRecordset.q">
>                 <cfset shortTitle = lcase(replace(title," ","","all")) />
>                 <cfif StructKeyExists(form,"#shorttitle#")>
>                     <cfif NOT bRunOnce><cfset lTitles=  lTitles & "<th>" &
> title & "</th>" ></cfif>
>                     <cfset myHTML.append("<td>" & value & "</td>")>
>                 </cfif>
>             </cfloop>
>             <cfif NOT bRunOnce>
>                 <cfset lTitles = "<tr>" & lTitles & "</tr>">
>                 <cfset bRunOnce="1">
>             </cfif>
>             <cfset myHTML.append("</tr>")>
>         </cfloop>
>     <cfsavecontent variable="totalHTML"><cfoutput><html><head><title>Excel
> Data Preview</title></head>
>         <body><table
> border=1>#lTitles##myHTML.toString()#</table></body></html></cfoutput></cfsavecontent>
>
>     <cfheader name="Content-Disposition" value="attachment;
> filename=FormData.xls" />
>     <cfcontent type="application/msexcel" variable="#ToBinary( ToBase64(
> totalHTML.Trim() ) )#" />
>     <cfexit />
>
> So there I am using <cfset ... > for a variable to save the content instead
> of <cfsavecontent ...>. I don't remember now if I ran into the same issue
> you are having with invalid variable type and that's why I switched to
> cfset. As you can see, I use a variable of
> createObject("java","java.lang.StringBuffer"). As I read from a blog post,
> it is better at allocating memory for an expanding string than multiple
> <cfset myHTML = myHTML & "bla">. That said, I don't know if there any
> downsides etc.
>
> The method you have I don't see why it wouldn't work, but I had problems for
> whatever reason with different browsers I think, which is why I switched to
> the above method.
>
> Best,
>
> Tomek
>
> On Mon, Nov 3, 2008 at 1:51 PM, Marco van den Oever <
>
> [EMAIL PROTECTED]> wrote:
>
> > I can't set the table etc between a <cfsavecontent
> > variable="pollingstats">, as it states that it's not a valid supported
> > variable type.
> > How would you set that table and looping from my example to a
> > variable? Put it in a structure or something?
>
> > You give me different ways of doing it, bit confused about what
> > belongs to what or what need to be in place together or not, can you
> > clarify?
>
> > Thanks
>
> > On Nov 3, 3:23 pm, "Tomek Kott" <[EMAIL PROTECTED]> wrote:
> > > Marco,
>
> > > Basically all you need is a table structure like your example. I actually
> > > found that your method wouldn't automatically pop up a "save as Excel"
> > > dialog box in all browsers. What I ended up doing was simply did a save
> > > content to a variable (<cfset ...>) and
>
> > >     <cfheader name="Content-Disposition" value="attachment;
> > > filename=FormData.xls" />
> > >     <cfcontent type="application/msexcel" variable="#myHTML#" />
>
> > > If you go this route though, be aware that for larger files where you
> > might
> > > be running cfset often, you might want to switch to a Java class object:
>
> > >     <cfset myHTML = createObject("java","java.lang.StringBuffer")>
>
> > > And then you would do
>
> > >     <cfset myHTML.append("<tr>")>
>
> > > And your final cfcontent tag would look like:
>
> > >     <cfcontent type="application/msexcel" variable="#ToBinary( ToBase64(
> > > totalHTML.Trim() ) )#" />
> > > To get it back to a normal string type. I found the above hint on some
> > blog
> > > about coldfusion after I found that things were going very slowly for a
> > 20
> > > row excel output. Doing things with the stringbuffer was much faster
> > > (although I don't know about the 'safety' of working with a more
> > primitive,
> > > as I understand, class)
>
> > > Best,
>
> > > Tomek
>
> > > On Sun, Nov 2, 2008 at 9:34 PM, Marco van den Oever <
>
> > > [EMAIL PROTECTED]> wrote:
>
> > > > Hereby a simple method:
>
> > > > <cfcontent type="application/vnd.ms-excel">
> > > >    <h2>Polling statistics: #stprops_pollingdata.question#</h2>
> > > >    <table border="1" cellpadding="1" cellspacing="2">
> > > >      <tr>
> > > >        <th>Date / Time created</th>
> > > >        <th>Question</th>
> > > >        <cfloop index="i" from="1" to="#application['wsoFarcryPolling'
> > > > & pollingid]#">
> > > >          <cfif stprops_pollingdata['answer' & i] GT 0>
> > > >            <th>#stprops_pollingdata['answer' & i]#</th>
> > > >          </cfif>
> > > >        </cfloop>
> > > >        <th>Total votes</th>
> > > >      </tr>
> > > >      <tr>
> > > >        <td>#stprops_pollingdata.datetimecreated#</td>
> > > >        <td>#stprops_pollingdata.question#</td>
> > > >        <cfloop index="i" from="1" to="#application['wsoFarcryPolling'
> > > > & pollingid]#">
> > > >          <cfif stprops_pollingdata['answer' & i] GT 0>
> > > >            <td>#sums[i].recordcount#</td>
> > > >          </cfif>
> > > >        </cfloop>
> > > >        <td>#answers_sum#</td>
> > > >      </tr>
> > > >    </table>
>
> > > > On Nov 3, 12:57 am, Marco van den Oever <[EMAIL PROTECTED]>
> > > > wrote:
> > > > > Is there a function to put db data in Excel???
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"farcry-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/farcry-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to