<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<ej:Grid ID="Grid" runat="server" AllowSorting="True" AllowGrouping="true" AllowResizing="true" AllowPaging="True" AllowFiltering="True" OnServerExcelExporting="Grid_ServerExcelExporting">
<FilterSettings FilterType="Excel" />
<ToolbarSettings ShowToolbar="True" ToolbarItems="excelExport" />
-----------------
</ej:Grid>
</asp:Content>
--------------------------------------------------------------------
private DataTable GetDataTale()
{
DataTable dt = new DataTable("Table");
dt.Columns.AddRange(new DataColumn[3] {
new DataColumn("Id", typeof(int)),
new DataColumn("Name", typeof(string)),
new DataColumn("Qty",typeof(string)) });
DataRow dr = null;
for (int i = 0; i <= 100; i++)
{
dr = dt.NewRow();
dr[0] = i;
dr[1] = "Product Name " + i.ToString();
dr[2] = "Qty" + i.ToString();
dt.Rows.Add(dr);
}
return dt;
}
protected void Grid_ServerExcelExporting(object sender, Syncfusion.JavaScript.Web.GridEventArgs e)
{
ExcelExport exp = new ExcelExport();
DataTable dt = GetDataTale();
exp.Export(Grid.Model, dt, "Export.xlsx", ExcelVersion.Excel2010, true, true, "flat-lime");
}
|