Essential Studio for Asp.Net | Demos

SHOWCASE SAMPLES
Showcase samples
    Grid / Events
    <%@ Page Title="Grid-Exporting Grid-ASP.NET-SYNCFUSION"   Language="C#" MetaDescription="This demo explains how to export the datagrid's content to Excel, PDF, and Word documents using the Syncfusion ASP.NET Web Forms DataGrid control." AutoEventWireup="true" CodeBehind="ExcelExporting.aspx.cs" MasterPageFile="~/Samplebrowser.Master" Inherits="WebSampleBrowser.Grid.ExcelExporting" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="SampleHeading" runat="server">
        <link href="../Content/ejthemes/responsive-css/ejgrid.responsive.css" rel="stylesheet" />
        <span class="sampleName">Grid / Events</span>
    </asp:Content>
    <asp:Content ID="ControlContent" runat="server" ContentPlaceHolderID="ControlsSection">
        <div>
            <ej:Grid ID="FlatGrid" runat="server" IsResponsive="true"  AllowFiltering="True" AllowGrouping="true" AllowReordering="true" AllowSorting="true" ShowSummary="true" ShowStackedHeader="true" OnServerWordExporting="FlatGrid_ServerWordExporting" OnServerPdfExporting="FlatGrid_ServerPdfExporting" OnServerExcelExporting="FlatGrid_ServerExcelExporting" AllowPaging="True">
                <ToolbarSettings ShowToolbar="true" ToolbarItems="excelExport,wordExport,pdfExport"></ToolbarSettings>
                  
                <SummaryRows>
                    <ej:SummaryRow ShowGroupSummary="false">
                        <SummaryColumn>
                            <ej:SummaryColumn SummaryType="Sum" Format="{0:C}" Prefix="Sum = " DisplayColumn="Freight" DataMember="Freight" />
                        </SummaryColumn>
                    </ej:SummaryRow>                
                </SummaryRows>
                <Columns>
                    <ej:Column Field="OrderID" HeaderText="Order ID" IsPrimaryKey="True" TextAlign="Right" Width="75" />
                    <ej:Column Field="OrderDate" HeaderText="Order Date" TextAlign="Right" Width="70" Priority="4"  Format="{0:MM/dd/yyyy}" />
                    <ej:Column Field="Freight" HeaderText="Freight" TextAlign="Right" Width="85" Format="{0:C}" Priority="3" />
                    <ej:Column Field="ShipName" HeaderText="Ship Name" Width="110"  />
                    <ej:Column Field="ShipCity" HeaderText="Ship City" Priority="2" Width="90" />
                   <ej:Column Field="ShipCountry" HeaderText="Ship Country" Width="90" />
                 </Columns>
                <StackedHeaderRows>
                   <ej:StackedHeaderRow>
                       <StackedHeaderColumns>
                            <ej:StackedHeaderColumn Column="OrderID,OrderDate,Freight" HeaderText="Order Details" />
                            <ej:StackedHeaderColumn Column="ShipName,ShipCity,ShipCountry" HeaderText="Ship Details" />
                        </StackedHeaderColumns>
                    </ej:StackedHeaderRow>
                </StackedHeaderRows>
            </ej:Grid>
        </div>
    </asp:Content>
    
    
    
    using Syncfusion.EJ.Export;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Syncfusion.XlsIO;
    using System.Collections;
    
    namespace WebSampleBrowser.Grid
    {
        public partial class ExcelExporting : System.Web.UI.Page
        {
            List<Orders> order = new List<Orders>();
            protected void Page_Load(object sender, EventArgs e)
            {
                BindDataSource();
            }
            private void BindDataSource()
            {
                int code = 10000;
                for (int i = 1; i < 10; i++)
                {
                    order.Add(new Orders(code + 1, new DateTime(1991, 05, 15), 2.3 * i, "Vins et alcoos Chevalier", "Berlin", "Argentina"));
                    order.Add(new Orders(code + 2, new DateTime(1990, 04, 04), 3.3 * i, "Toms spezialitatean", "Madrid", "Autria"));
                    order.Add(new Orders(code + 3, new DateTime(1957, 11, 30), 4.3 * i, "Hanari Carnes", "Cholchester", "Austria"));
                    order.Add(new Orders(code + 4, new DateTime(1930, 10, 22), 5.3 * i, "Victuailles en stock" , "Marseille", "Argentina"));
                    order.Add(new Orders(code + 5, new DateTime(1953, 02, 18), 6.3 * i, "Supremes delices", "Tsawassen", "Argentina"));
                    code += 5;
                }
                this.FlatGrid.DataSource = order;
                this.FlatGrid.DataBind();
            }
    
            [Serializable]
            public class Orders
            {
                public Orders()
                {
    
                }
               public Orders(long OrderId, DateTime OrderDate, double Freight, string ShipName, string ShipCity, string ShipCountry)
                {
                     this.OrderID = OrderId;
                    this.OrderDate = OrderDate;
                    this.Freight = Freight;
                    this.ShipName = ShipName;
                    this.ShipCity = ShipCity;
                    this.ShipCountry = ShipCountry;
                }
                public long OrderID { get; set; }
                public DateTime OrderDate { get; set; }
                public double Freight { get; set; }
                public string ShipName { get; set; }
                public string ShipCity { get; set; }
                public string ShipCountry { get; set; }
            }
    
            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");
            }
    
            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");
            }
    
            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");
            }
        }
    }