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

Export to Excel

Employee IDLast NameFirst NameBirth DateHire DateAddressCityCountry
12
Page size:
 9 items in 2 pages
1DavolioNancy12-08-4805/01/1992507 - 20th Ave. E. Apt. 2ASeattleUSA
2FullerAndrew02-19-5208/14/1992908 W. Capital WayTacomaUSA
3LeverlingJanet08-30-6304/01/1992722 Moss Bay Blvd.KirklandUSA
4PeacockMargaret09-19-3705/03/19934110 Old Redmond Rd.RedmondUSA
5BuchananSteven03-04-5510/17/199314 Garrett HillLondonUK
6SuyamaMichael07-02-6310/17/1993Coventry House Miner Rd.LondonUK
7KingRobert05-29-6001/02/1994Edgeham Hollow Winchester WayLondonUK
  • Demo Configurator
  • Column AutoFit mode (XLSX only)Disabled

This is a demonstration of Excel formats supported by RadGrid (HTML, ExcelML and BIFF).They are all based on different standards and specifications so there are differences in the supported features. You can use the external buttons or the built-in button (BIFF format) in the command item to export the grid to Excel. Below you can find a brief description of these three Excel formats.

  • HTML
    This format is based on the Microsoft Office HTML format. It can be styled via both inline CSS and stylesheets.
  • ExcelML
    Based on the Microsoft Office XML speardsheet format. Supports styling through server-side API, compatible with the original specification.
  • BIFF
    Microsoft's binary XLS format is called BIFF. It has a convenient server-side API and is based on the Export Infrastructure which means that you have complete control over the exported content.
  • XLSX
    XLSX format is the latest export format. It is based on the Telerik document processing libraries which allow you to export RadGrid in Excel xlsx format introduced by Microsoft in Excel 2007.

With the R1 2021 release, the Worksheet name of the exported Excel file can be controlled via the ExportSettings-Excel-WorksheetName property. Applicable to all Excel formats except HTML

Another addition to the R1 2021 release is the ExportSettings-Excel-AutoFitColumnWidth property. It is available only for the Xlsx format export and is based on the AutoFitWidth options of the SpreadProcessing Library: RadSpreadProcessing - Auto Fit Columns Width

  • 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>
        <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="Images/Excel_HTML.png"
            OnClick="ImageButton_Click" AlternateText="Html" />
        <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="Images/Excel_ExcelML.png"
            OnClick="ImageButton_Click" AlternateText="ExcelML" />
        <asp:ImageButton ID="ImageButton3" runat="server" ImageUrl="Images/Excel_BIFF.png"
            OnClick="ImageButton_Click" AlternateText="Biff" />
        <asp:ImageButton ID="ImageButton4" runat="server" ImageUrl="Images/Excel_XLSX.png"
            OnClick="ImageButton_Click" AlternateText="Xlsx" />
    </div>
    <div class="demo-container no-bg">
        <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" AllowPaging="true"
            PageSize="7" AutoGenerateColumns="false" OnExcelMLWorkBookCreated="RadGrid1_ExcelMLWorkBookCreated"
            OnItemCreated="RadGrid1_ItemCreated" OnHTMLExporting="RadGrid1_HtmlExporting" OnItemCommand="RadGrid1_ItemCommand"
            OnBiffExporting="RadGrid1_BiffExporting">
            <ExportSettings>
                <Excel WorksheetName="Employees" />
            </ExportSettings>
            <MasterTableView CommandItemDisplay="Top">
                <CommandItemSettings ShowExportToExcelButton="true" ShowAddNewRecordButton="false" ShowRefreshButton="false" />
                <Columns>
                    <telerik:GridBoundColumn DataField="EmployeeID" HeaderText="Employee ID" HeaderStyle-Width="100px">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="LastName" HeaderText="Last Name" HeaderStyle-Width="130px">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="FirstName" HeaderText="First Name" HeaderStyle-Width="130px">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="BirthDate" HeaderText="Birth Date" DataFormatString="{0:MM-dd-yy}"
                        HeaderStyle-Width="140px">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="HireDate" HeaderText="Hire Date" DataFormatString="{0:MM/dd/yyyy}"
                        HeaderStyle-Width="140px">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Address" HeaderText="Address" HeaderStyle-Width="240px">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="City" HeaderText="City" HeaderStyle-Width="100px">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Country" HeaderText="Country">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </div>
    <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT * FROM [Employees]" runat="server"></asp:SqlDataSource>
    <qsf:ConfiguratorPanel ID="ConfiguratorPanel1" runat="server">
        <Views>
            <qsf:View>
                <ul class="fb-group">
                    <li>
                        <asp:CheckBox ID="CheckBox1" runat="server" Text="Ignore paging (exports all pages)"></asp:CheckBox>
                    </li>
                    <li>
                        <asp:CheckBox ID="CheckBox2" runat="server" Text="Apply Custom Styles"></asp:CheckBox>
                    </li>
                    <li>
                        <qsf:TextBox runat="server" ID="tbWorksheetName" EmptyMessage="Enter the name of the worksheet" Label="Worksheet name(Not Applicable to HTML format)"></qsf:TextBox>
                    </li>
                    <li>
                        <qsf:DropDownList runat="server" ID="AutoFitColumnWidthDropDown" Label="Column AutoFit mode (XLSX only)">
                            <Items>
                                <telerik:DropDownListItem Text="Disabled" />
                                <telerik:DropDownListItem Text="AutoFitExpandOnly" />
                                <telerik:DropDownListItem Text="AutoFitAll" />
                                <telerik:DropDownListItem Text="ExpandToFitNumberValuesWidth" />
                            </Items>
                        </qsf:DropDownList>
                    </li>
                </ul>
            </qsf:View>
        </Views>
    </qsf:ConfiguratorPanel>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance