ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Export GridView as Image to Excel PDF using C# and VB.Net in ASP.Net<p>Hi <a class="username" rel="iamjer76">iamjer76</a>,</p> <p>Refer below sample.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;asp:Panel runat=&#34;server&#34; ID=&#34;pnlImage&#34;&gt; &nbsp;&nbsp;&nbsp; &lt;asp:GridView ID=&#34;GridView1&#34; runat=&#34;server&#34; AutoGenerateColumns=&#34;false&#34;&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Columns&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:BoundField DataField=&#34;Id&#34; HeaderText=&#34;Customer Id&#34; ItemStyle-Width=&#34;90&#34; /&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:BoundField DataField=&#34;Name&#34; HeaderText=&#34;Name&#34; ItemStyle-Width=&#34;120&#34; /&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:BoundField DataField=&#34;Country&#34; HeaderText=&#34;Country&#34; ItemStyle-Width=&#34;120&#34; /&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Columns&gt; &nbsp;&nbsp;&nbsp; &lt;/asp:GridView&gt; &nbsp;&nbsp;&nbsp; &lt;br /&gt; &nbsp;&nbsp;&nbsp; &lt;asp:GridView ID=&#34;GridView2&#34; runat=&#34;server&#34; AutoGenerateColumns=&#34;false&#34;&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Columns&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:BoundField DataField=&#34;Id&#34; HeaderText=&#34;Customer Id&#34; ItemStyle-Width=&#34;90&#34; /&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:BoundField DataField=&#34;Name&#34; HeaderText=&#34;Name&#34; ItemStyle-Width=&#34;120&#34; /&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:BoundField DataField=&#34;Country&#34; HeaderText=&#34;Country&#34; ItemStyle-Width=&#34;120&#34; /&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Columns&gt; &nbsp;&nbsp;&nbsp; &lt;/asp:GridView&gt; &lt;/asp:Panel&gt; &lt;asp:HiddenField ID=&#34;hfImageData&#34; runat=&#34;server&#34; /&gt; &lt;br /&gt; &lt;asp:Button ID=&#34;btnExport&#34; Text=&#34;Export To&nbsp;&nbsp; Pdf&#34; runat=&#34;server&#34; UseSubmitBehavior=&#34;false&#34; &nbsp;&nbsp;&nbsp; OnClick=&#34;ExportToPdf&#34; OnClientClick=&#34;return ConvertToImage(this)&#34; /&gt; &lt;br /&gt; &lt;asp:Button Text=&#34;Export To Excel&#34; runat=&#34;server&#34; runat=&#34;server&#34; OnClick=&#34;ExportToExcel&#34; &nbsp;&nbsp;&nbsp; UseSubmitBehavior=&#34;false&#34; OnClientClick=&#34;return ConvertToImage(this)&#34; /&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; &nbsp;&nbsp;&nbsp; function ConvertToImage(btnExport) { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; html2canvas($(&#34;[id*=pnlImage]&#34;)[0], { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; onrendered: function (canvas) { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var base64 = canvas.toDataURL(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(&#34;[id*=hfImageData]&#34;).val(base64); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; __doPostBack(btnExport.name, &#34;&#34;); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false; &nbsp;&nbsp;&nbsp; } &lt;/script&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Data; using iTextSharp.text.pdf; using iTextSharp.text; using System.IO;</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.Data Imports System.IO Imports iTextSharp.text Imports iTextSharp.text.pdf</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { &nbsp;&nbsp;&nbsp; if (!this.IsPostBack) &nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataTable dt = new DataTable(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)), &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new DataColumn("Name", typeof(string)), &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new DataColumn("Country",typeof(string)) }); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dt.Rows.Add(1, "John Hammond", "United States"); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dt.Rows.Add(2, "Mudassar Khan", "India"); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dt.Rows.Add(3, "Suzanne Mathews", "France"); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dt.Rows.Add(4, "Robert Schidner", "Russia"); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GridView1.DataSource = dt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GridView1.DataBind(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GridView2.DataSource = dt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GridView2.DataBind(); &nbsp;&nbsp;&nbsp; } } protected void ExportToPdf(object sender, EventArgs e) { &nbsp;&nbsp;&nbsp; string base64 = Request.Form[hfImageData.UniqueID].Split(',')[1]; &nbsp;&nbsp;&nbsp; byte[] bytes = Convert.FromBase64String(base64); &nbsp;&nbsp;&nbsp; Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 10f); &nbsp;&nbsp;&nbsp; PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream); &nbsp;&nbsp;&nbsp; pdfDoc.Open(); &nbsp;&nbsp;&nbsp; iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(bytes); &nbsp;&nbsp;&nbsp; pdfDoc.Add(img); &nbsp;&nbsp;&nbsp; pdfDoc.Close(); &nbsp;&nbsp;&nbsp; Response.ContentType = "application/pdf"; &nbsp;&nbsp;&nbsp; Response.AddHeader("content-disposition", "attachment;filename=GridView.pdf"); &nbsp;&nbsp;&nbsp; Response.Cache.SetCacheability(HttpCacheability.NoCache); &nbsp;&nbsp;&nbsp; Response.Write(pdfDoc); &nbsp;&nbsp;&nbsp; Response.End(); } protected void ExportToExcel(object sender, EventArgs e) { &nbsp;&nbsp;&nbsp; string base64 = Request.Form[hfImageData.UniqueID].Split(',')[1]; &nbsp;&nbsp;&nbsp; byte[] bytes = Convert.FromBase64String(base64); &nbsp;&nbsp;&nbsp; string filepath = string.Format("~/Files/GridView.jpg"); &nbsp;&nbsp;&nbsp; File.WriteAllBytes(Server.MapPath(filepath), bytes); &nbsp;&nbsp;&nbsp; System.Web.UI.WebControls.Image imgCapture = new System.Web.UI.WebControls.Image(); &nbsp;&nbsp;&nbsp; imgCapture.ImageUrl = this.GetAbsoluteUrl(filepath); &nbsp;&nbsp;&nbsp; using (StringWriter sw = new StringWriter()) &nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using (HtmlTextWriter hw = new HtmlTextWriter(sw)) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Web.UI.WebControls.Table table = new System.Web.UI.WebControls.Table(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TableRow row = new TableRow(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; row.Cells.Add(new TableCell()); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; row.Cells[0].Controls.Add(imgCapture); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; table.Rows.Add(row); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; table.RenderControl(hw); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Clear(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Buffer = true; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.AddHeader("content-disposition", "attachment;filename=Images.xls"); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Charset = ""; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.ContentType = "application/vnd.ms-excel"; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Write(sw.ToString()); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Flush(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.End(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp; } } private string GetAbsoluteUrl(string relativeUrl) { &nbsp;&nbsp;&nbsp; relativeUrl = relativeUrl.Replace("~/", string.Empty); &nbsp;&nbsp;&nbsp; string[] splits = Request.Url.AbsoluteUri.Split('/'); &nbsp;&nbsp;&nbsp; if (splits.Length &gt;= 2) &nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string url = splits[0] + "//"; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int i = 2; i &lt; splits.Length - 1; i++) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; url += splits[i]; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; url += "/"; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return url + relativeUrl; &nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp; return relativeUrl; }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load &nbsp;&nbsp;&nbsp; If Not Me.IsPostBack Then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim dt As DataTable = New DataTable() &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dt.Columns.AddRange(New DataColumn(2) {New DataColumn("Id", GetType(Integer)), New DataColumn("Name", GetType(String)), New DataColumn("Country", GetType(String))}) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dt.Rows.Add(1, "John Hammond", "United States") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dt.Rows.Add(2, "Mudassar Khan", "India") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dt.Rows.Add(3, "Suzanne Mathews", "France") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dt.Rows.Add(4, "Robert Schidner", "Russia") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GridView1.DataSource = dt &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GridView1.DataBind() &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GridView2.DataSource = dt &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GridView2.DataBind() &nbsp;&nbsp;&nbsp; End If End Sub Protected Sub ExportToPdf(ByVal sender As Object, ByVal e As EventArgs) &nbsp;&nbsp;&nbsp; Dim base64 As String = Request.Form(hfImageData.UniqueID).Split(","c)(1) &nbsp;&nbsp;&nbsp; Dim bytes As Byte() = Convert.FromBase64String(base64) &nbsp;&nbsp;&nbsp; Dim pdfDoc As Document = New Document(PageSize.A4, 10.0F, 10.0F, 10.0F, 10.0F) &nbsp;&nbsp;&nbsp; Dim writer As PdfWriter = PdfWriter.GetInstance(pdfDoc, Response.OutputStream) &nbsp;&nbsp;&nbsp; pdfDoc.Open() &nbsp;&nbsp;&nbsp; Dim img As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(bytes) &nbsp;&nbsp;&nbsp; pdfDoc.Add(img) &nbsp;&nbsp;&nbsp; pdfDoc.Close() &nbsp;&nbsp;&nbsp; Response.ContentType = "application/pdf" &nbsp;&nbsp;&nbsp; Response.AddHeader("content-disposition", "attachment;filename=GridView.pdf") &nbsp;&nbsp;&nbsp; Response.Cache.SetCacheability(HttpCacheability.NoCache) &nbsp;&nbsp;&nbsp; Response.Write(pdfDoc) &nbsp;&nbsp;&nbsp; Response.[End]() End Sub Protected Sub ExportToExcel(ByVal sender As Object, ByVal e As EventArgs) &nbsp;&nbsp;&nbsp; Dim base64 As String = Request.Form(hfImageData.UniqueID).Split(","c)(1) &nbsp;&nbsp;&nbsp; Dim bytes As Byte() = Convert.FromBase64String(base64) &nbsp;&nbsp;&nbsp; Dim filepath As String = String.Format("~/Files/GridView.jpg") &nbsp;&nbsp;&nbsp; File.WriteAllBytes(Server.MapPath(filepath), bytes) &nbsp;&nbsp;&nbsp; Dim imgCapture As System.Web.UI.WebControls.Image = New System.Web.UI.WebControls.Image() &nbsp;&nbsp;&nbsp; imgCapture.ImageUrl = Me.GetAbsoluteUrl(filepath) &nbsp;&nbsp;&nbsp; Using sw As StringWriter = New StringWriter() &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Using hw As HtmlTextWriter = New HtmlTextWriter(sw) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim table As System.Web.UI.WebControls.Table = New System.Web.UI.WebControls.Table() &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim row As TableRow = New TableRow() &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; row.Cells.Add(New TableCell()) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; row.Cells(0).Controls.Add(imgCapture) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; table.Rows.Add(row) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; table.RenderControl(hw) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Clear() &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Buffer = True &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.AddHeader("content-disposition", "attachment;filename=Images.xls") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Charset = "" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.ContentType = "application/vnd.ms-excel" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Write(sw.ToString()) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Flush() &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.[End]() &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Using &nbsp;&nbsp;&nbsp; End Using End Sub Private Function GetAbsoluteUrl(ByVal relativeUrl As String) As String &nbsp;&nbsp;&nbsp; relativeUrl = relativeUrl.Replace("~/", String.Empty) &nbsp;&nbsp;&nbsp; Dim splits As String() = Request.Url.AbsoluteUri.Split("/"c) &nbsp;&nbsp;&nbsp; If splits.Length &gt;= 2 Then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim url As String = splits(0) &amp; "//" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For i As Integer = 2 To splits.Length - 1 - 1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; url += splits(i) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; url += "/" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Return url &amp; relativeUrl &nbsp;&nbsp;&nbsp; End If &nbsp;&nbsp;&nbsp; Return relativeUrl End Function</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/207331/Export-GridView-as-Image-to-Excel-PDF-using-C-and-VBNet-in-ASPNet/https://www.aspforums.net:443/Threads/207331/Export-GridView-as-Image-to-Excel-PDF-using-C-and-VBNet-in-ASPNet/Wed, 14 Aug 2019 05:48:20 GMT