private void Daochu (string outtpye)
{
String Name= "My" +datetime.now.tostring ("YYMMDD-HHMMSS") + "number file export";
System.Web.HttpContext hc=system.web.httpcontext.current;
Hc. Response.Clear ();
Hc. Response.buffer=true;
Hc. Response.contentencoding=system.text.encoding.utf8;
if (outtpye== "1")
{
Hc. Response.AddHeader ("Content-disposition", "Attachment;filename=" +httputility.urlencode (name, SYSTEM.TEXT.ENCODING.UTF8) + ". Doc");
Hc. Response.contenttype= "Application/ms-word";
}
else if (outtpye== "2")
{
Hc. Response.AddHeader ("Content-disposition", "Attachment;filename=" +httputility.urlencode (name, SYSTEM.TEXT.ENCODING.UTF8) + ". xls");
Hc. Response.contenttype= "Application/ms-excel";
}
System.IO.StringWriter sw=new System.IO.StringWriter ();
System.Web.UI.HtmlTextWriter htw=new System.Web.UI.HtmlTextWriter (SW);
This. Datagrid1.rendercontrol (HTW);
Hc. Response.Write (SW. ToString ());
Hc. Response.End ();
Response.Write ("<script language=javascript>window.opener=null;window.close ();</script>");
}
__________________________ type ________________________________________
Response.ContentType = "Application/vnd.ms-excel"
Response.ContentType = "Application/msword"; </