简单问题,路过的近来看看咯,感激不尽!!!
一段从datagrid导出Excel的代码,运行成功,但是导出来的数据行与行之间总是隔着一个空行,还有就是它回自动弹出表格下载和本页面下载的对话框,我想只要能下载表格就可以了,页面就不要下载了,请各路人不吝指教
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);
this.dg.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
------解决方案--------------------有模版列的问题,还是换中写法吧