0
我想将数据网格导出到excel文件。它正确地转换asp:BoundColumn,但无法转换具有linkbutton或imagebutton的模板列。这些单元格被转换为空单元格。将网格导出为excel时出现问题
这里是出口的控件到Excel中。代码,
Public Shared Sub Export(ByVal Mime As String, ByVal Filename As String, ByVal Response As HttpResponse, ByVal Control As Control)
Dim stringWrite As New System.IO.StringWriter()
Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
Response.Clear()
Response.Buffer = True
Response.Charset = String.Empty
Response.ContentType = Mime
Response.AddHeader("Content-Disposition", "filename=" & Filename)
Control.RenderControl(htmlWrite)
Response.Write("<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd""><html xmlns=""http://www.w3.org/1999/xhtml""><head id=""Head1"" runat=""server""><meta http-equiv=""content-type"" content=""text-html; charset=utf-8""></head><body>" & stringWrite.ToString & "</body></html>")
Response.End()
End Sub
问题出在哪里可以?有任何想法吗? 在此先感谢。
你需要的ImageButton在Excel中呢? – 2009-09-08 06:58:31
其实我的问题不是imagebutton的可见性。不显示它是可以的,但我想知道原因。但对于linkbutton是我需要它,至少是它的文本。 – 2009-09-08 07:03:35