Arix Posted August 12, 2006 Posted August 12, 2006 Hello everybody. 1. How can multiple GridViews on a single page be exported to a single Excel file, so that all GridViews are located on the same worksheet (with proper distances - empty rows and columns - between the separate GridViews, of course)? 2. How can be done a similar operation: each GridView to be located in a different worksheet but still in a single file? Thank you. Quote
rfazendeiro Posted August 14, 2006 Posted August 14, 2006 hi, i have put information in a excel sheet like this: <html> <head> <title>List</title> </head> <body> <form id="Form1" method="post" runat="server"> <%Response.Clear();%> <table border="1"> <asp:Repeater id="rptRanking" runat="server"> <HeaderTemplate> <tr> <th>Name</th> <th>Email</th> <th>MobilePhone</th> <th>Points</th> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td><%# DataBinder.Eval(Container.DataItem, "name") %></td> <td><%# DataBinder.Eval(Container.DataItem, "email") %></td> <td><%# DataBinder.Eval(Container.DataItem, "phone") %></td> <td><%# DataBinder.Eval(Container.DataItem, "points") %></td> </tr> </ItemTemplate> </asp:Repeater> </table> <%Response.End();%> </form> </body> </html> [/html] in the codebehind i just put the following [csharp] using System; using System.Web.UI; using System.Web.UI.WebControls; namespace PTCom.PTWiFi.MemberGetMember.Presentation { public class Ranking_excel_list : Page { protected Repeater rptRanking; private void Page_Load(object sender, EventArgs e) { Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("content-disposition","attachment; filename=freepromocode_list.xls"); rptRanking.DataSource = "GET INFORMATION FROM DATA SOURCE" rptRanking.DataBind(); } } [/csharp] hope this helps Quote
Arix Posted August 14, 2006 Author Posted August 14, 2006 This is not what I asked, but thank you anyway. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.