Introduction
In this article
I'll show you how we can export a panel containing controls like Labels,
Textboxes etc. In many cases we need to export our GridView to Excel and
some other controls on the page to Excel.
Background
For exporting
our page content in this article I'm using a third party DLL which contains
same panel like ASP.Net panel. Doing a Google search I found this DLL and I'm
willing to share it with you. This export panel can be exported in various formats
like Excel, Word, HTML, PowerPoint and WordPerfect. By simply using just two or three lines
of code we can export our panel in th above mentioned format.
In so many cases we need to prepare reports; normally these reports we are
displayed in a GridView which you can export to Excel format with lots of stuff
but in this case you are able to export only GridView and only in Excel format.
But using this export panel control you can export anything in the panel to
various formats and with little stuff. So let's see this export panel control.
Step 1:
Start a new web
site and add a reference to the ExportPanel.dll file given with the upload in the bin
directory.
Step 2:
Register
tagprefix to ExportPanel.dll on Default.aspx page like below.
<%@ Register TagPrefix="cc1" Namespace="ControlFreak" Assembly="ExportPanel" %>
Step 3:
After registering tagprefix you can use this Exportpanel control like below.
<cc1:exportpanel id="ExportPanel1" runat="server" Height="207px" Width="688px" BorderWidth="1px" BorderStyle="Dotted" ScrollBars="Both"></cc1:exportpanel>
Step 4:
In this panel you can keep any control with data which you want to export in Excel Word, HTML etc. I'm keeping GridView and label.
<cc1:exportpanel
id="ExportPanel1"
runat="server"
Height="207px"
Width="688px"
BorderWidth="1px"
BorderStyle="Dotted"
ScrollBars="Both">
<table
class="style1">
<tr>
<td>
<asp:GridView
ID="GridView1"
runat="server"
BackColor="LightGoldenrodYellow"
BorderColor="Tan"
BorderWidth="1px"
CellPadding="2"
ForeColor="Black"
GridLines="None">
<AlternatingRowStyle
BackColor="PaleGoldenrod"
/>
<FooterStyle
BackColor="Tan"
/>
<HeaderStyle
BackColor="Tan"
Font-Bold="True"
/>
<PagerStyle
BackColor="PaleGoldenrod"
ForeColor="DarkSlateBlue"
HorizontalAlign="Center"
/>
<SelectedRowStyle
BackColor="DarkSlateBlue"
ForeColor="GhostWhite"
/>
<SortedAscendingCellStyle
BackColor="#FAFAE7"
/>
<SortedAscendingHeaderStyle
BackColor="#DAC09E"
/>
<SortedDescendingCellStyle
BackColor="#E1DB9C"
/>
<SortedDescendingHeaderStyle
BackColor="#C2A47B"
/>
</asp:GridView>
</td>
<td
valign="top">
Some Thing Here like controls or any text also.</td>
</tr>
<tr>
<td>
<asp:Label
ID="Label1"
runat="server"
Font-Bold="True"
ForeColor="#0000CC"
Text="I'm Lable"></asp:Label>
</td>
<td
bgcolor="#99FFCC">
<strong>This
is Table Cell</strong></td>
</tr>
</table>
</cc1:exportpanel>
Put one RadioButtonList to specify the format in which te user wants to
export the panel.

Deepthi VrPosted Jan 21, 2019, 3:51 AM
Hi. I am trying to get an impersonated image in an exported word file but it shows a broken link. I know this issue could be solved if i am accessing the image through its url but since its impersonation, i am redirecting the image link to another aspx file in a query string and in that file its fetched from the file server. I hope you understand my point. anyone faced this issue>> please revert.
Santosh PattarPosted Jan 17, 2019, 1:23 AM
How to apply stylesheet?
kiranPosted Jan 15, 2018, 3:39 AM
Your rar file is not openinig after download.
Pankaj KadamPosted May 7, 2016, 5:21 AM
can i?
Pankaj KadamPosted May 7, 2016, 5:21 AM
i want to Export to pdf
srinivas prabhuPosted Nov 23, 2015, 2:31 AM
Hi krishna, it is not working with my code that i am trying to export panel contains dynamic tablebuilder data, is there any change required to do export to excel
viral maruPosted Oct 30, 2014, 7:00 AM
Hi Krishna, Nice Tutorial.. ! but, is it support to dynamic .Net controls as well ?
NARESH BOLUSANIPosted Oct 17, 2014, 5:12 AM
this code is fine but i am export to excel in that not formatting HH:mm
snehal pokharnaPosted Mar 27, 2014, 2:56 AM
Hello its saying unknown server tag <cc1:exportpanel> even if added assembly and register...plz help me
dinesh pardeshiPosted Dec 3, 2012, 7:07 AM
the code is working fine for wor,html,excel. but it will not working for power point.so please send solution for power point.
Bhanuprakash BysaniPosted Nov 26, 2012, 2:35 AM
Hi when i added in to my solution dll is asking for strong name
danish tahirPosted Oct 25, 2012, 12:11 AM
Hi, the export works in Powerpoint 2003 but not in 2007. Can anyone suggest a solution for PP2007
Tamim MakkiPosted Oct 11, 2012, 11:49 AM
How can we add headers and footers to the word file?
Former memberPosted Sep 30, 2012, 1:13 PM
This is really nice article http://www.dotnetpools.com/Article/ArticleDetiail/?articleId=22&title=Gridview%20Export%20To%20Excel%20In%20Asp.Net%20C#
nagamani ptPosted Aug 28, 2012, 6:56 AM
hai nice work.now to add print option
kiran chPosted Jun 15, 2012, 1:19 AM
Hi.export to PPT is not working..when i select ppt and click export it is open blank ppt...
shyam srivastavaPosted Jun 11, 2012, 2:34 AM
hi
shyam srivastavaPosted Jun 11, 2012, 2:34 AM
fine but notworking with images .image cannot be exported with it.can you give any solution to export image and data both.
Elicela ZunigaPosted Mar 13, 2012, 12:39 PM
Ah Ok!!! well, I need it for office 2007, I will still look for it!!! Thanks a lot!!! Regards!!!
Elicela ZunigaPosted Mar 13, 2012, 12:24 PM
switch (RadioButtonList1.SelectedValue.ToString()) { case "HTML": ExportPanel1.ExportType = ExportPanel.AppType.HTML; break; case "Excel": ExportPanel1.ExportType = ExportPanel.AppType.Excel; break; case "Word": ExportPanel1.ExportType = ExportPanel.AppType.Word; break; case "Powerpoint": ExportPanel1.ExportType = ExportPanel.AppType.PowerPoint; break; case "WordPerfect": ExportPanel1.ExportType = ExportPanel.AppType.WordPerfect; break; }
Elicela ZunigaPosted Mar 13, 2012, 12:22 PM
When I press the radio button Powerpoint and click the button, it open the presentation but nothing appear, the presentation is without nothing, and the other documents works fine!!!, they show that the export panel has.... :(
Elicela ZunigaPosted Mar 13, 2012, 12:12 PM
I need it for power point!!! and I don't know how to do to make it work, please help me, is really helpful thoug.... Thanks!!!
Elicela ZunigaPosted Mar 13, 2012, 12:08 PM
Does not work with powerpoint... please help me!!!
loknadh osuriPosted Jan 20, 2012, 9:35 AM
provide screen shots for your articles, it will be useful . Thank you
Maria JohnsonPosted Jan 19, 2012, 11:10 PM
Its a very useful article for those who want to know how to export a panel in ASP.Net.
Sonakshi SinghPosted Jan 19, 2012, 11:02 PM
Good one Krishna..