Ron,
There's a few things I'd do...
I'd wrap everything from the first cfset to the cfoutput tag in a CFSILENT tag.
I'd put the CFOUTPUT on the same line as </cfsilent>.
I'd tinker with line breaks to insure that I'm spacing things
correctly for Excel, since it's getting everything verbatim from your
page.
So it'd look like this:
<cfsilent>
<cfset todayDate = #Now()#>
<cfset saveDate = #DateFormat(todayDate,('yymmdd'))#>
<cfset saveTime = #TimeFormat(todayDate,('HHmm'))#>
<CFSETTING ENABLECFOUTPUTONLY="yes">
<CFSET TAB=CHR(9)>
<CFQUERY NAME="get_Data" DATASOURCE="mydatasource">
SELECT Name_Last, Name_First, Group_Company,
FROM data
ORDER by Name_Last, Name_First
</CFQUERY>
<CFHEADER NAME="Content-Disposition" VALUE="inline;
filename=savedfile-#saveDate#-#saveTime#.xls">
<CFCONTENT TYPE="application/msexcel">
</cfsilent><CFOUTPUT QUERY="getData">
#Name_First##TAB##Name_Last##TAB##Group_Company#</CFOUTPUT>
The only change that may need making is to this:
...
</cfsilent><CFOUTPUT QUERY="getData">#Name_First# {removed to save space}
</CFOUTPUT>
When you're outputting data in a situation like this, line breaks
count. Something we often forget is that while a browser may ignore
extra white space, Excel, Word, or Acrobat don't.
Give it a try...
Laterz,
J
--
Continuum Media Group LLC
Burnsville, MN 55337
http://www.web-relevant.com
http://cfobjective.blogspot.com
On Fri, 14 Jan 2005 16:52:26 -0600, Ron Eis <[EMAIL PROTECTED]> wrote:
> I'm trying to add the headers in an .xls file created from my query. I
> get all the data from the query but how do I add the column headers in
> the Excel spreadsheet?
>
> Also, my data is output on every other line of the spreadsheet. Only
> the "even" numbers of the spreadsheet have data.
>
> Can anyone help?
>
> <cfset todayDate = #Now()#>
> <cfset saveDate = #DateFormat(todayDate,('yymmdd'))#>
> <cfset saveTime = #TimeFormat(todayDate,('HHmm'))#>
>
> <CFSETTING ENABLECFOUTPUTONLY="yes">
>
> <CFSET TAB=CHR(9)>
>
> <CFQUERY NAME="get_Data" DATASOURCE="mydatasource">
> SELECT Name_Last, Name_First, Group_Company,
> FROM data
> ORDER by Name_Last, Name_First
> </CFQUERY>
>
> <CFHEADER NAME="Content-Disposition" VALUE="inline;
> filename=savedfile-#saveDate#-#saveTime#.xls">
> <CFCONTENT TYPE="application/msexcel">
>
> <CFOUTPUT QUERY="get Data">
>
> #Name_First##TAB##Name_Last##TAB##Group_Company#
>
> </CFOUTPUT>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application
http://www.houseoffusion.com/banners/view.cfm?bannerid=48
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:190553
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54