谁有asp.net Repeater 查询出来的数据导出Excel的代码呀,困扰好个几个星期了,谁有可用的代码帮帮小弟把。还有就是Excel导入到MS sql数据库。
解决方案 »
- jquery似乎与其他JS文件冲突,怎么办?
- 帮我写个Cache帮助类,通用的
- 这个网站的JS真他X的强大, 你写得出来吗?
- 请问怎么删除XML节点的问题
- 欢迎大家讨论!来者有分!关于asp页加到asp.Net工程里面。
- 北京Asp.Net的程序员看过来
- html页面用js写数据绑定
- 建立一个.net工程用一段时间后设置断点跟踪会变得很慢,各位有没有什么方法解决这个问题?
- C#静态构造函数如何初始化
- 紧急情况……有关SqlDataReader读出数据的问题!有请微软专家…………!有请微软专家…………!
- 在asp.net 中 网页上的textbox 如何实现 文本编辑器中的撤销、恢复时事件
- 插入数据与上传图片怎么保证事务一致性
{ httpResponse.Clear();
httpResponse.Buffer = true;
httpResponse.Charset = "utf-8";
httpResponse.AppendHeader("Content-Disposition", "attachment;filename=sap.xls");
httpResponse.ContentEncoding = System.Text.Decoder.ReferenceEquals("utf-8"); //设置输出流为简体中文
httpResponse.ContentType = "application/ms-excel"; //设置输出文件类型为excel文件。
httpPage.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);
dg.RenderControl(oHtmlTextWriter);
httpResponse.Write(oStringWriter.ToString());
httpResponse.End();
}
http://blog.163.com/sjzlgt@126/blog/static/2688758220087794312283/
rpt.DataBind();
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF7;
string FileName = "111.xls";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
Response.ContentType = "application/ms-excel";
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
rpt.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
{
strFileName = System.Web.HttpUtility.UrlEncode(strFileName,System.Text.Encoding.UTF8);
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.Buffer = true;
System.Web.HttpContext.Current.Response.Charset = "gb2312";
System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "online; filename=" + strFileName + ".xls");
System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
System.Web.HttpContext.Current.Response.ContentType = "application/ms-excel";
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);
rp.RenderControl(oHtmlTextWriter);
rp = null;
System.Web.HttpContext.Current.Response.Write(oStringWriter.ToString().Replace("<td","<td STYLE='MSO-NUMBER-FORMAT:\\@'"));
System.Web.HttpContext.Current.Response.Buffer = false;
System.Web.HttpContext.Current.Response.End();
}http://topic.csdn.net/u/20090914/09/382d4e17-12e0-45e0-8d9d-857c5011fe05.html
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw);
this.OrderList.RenderControl(hw); Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
Page.EnableViewState = false; Response.AppendHeader("Content-Disposition", "attachment;filename=Teacher.xls");
Response.Write("<html><head><meta http-equiv=Content-Type content=\"text/html; charset=gbk\"><title>Copyright by SDU</title></head><body><center>"); 出现乱码就把gbk换成auto
Response.Write(sw.ToString());
Response.Write("</center></body></html>");
Response.End();