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