怎样将DataGrid中的数据导入Excel中
2008-06-12 15:48
453 查看
//摘自http://www.dotnetsky.net/netsave/ShowTopic-77067.html //
try{
Response.Clear();
Response.Buffer= true;
Response.Charset="GB2312";
Response.ContentEncoding=System.Text.Encoding.GetEncoding("UTF-8");//设置输出流为简体中文Response.AppendHeader("Content-Disposition","attachment;filename=test.xls"); Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。 this.EnableViewState = false;
CultureInfo myCItrad = new CultureInfo("ZH-CN",true); HtmlGenericControl div=new HtmlGenericControl(); System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad); div.InnerHtml = oStringWriter.ToString(); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); // 下载页面显示的
DataGrid1.RenderControl(oHtmlTextWriter); // LZ 注意此处DataGrid1div.InnerHtml =oStringWriter.ToString();
Response.Write(div.InnerText); Response.End();
}
catch( Exception ex)
{MsgBox("",ex.Message);}
try{
Response.Clear();
Response.Buffer= true;
Response.Charset="GB2312";
Response.ContentEncoding=System.Text.Encoding.GetEncoding("UTF-8");//设置输出流为简体中文Response.AppendHeader("Content-Disposition","attachment;filename=test.xls"); Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。 this.EnableViewState = false;
CultureInfo myCItrad = new CultureInfo("ZH-CN",true); HtmlGenericControl div=new HtmlGenericControl(); System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad); div.InnerHtml = oStringWriter.ToString(); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); // 下载页面显示的
DataGrid1.RenderControl(oHtmlTextWriter); // LZ 注意此处DataGrid1div.InnerHtml =oStringWriter.ToString();
Response.Write(div.InnerText); Response.End();
}
catch( Exception ex)
{MsgBox("",ex.Message);}
相关文章推荐
- [导入]怎样实现excel的数据导入到datagrid中
- 怎样实现excel的数据导入到datagrid中?
- 将DataGrid中的数据完全导入到EXCEL中
- java怎样把数据导入到Excel中去
- 怎样将Excel中的数据导入到SQL Server 2000数据库中
- 将DataGrid中的数据完全导入到EXCEL中
- winform中 将DataGrid中的数据导入Excel中,并显示Excel应用程序
- ASP.NET 把DataGrid数据导入到Excel中
- 怎样将Datatable中的数据直接导入到Excel模板上
- DataGrid数据导入excel或word
- Excel数据导入DataGrid中
- 怎样将excel中的数据导入到oracle数据库中
- 怎样将Excel中的数据导入到SQL Server 2000数据库中
- DataGrid的数据导入到Excel或CSV
- 怎样将Excel中的数据导入到SQL Server 2000数据库中
- 怎样将excel中的数据通过PL/SQL导入ORACLE数据库中
- 将datagrid数据导入到excel(转载)
- 关于DataGrid 数据导入Excel乱码
- [VB.NET]救助:将datagrid中的数据导入到excel中时遇到错误??
- DataGrid的数据导入到Excel或CSV