Hello everyone, I have a problem with some code I'm testing that I will use to export information from a DataTable over to an excel file. I took this code from some on line tutorials, seems they all are pretty much the same
protected void exportToExcelButton_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt = currentTable();
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("content-disposition", "attachment; filename=somefilename.xls");
System.IO.StringWriter sw = new System.IO.StringWriter();
string tab = "";
foreach (DataColumn dc in dt.Columns)
{
sw.Write(tab + dc.ColumnName);
tab = "\t";
}
sw.Write("\n");
int i;
...
Go to the complete details ...