exporting to excel question

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
 
T

ThatsIT.net.au

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top