[GridFeatures.aspx]
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<ej:Grid ID="Grid1" AllowPaging="True" DataSourceID="SqlData" AllowSorting="True" Width="900px" OnServerWordExporting="FlatGrid_ServerWordExporting" OnServerPdfExporting="FlatGrid_ServerPdfExporting"
OnServerExcelExporting="FlatGrid_ServerExcelExporting"
runat="server">
<Columns>
<ej:Column DataType="number" Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" TextAlign="Right" Width="90" />
<ej:Column DataType="number" Field="EmployeeID" ForeignKeyField="EmployeeID" ForeignKeyValue="FirstName" HeaderText="Employee ID" TextAlign="Right" Width="110" />
...
</Columns>
...
</ej:Grid>
<asp:SqlDataSource ID="SqlData" runat="server" ConnectionString="<%$ ConnectionStrings:SQLConnectionString %>"
SelectCommand="SELECT * FROM [Orders]"></asp:SqlDataSource>
...
</asp:Content>
[GridFeatures.aspx.vb]
Imports System.Collections
Imports System.Collections.Generic
...
Imports Syncfusion.XlsIO
Imports Syncfusion.EJ.Export //it is must to refer
Protected Sub FlatGrid_ServerExcelExporting(sender As Object, e As Syncfusion.JavaScript.Web.GridEventArgs)
Dim exp As New ExcelExport()
Dim data As DataView = CType(SqlData.Select(New DataSourceSelectArguments()), DataView)
Dim dt As DataTable = data.Table
exp.Export(Grid1.Model, dt, "Export.xlsx", ExcelVersion.Excel2010, True, True, _
"flat-lime")
End Sub |