exporting to excel question - DOTNET
This is a discussion on exporting to excel question - DOTNET ; I am able to export the datatable to excel. Below is the code that is being
used in the button click event by calling the below and passing in the
filename. But there are 2 columns in the datatable that ...
-
exporting to excel question
I am able to export the datatable to excel. Below is the code that is being
used in the button click event by calling the below and passing in the
filename. But there are 2 columns in the datatable that are checkboxes. How
can I get those to show either true or false (checked/unchecked)? Example
code or links are good.
public void ExportGridToExcel(string fileName)
{
DataTable dataTable = new DataTable();
Response.ClearContent();
Response.AddHeader("content-disposition",
string.Format("attachment;filename={0}.xls", fileName));
Response.ContentType = "application/ms-excel";
StringWriter stw = new StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);
GridView gvExport = new GridView();
gvExport.DataSource = bindgrid();
gvExport.DataBind();
gvExport.RenderControl(htextw);
Response.Write(stw.ToString());
Response.End();
}
Thanks.
John
-
Re: exporting to excel question
Maybe something like
new table = oldtable
for r as tablerow in newTable
detect if their is a checkbox and what its value is, then remove it and
set sells text to T or F
next
"JohnE" <JohnEatdiscussionsdotmicrosoft.com> wrote in message
news:ED38B1B1-E139-4539-9F74-0C0569D895B2atmicrosoftdotcom...
>I am able to export the datatable to excel. Below is the code that is
>being
> used in the button click event by calling the below and passing in the
> filename. But there are 2 columns in the datatable that are checkboxes.
> How
> can I get those to show either true or false (checked/unchecked)? Example
> code or links are good.
>
> public void ExportGridToExcel(string fileName)
> {
> DataTable dataTable = new DataTable();
> Response.ClearContent();
> Response.AddHeader("content-disposition",
> string.Format("attachment;filename={0}.xls", fileName));
> Response.ContentType = "application/ms-excel";
> StringWriter stw = new StringWriter();
> HtmlTextWriter htextw = new HtmlTextWriter(stw);
> GridView gvExport = new GridView();
> gvExport.DataSource = bindgrid();
> gvExport.DataBind();
> gvExport.RenderControl(htextw);
> Response.Write(stw.ToString());
> Response.End();
> }
>
> Thanks.
> John
>
>