private void ExportExcel(string str,bool type)
{
Response.Buffer = true;
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.Charset = "gb2312";
if (type)
{
Page.Response.AddHeader("Content-Disposition", "filename=ExportFile.xls");
Page.Response.ContentType = "application/vnd.ms-excel"; //输出类型application/msword为word格式
}
else
{
Page.Response.AddHeader("Content-Disposition", "filename=ExportFile.doc");
Page.Response.ContentType = "application/msword"; //输出类型application/msword为word格式
}
Page.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
Page.Response.Write(str);
Page.Response.End();
}