New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Export Multiple Grids



Order IDOrder DateFreightShip NameShip Country
Page size:
 798 items in 266 pages
102798/13/1996 12:00:00 AM25.83Lehmanns MarktstandGermany
102808/14/1996 12:00:00 AM8.98Berglunds snabbköpSweden
102838/16/1996 12:00:00 AM84.81LILA-SupermercadoVenezuela

Customer IDContact NameCompany NameContact TitleCountry
Page size:
 91 items in 31 pages
ALFKIMaria AndersAlfreds FutterkisteSales RepresentativeGermany
ANATRAna TrujilloAna Trujillo Emparedados y heladosOwnerMexico
ANTONAntonio MorenoAntonio Moreno TaqueríaOwnerMexico

Product IDProduct NameSupplier IDCategory IDUnit Price
Page size:
 68 items in 23 pages
11Queso Cabrales5421.00
12Queso Manchego La Pastora5438.00
13Konbu686.00

This is a practical demonstration of the new overload, introduced in R1 2021, of the GenerateXlsxOutput() overload method provided by the grid. It can be utilized further for different scenarios where you need the Excel XLSX output even without actually exporting anything.

  • DefaultVB.aspx
  • DefaultVB.aspx.vb
<%@ Page Language="vb" AutoEventWireup="false" Inherits="Telerik.GridExamplesCSharp.Exporting.ExportToExcel.DefaultVB"CodeFile="DefaultVB.aspx.vb"  %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container no-bg">
    <telerik:RadButton RenderMode="Lightweight" ID="RadButton1" runat="server" Text="Export All Grids"
        Height="30px" OnClick="RadButton1_Click">
        <Icon PrimaryIconCssClass="p-i-file-xlsx"></Icon>
    </telerik:RadButton>
    <br />
    <br />
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" CellSpacing="0"
        DataSourceID="SqlDataSource1" GridLines="None" PageSize="3" 
        OnColumnCreated="RadGrids_ColumnCreated">
        <ExportSettings IgnorePaging="true" ExportOnlyData="true">
            <Excel Format="Xlsx" WorksheetName="Orders" AutoFitColumnWidth="AutoFitExpandOnly" />
        </ExportSettings>
        <MasterTableView DataSourceID="SqlDataSource1" DataKeyNames="OrderID">
        </MasterTableView>
    </telerik:RadGrid>
    <br />
    <telerik:RadGrid ID="RadGrid2" runat="server" AllowPaging="True" CellSpacing="0"
        DataSourceID="SqlDataSource2" GridLines="None" PageSize="3"
        OnColumnCreated="RadGrids_ColumnCreated">
        <ExportSettings IgnorePaging="true" ExportOnlyData="true">
            <Excel Format="Xlsx" WorksheetName="Customers" AutoFitColumnWidth="AutoFitExpandOnly" />
        </ExportSettings>
        <MasterTableView DataSourceID="SqlDataSource2" DataKeyNames="CustomerID">
        </MasterTableView>
    </telerik:RadGrid>
    <br />
    <telerik:RadGrid ID="RadGrid3" runat="server" AllowPaging="True" CellSpacing="0"
        DataSourceID="SqlDataSource3" GridLines="None" PageSize="3"
        OnColumnCreated="RadGrids_ColumnCreated">
        <ExportSettings IgnorePaging="true" ExportOnlyData="true">
            <Excel Format="Xlsx" WorksheetName="Products" AutoFitColumnWidth="AutoFitExpandOnly" />
        </ExportSettings>
        <MasterTableView DataSourceID="SqlDataSource3" DataKeyNames="ProductID">
        </MasterTableView>
    </telerik:RadGrid>
        </div>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT [OrderID], [OrderDate], [Freight], [ShipName], [ShipCountry] FROM [Orders]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server"
        ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT [CustomerID], [ContactName], [CompanyName], [ContactTitle], [Country] FROM [Customers]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server"
        ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT [ProductID], [ProductName], [SupplierID], [CategoryID], [UnitPrice] FROM [Products]"></asp:SqlDataSource>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance