exporting to excel question

  • Thread starter Thread starter JohnE
  • Start date Start date
J

JohnE

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
 
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
 
Back
Top