gridview 保存到 excel c# .net gridview乱码excel.netwebform 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://bbs.csdn.net/topics/390796988http://bbs.csdn.net/topics/390780207发帖两次,未解决....... 试试 下边的代码GridView gv = new GridView(); gv.DataSource = dtError; gv.DataBind(); gv.Attributes.Add("style", "vnd.ms-excel.numberformat:@"); HttpResponse hResponse = this.Response; string fileName1 = "新员工格式验证错误统计" + DateTime.Now.ToString("yyyyMMdd"); hResponse.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName1, System.Text.Encoding.UTF8) + ".xls"); hResponse.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); hResponse.ContentType = "application/ms-excel"; this.EnableViewState = false; StringWriter tw = new StringWriter(); System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw); gv.RenderControl(hw); hResponse.Write(tw); hResponse.End(); 你的方法我试过的呀。http://bbs.csdn.net/topics/390796988 见 3 楼是不是不兼容的缘故呢? 你安装的win7是ghost 版的吧,如果是,里面集成是的office2007版本的,你原来是office2003版本,肯定打不开的。建议你把office2007删除,重新安装office2003.试试看。 你的方法我试过的呀。http://bbs.csdn.net/topics/390796988 见 3 楼是不是不兼容的缘故呢?弹出下载框是什么样子的?、要用IE下载 是 win7 Ghost 版的 公司现在都是 office 2007 的 (总不能全部都要安装2003吧) 之前是 office 2003 就没有问题 ,有啥好的办法可以解决吗? 你的方法我试过的呀。http://bbs.csdn.net/topics/390796988 见 3 楼是不是不兼容的缘故呢?弹出下载框是什么样子的?、要用IE下载弹出框如下保存后 打开的样子 如下:http://bbs.csdn.net/topics/390780207 public static void DGToExcel(Control ctl, string fileName) { HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename="+fileName); HttpContext.Current.Response.Charset = ""; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default; HttpContext.Current.Response.ContentType = "application/ms-excel"; ctl.Page.EnableViewState = false; StringWriter tw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(tw); ctl.RenderControl(hw); HttpContext.Current.Response.Write(tw.ToString()); HttpContext.Current.Response.End(); }修改一下编码方式解决乱码问题 让你测试是不是office版本引起的问题无语了 BOM 物料清单 ? 这个有啥用呀? 不懂耶.... 你导出的是2003格式的win7上默认的是office2007,要打开2003的文档,需要安装office2007兼容性组件 BOM 物料清单 ? 这个有啥用呀? 不懂耶....BOM = ByteOrderMarking 急急急急求一个C#的RPG游戏,什么都行只要能耍的,谢了!!! C# Graphics 图层问题,急急急!!! 节前求一简单正则.........谢谢 关于库存的问题。算单价的问题。。 Sql image字段如何为空? 请问一个关于break的问题 c#如何打开已存入数据库的WORD文档,进行文档编辑或删除!在线 如何添加Microsoft Visio Drawing Control组件? C#开发视频监控界面 一个菜鸟的问题!!!! winfrom 程序 发布 之后是不是不带配置文件的??? wpf combobox 多选
http://bbs.csdn.net/topics/390780207
发帖两次,未解决.......
gv.DataSource = dtError;
gv.DataBind();
gv.Attributes.Add("style", "vnd.ms-excel.numberformat:@");
HttpResponse hResponse = this.Response;
string fileName1 = "新员工格式验证错误统计" + DateTime.Now.ToString("yyyyMMdd");
hResponse.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName1, System.Text.Encoding.UTF8) + ".xls");
hResponse.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
hResponse.ContentType = "application/ms-excel";
this.EnableViewState = false;
StringWriter tw = new StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
gv.RenderControl(hw);
hResponse.Write(tw);
hResponse.End();
http://bbs.csdn.net/topics/390796988 见 3 楼是不是不兼容的缘故呢?
http://bbs.csdn.net/topics/390796988 见 3 楼是不是不兼容的缘故呢?
弹出下载框是什么样子的?、要用IE下载
有啥好的办法可以解决吗?
http://bbs.csdn.net/topics/390796988 见 3 楼是不是不兼容的缘故呢?
弹出下载框是什么样子的?、要用IE下载
弹出框如下
保存后 打开的样子 如下:
http://bbs.csdn.net/topics/390780207
public static void DGToExcel(Control ctl, string fileName)
{
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename="+fileName);
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
HttpContext.Current.Response.ContentType = "application/ms-excel";
ctl.Page.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
ctl.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}修改一下编码方式解决乱码问题
win7上默认的是office2007,要打开2003的文档,需要安装office2007兼容性组件