Bind gridview data to Excel sheet
//Add relevant Assembly first to asp.page
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v8.2.Export, Version=8.2.2.0, Culture=neutral, PublicKeyToken=49d90c14d24271b5"
Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dxwgv" %>
Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v8.2, Version=8.2.2.0, Culture=neutral, PublicKeyToken=49d90c14d24271b5"
Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v8.2, Version=8.2.2.0, Culture=neutral, PublicKeyToken=49d90c14d24271b5"
Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dxwgv" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v8.2, Version=8.2.2.0, Culture=neutral, PublicKeyToken=49d90c14d24271b5"
Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
// Then add a gridview
// Then add a GridViewExporter as below I have a thrid part tool called devExpress
<dxwgv:ASPxGridViewExporter id="ASPxGridViewExporter1" runat="server" DetailHorizontalOffset="10" DetailVerticalOffset="10" LeftMargin="1" >
</dxwgv:ASPxGridViewExporter>
</dxwgv:ASPxGridViewExporter>
//Then go to class (.cs )file
method_name(DataTable dtx)
{
DataTable dt = new DataTable();
dt = dtx;
gridView1.DataSource= dt;
string repName ="RepName";
ASPxGridViewExporter1.WriteXlsToResponse(repName , true);
}
{
DataTable dt = new DataTable();
dt = dtx;
gridView1.DataSource= dt;
string repName ="RepName";
ASPxGridViewExporter1.WriteXlsToResponse(repName , true);
}
Comments
Post a Comment