I have a RadGrid that I want to export to Excel, but above the exported grid I would like to add an addition HTML table. After adding the table, the formatting of the export is unaligned. I'm guessing I don't have my HTML tags correct. All I want to accomplish is adding an HTML table above the exported grid and the table & the grid should fill 100% of the width of the screen. Please help.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!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 runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <telerik:RadScriptManager ID="mgrJS" runat="server"> </telerik:RadScriptManager> <telerik:radajaxmanager ID="mgrAjax" runat="server"> </telerik:radajaxmanager> <telerik:RadGrid runat="server" ID="dg" Skin="WebBlue" AllowSorting="true" ></telerik:RadGrid> <asp:Button ID="btn" runat="server" text="Export" /> </div> </form> </body> </html>Imports System.Data Partial Class _Default Inherits System.Web.UI.Page Private Function CreateDataTable() As DataTable Dim dt As New DataTable dt.Columns.Add("123", GetType(String)) dt.Columns.Add("456", GetType(String)) dt.Columns.Add("789", GetType(String)) Dim r As DataRow = dt.NewRow r(0) = "abc" r(1) = "def" r(2) = "ghi" dt.Rows.Add(r) Return dt End Function Protected Sub dg_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles dg.NeedDataSource dg.DataSource = CreateDataTable() End Sub Protected Sub btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn.Click Dim header As New StringBuilder("<table style='width:100%'><tr><td></td></tr><tr><td align='center'>The Title</td></tr><tr><td></td></tr><tr><td><table style='width:100%'>") dg.MasterTableView.Caption = header.ToString dg.ExportSettings.ExportOnlyData = True dg.ExportSettings.OpenInNewWindow = True dg.ExportSettings.IgnorePaging = True dg.MasterTableView.ExportToExcel() header.Append("</table></td></tr></table>") End SubEnd Class