注意:我说的是Table控件,不是GridView。
而且由于结构比较复杂,数据是动态生成的。
实际上是由好几个表组合而成的一个Table,我是一个格一个格拼出来的,根本没用到Datasource、Databind什么的。
这个要怎么导出到 Excel 呢??别回以下这段代码,这段代码导出后的Excel是空的。 Response.Clear()
Response.Buffer = True
Response.Charset = "GB2312"
Response.AppendHeader("Content-Disposition", "attachment;filename=FileName.xls")
Response.ContentEncoding = System.Text.Encoding.UTF7
Response.ContentType = "application/ms-excel"
Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter)
Me.Table1.RenderControl(oHtmlTextWriter)
Response.Output.Write(oStringWriter.ToString)
Response.Flush()
Response.End()
而且由于结构比较复杂,数据是动态生成的。
实际上是由好几个表组合而成的一个Table,我是一个格一个格拼出来的,根本没用到Datasource、Databind什么的。
这个要怎么导出到 Excel 呢??别回以下这段代码,这段代码导出后的Excel是空的。 Response.Clear()
Response.Buffer = True
Response.Charset = "GB2312"
Response.AppendHeader("Content-Disposition", "attachment;filename=FileName.xls")
Response.ContentEncoding = System.Text.Encoding.UTF7
Response.ContentType = "application/ms-excel"
Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter)
Me.Table1.RenderControl(oHtmlTextWriter)
Response.Output.Write(oStringWriter.ToString)
Response.Flush()
Response.End()
解决方案 »
- 在局域网内别的电脑上访问不了一个服务器上的网站,是怎么回事呢?
- 如何对GRIDVIEW内容进行筛选?
- 初学ASP.NET一个简单的数据库连接问题
- 问一个超菜的问题:vb网页怎么用数据库对象?
- 如何引用用户控件中的类呢
- GridView 日期格式化
- 关于ASP.NET 2005 中的Listbox疑难问题
- 请问大侠们是不是有一个获取本地IP的方法?
- ASP.NET中GridView 内容滚动如何解决
- 高手来拿分,不用下面的循环,我怎么知道当前的在datagrid的checkbox当前列被选中的状态是checked还是not checked?
- 关于添加的问题,急~~
- 有浪费网络资源的嫌疑,还是想发帖问1下,大家有没有在用.NET的控件的
var winname = window.open('', '_blank', 'top=10000');
var strHTML = document.all.tableExcel.innerHTML;
winname.document.open('text/html', 'replace');
winname.document.writeln(strHTML);
winname.document.execCommand('saveas','','excel.xls');
winname.close();
}