Exporting multiple GridViews to single/multiple Excel sheets

Arix

Newcomer
Joined
Jun 8, 2006
Messages
3
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.
 
hi,

i have put information in a excel sheet like this:

Code:
<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
 
Back
Top