string FileName = DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute;
HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8) + ".xls");
HttpContext.Current.Response.ContentType = "application/ms-excel";
DataTable dt = webBll.getExcel();
int i = 0, j;
for (i = 0; i < dt.Columns.Count; i++)
{
HttpContext.Current.Response.Write(dt.Columns[i].ToString() + "\t");
}
HttpContext.Current.Response.Write("\n");
foreach (DataRow dr in dt.Rows)
{
for (j = 0; j < dr.ItemArray.Length; j++)
HttpContext.Current.Response.Write(dr.ItemArray[j].ToString() + "\t");
HttpContext.Current.Response.Write("\n");
}
HttpContext.Current.Response.End();