[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Expand]Controls and Libraries
 [Collapse]Common Features
  [Collapse]Data Binding Common Concepts
    How to: Bind GridControl to Database and Implement Master-Detail Mode at Design Time
    How to: Bind a Control to a Database at Runtime
    How to: Bind a Control to Data Created at Runtime
    How to: Bind a Control to Data in an XML File
    Traditional Data Binding Methods
    Data Source Configuration Wizard
    Data Binding Mechanism in ADO.NET
    Binding Controls to XML Data
    Binding Controls to Data Created at Runtime
    Add Unbound Data to a Data-Aware Control (XtraGrid, XtraPivotGrid)
    Binding to Excel Data Sources
    Binding to LINQ to SQL Classes
    Unbound Sources
    Binding to Entity Framework Core
    Binding to OData
    Bind to JSON Data
    Bind to XPO Data
    Bind to Azure SQL Database
    Binding to SQL Data
    Data Annotation Attributes
    How to: Add Virtual Rows Using the UnboundSource Component
    Obtaining Fields Available in Data Source
  [Expand]Data Source Wizard
  [Expand]Application Appearance and Skin Colors
  [Expand]Filtering UI Context
   Find Panel Syntax
  [Expand]Graphics Performance and High DPI
  [Expand]Scaffolding Wizard
  [Expand]Formatting Values
   HTML-inspired Text Formatting
  [Expand]Save and Restore Layouts
   Clipboard - Copy and Paste Operations. Data Formatting
   Version Compatibility: Default Property Values
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Binding to Excel Data Sources

This document illustrates how to bind to data from Microsoft Excel workbooks (XLS, XLSX or XLSM files) or CSV files using the Data Source Configuration Wizard, the ExcelDataSource component and in code.

Expanded Data Source Configuration Wizard

  1. Invoke the smart tag for the required data-aware DevExpress control and select the 'Data Source Wizard' option.

  2. On the wizard main page, select the 'Excel Data Source' option. Click 'New Data Source' to create a new data source or select the required data source from the list, then click 'Next' to proceed.

  3. Select the required data source and set advanced options using the Data Source Wizard. The following gallery illustrates this process.

  4. Click finish and run the application to see the result.

Expanded The ExcelDataSource Component

Using the ExcelDataSource component, you can provide data from Excel data sources for any data-aware control that does not support the Data Source Configuration Wizard.

  1. Locate the ExcelDataSource component on the toolbox under the 'Data&Analytics' group and drop it onto your form.

  2. When you add the ExcelDataSource component to an application form, the 'Data Source Wizard' dialog automatically pops up. Follow these steps to set up the connection. To invoke this wizard manually, use the component's smart-tag as shown below.

  3. Assign the customized ExcelDataSource component as the data source for the target control. For instance, for the Data Grid control, use the GridControl.DataSource property.

  4. The ExcelDataSource component does not retrieve records automatically. Thus, to populate your data control, call the Fill (see ExcelDataSource.Fill) or FillAsync (see ExcelDataSource.FillAsync) method.

Expanded Binding in Code

  1. Create a new instance of the ExcelDataSource component.

  2. Use the ExcelDataSource.FileName or ExcelDataSource.Stream properties to supply the component with a data source from a local storage or stream.

  3. Depending on the data source type (Excel workbook or CSV file), create either a ExcelSourceOptions or CsvSourceOptions object. Using this object's properties, you can specify a cell range to be loaded. Assign the object created to the ExcelDataSource.SourceOptions property.


    You must provide the ExcelWorksheetSettings, ExcelTableSettings or ExcelDefinedNameSettings objects for each ExcelSourceOptions class instance.

  4. Set additional import options if required.

  5. Assign your ExcelDataSource to the data-aware control and call the component's Fill/FillAsync method to populate it with records.

    The complete code is listed below.

Is this topic helpful?​​​​​​​