Grid View To Excel
<p>Hi
I am trying to convert the contents of a grid View to an excel file
and I am doing it using this code</p>

<pre><code> string attachment = "attachment; filename= " + FileName; 
 Response.ClearContent();
 Response.AddHeader("content-disposition", attachment);
 Response.ContentType = "application/excel";
 StringWriter sw = new StringWriter();
 HtmlTextWriter htw = new HtmlTextWriter(sw);
 gv.RenderControl(htw);           
 Response.Write(sw.ToString());
 Response.End();
</code></pre>

<p>The problem is I am getting some sort of html in an excel style format , theres java script in the page links etc
what I want is to turn the results of my query into a comma seperated file
Is that do-able for free or do I have to run the query myself get the data and write out a csv stream
Thanks </p>
