private void ExportToExcel(DataTable dtIn)
{
DataTable dt = dtIn;
if (dt != null)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment;filename=FileName.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
string tab = "";
foreach (DataColumn dc in dt.Columns)
{
Response.Write(tab + dc.ColumnName);
tab = "\t";
}
Response.Write("\n");
int i;
foreach (DataRow dr in dt.Rows)
{
tab = "";
for (i = 0; i < dt.Columns.Count; i++)
{
Response.Write(tab + dr[i].ToString());
tab = "\t";
}
Response.Write("\n");
}
Response.End();
}
}
Compare Sql Server Table Constraints
13 years ago
0 comments:
Post a Comment