OK, this is different to my previous posting, so I thought it best to post
another to save confusion. I am having some really wierd things happening when
outputting data from a query to excel using cfeader and cfcontent. I am
building the where clause of the query dynamically using <cfif isdefined.. (see
code below for more detail). If I remove the cfeader and cfcontent tags, it
works fine, and the where clause is filtering out as it is supposed to..
HOWEVER, when I add back the cfheader and cfcontent, it is generating the
results in excel (which is what I want it to), but it is dislaying all data..
in other words, it seems to be ignoring the where clauses between the <cfif
tags even if they are true. I have included the full code below. Any
suggestions as to why this might be happening would be great. Thankyou.

<cfset FileLocation = "#AppLocation#administration\members\member_lists\ ">
<cfset FileName = "MbrList_#DateFormat(now(),'yymmdd')#_#RandRange(1 ,99)#.xls">

<cfquery name="Members" datasource="#datasource#">
SELECT m.email, m.member_number, m.name, m.address_1, m.address_2,
m.address_3, m.address_city, m.address_state, m.address_postcode,
m.address_country, mc.description
FROM members m,
member_categories mc
WHERE m.mem_category_id = mc.mem_category_id
<cfif isdefined("form.no_email")>
and (TRIM(m.email) = '' or m.email is null)
</cfif>
<cfif isdefined("form.not_renewed")>
and m.member_id in (select member_id from mem_subscriptions where period =
#form.not_renewed#)
</cfif>
ORDER BY member_id
</cfquery>


<cfheader name="Content-Disposition" value="inline; filename=#FileName#">
<cfcontent type="application/unknown">

<table border=1><tr><td><b>Member
No.</b></td><td><b>Category</b></td><td><b>Name</b></td><td><b>Address
1</b></td><td><b>Address 2</b></td><td><b>Address
3</b></td><td><b>City</b></td><td><b>State</b></td><td><b>Postcode</b></td><td><
b>Country</b></td></tr>
<cfoutput query="Members">

<tr><td>#member_number#</td><td>#description#</td><td>#name#</td><td>#address_1
#</td><td>#address_2#</td><td>#address_3#</td><td>#address_city#</td><td>#addres
s_state#</td><td>#address_postcode#</td><td>#address_country#</td></tr>
</cfoutput>
</table>