I have a gridview that has six columns. I need to hide the last column
(i.e. not download it) in the download from gridview to excel. My
current code (which downloads the entire gridview) is as follows:
public static void ExportExcelFile (Control htmlData, string
filename)
{
HttpContext.Cur rent.Response.C lear();
HttpContext.Cur rent.Response.A ddHeader("conte nt-disposition",
"attachment;fil ename="
+ filename + ".xls");
HttpContext.Cur rent.Response.C harset = "";
HttpContext.Cur rent.Response.C ontentType = "applicatio n/
vnd.xls";
System.IO.Strin gWriter stringWrite = new
System.IO.Strin gWriter();
System.Web.UI.H tmlTextWriter htmlWrite = new
HtmlTextWriter( stringWrite);
htmlData.Render Control(htmlWri te);
HttpContext.Cur rent.Response.W rite(stringWrit e.ToString());
HttpContext.Cur rent.Response.E nd();
}
I am calling this by the following code:
protected void btnDownloadDebi t_Click(object sender, EventArgs e)
{
grvDebit.Column s[5].Visible = false;
Util.ExportExce lFile(grvDebit, "DebitDetai l");
grvDebit.Column s[5].Visible = true;
}
I thought that making the fifth column's visible property to false
before the call would result in that column not being downloaded. I
was wrong. Can anyone give me some advice on this? Thanks for all help
in advance.
Dave
(i.e. not download it) in the download from gridview to excel. My
current code (which downloads the entire gridview) is as follows:
public static void ExportExcelFile (Control htmlData, string
filename)
{
HttpContext.Cur rent.Response.C lear();
HttpContext.Cur rent.Response.A ddHeader("conte nt-disposition",
"attachment;fil ename="
+ filename + ".xls");
HttpContext.Cur rent.Response.C harset = "";
HttpContext.Cur rent.Response.C ontentType = "applicatio n/
vnd.xls";
System.IO.Strin gWriter stringWrite = new
System.IO.Strin gWriter();
System.Web.UI.H tmlTextWriter htmlWrite = new
HtmlTextWriter( stringWrite);
htmlData.Render Control(htmlWri te);
HttpContext.Cur rent.Response.W rite(stringWrit e.ToString());
HttpContext.Cur rent.Response.E nd();
}
I am calling this by the following code:
protected void btnDownloadDebi t_Click(object sender, EventArgs e)
{
grvDebit.Column s[5].Visible = false;
Util.ExportExce lFile(grvDebit, "DebitDetai l");
grvDebit.Column s[5].Visible = true;
}
I thought that making the fifth column's visible property to false
before the call would result in that column not being downloaded. I
was wrong. Can anyone give me some advice on this? Thanks for all help
in advance.
Dave