DataGrid数据导入Excel 选择自 sunnystar365 的 Blog
2005-09-19 22:10
579 查看
if(DataGrid1.Items.Count==0)
{
Response.Write("<script>alert('对不起,你没有查询到任何记录,不能导出数据')</script>");
}
else
{ Response.Clear();
Response.Buffer= true;
Response.Charset="GB2312";
Response.AppendHeader("Content-Disposition","attachment;filename=FileName.xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");
//设置输出流为简体中文
Response.ContentType = "application/ms-excel";
//设置输出文件类型为excel文件。
this.EnableViewState = false;
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",true);
System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
DataGrid1.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
}
作者Blog:http://blog.csdn.net/sunnystar365/
{
Response.Write("<script>alert('对不起,你没有查询到任何记录,不能导出数据')</script>");
}
else
{ Response.Clear();
Response.Buffer= true;
Response.Charset="GB2312";
Response.AppendHeader("Content-Disposition","attachment;filename=FileName.xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");
//设置输出流为简体中文
Response.ContentType = "application/ms-excel";
//设置输出文件类型为excel文件。
this.EnableViewState = false;
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",true);
System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
DataGrid1.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
}
作者Blog:http://blog.csdn.net/sunnystar365/
相关文章推荐
- datagrid数据导出到excel文件给客户端下载的几种方法 选择自 yangyifan0 的 Blog
- ASP.NET 把DataGrid数据导入到Excel中
- DataGrid中的数据导入到Word和Excel_C#
- excel数据导入到datagrid
- DataGrid中的数据导入到Word和Excel_C#
- 怎样实现excel的数据导入到datagrid中?
- Excel数据导入DataGrid中
- DataGrid中的数据导入到Word和Excel_VB
- excel数据导入到datagrid
- 将DataGrid中的数据完全导入到EXCEL中
- excel数据导入到datagrid
- 将DataGrid中的数据完全导入到EXCEL中
- 将datagrid数据导入到excel(转载)
- [导入]怎样实现excel的数据导入到datagrid中
- Silverlight 将DataGrid的数据导入到Excel中
- DataGrid数据导入excel或word
- 使用ModalDialog选择EXCEL,导入数据到数据库
- DataGrid数据导入Excel
- DataGrid数据导入Excel
- [引]SQLServer和Access、Excel数据传输简单总结 选择自 xdev 的 Blog