Default.aspx
<ej:Grid ID="FlatGrid" runat="server" AllowPaging="True" OnServerWordExporting="FlatGrid_ServerWordExporting" OnServerPdfExporting="FlatGrid_ServerPdfExporting" OnServerExcelExporting="FlatGrid_ServerExcelExporting" >
<EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True"></EditSettings>
<ToolbarSettings ShowToolbar="true" ToolbarItems="excelExport,wordExport,pdfExport"></ToolbarSettings>
<Columns>
<ej:Column Field="OrderID" HeaderText="Order ID" Width="90" />
<ej:Column Field="CustomerID" HeaderText="Customer ID" Width="85"/>
<ej:Column Field="EmployeeID" HeaderText="Employee ID" Width="70"/>
<ej:Column Field="ShipCity" HeaderText="Ship City" Width="80" />
<ej:Column Field="Freight" HeaderText="Freight" Format="{0:C}" Width="80"/>
</Columns>
</ej:Grid>
Server side:-
// Excel Exporting
protected void FlatGrid_ServerExcelExporting(object sender, Syncfusion.JavaScript.Web.GridEventArgs e)
{
ExcelExport exp = new ExcelExport();
exp.Export(FlatGrid.Model, (IEnumerable)FlatGrid.DataSource, "Export.xlsx", ExcelVersion.Excel2010, true, true, "flat-lime");
}
// Word Exporting
protected void FlatGrid_ServerWordExporting(object sender, Syncfusion.JavaScript.Web.GridEventArgs e)
{
WordExport exp = new WordExport();
exp.Export(FlatGrid.Model, (IEnumerable)FlatGrid.DataSource, "Export.docx", true, true, "flat-lime");
}
// Pdf Exporting
protected void FlatGrid_ServerPdfExporting(object sender, Syncfusion.JavaScript.Web.GridEventArgs e)
{
PdfExport exp = new PdfExport();
exp.Export(FlatGrid.Model, (IEnumerable)FlatGrid.DataSource, "Export.pdf", true, true, "flat-lime");
}
|