Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Collapse]Spreadsheet
   [Expand]Product Information
    Product Structure
    Getting Started
   [Expand]Spreadsheet Document
    Supported Formats
   [Expand]Cell Basics
   [Expand]Spreadsheet Formulas
    Defined Names
    Data Binding
    Data Validation
   [Expand]Data Presentation
    Data Grouping
   [Expand]Pivot Table Overview
   [Expand]Charting Overview
    Printing
    Events
   [Expand]Mail Merge Overview
    Protection
    Find and Replace
   [Expand]Visual Elements
    Services
   [Expand]Shortcuts
   [Collapse]Examples
    [Expand]Files
    [Expand]Workbooks
    [Expand]Worksheets
    [Expand]Rows and Columns
    [Expand]Cells
    [Expand]Formulas
    [Collapse]Import and Export Data
      How to: Import Data to a Worksheet
      How to: Export a Worksheet Range to a DataTable
      How to: Use a Custom Converter for Export to a DataTable
    [Expand]Data Binding
    [Expand]Mail Merge
    [Expand]Formatting Cells
    [Expand]Conditional Formatting
    [Expand]Group Data
    [Expand]Filter Data
    [Expand]Tables
    [Expand]Pivot Tables
    [Expand]Printing
    [Expand]Pictures
    [Expand]Charts
    [Expand]Protection
    [Expand]Customization
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  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]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Import Data to a Worksheet

You can import data to worksheet cells from different data sources (for example, arrays, lists and data tables) via the worksheet's Import extension method.

Important

Worksheet extensions are defined by the WorksheetExtensions class. To enable them, add a reference to the DevExpress.Docs.v17.2.dll library and explicitly import the DevExpress.Spreadsheet namespace into your source code with a using directive (Imports in Visual Basic).

Pass the following parameters to the WorksheetExtensions.Import method.

  • An object that specifies a source for importing data.
  • Row and column indexes of the start cell in which you wish to insert imported data into the worksheet.
  • A Boolean value specifying whether to insert imported data vertically or horizontally. Use this parameter when importing data from a one-dimensional array or list.

Expanded Import Data from Arrays

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E4751.

The image below shows the results.

Expanded Import Data from a List

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E4751.

The image below shows the results.

Expanded Import Data from a DataTable

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E4751.

The following code illustrates how to import data from a System.Data.DataTable object to a worksheet. Note that the cell data types are set automatically, according to the data types of the source column. Cell formats are set automatically to the default value for the cell data type. However, you can easily change them, as described in the How to: Specify Number or Date Format for Cell Content topic.

The image below shows the results.

Tip

To import data into a worksheet, you can bind a read-only data source as described in the How to Bind a Spreadsheet to a List of Objects document and subsequently remove the binding using the WorksheetDataBindingCollection.Remove or WorksheetDataBindingCollection.Clear method.

How would you rate this topic?​​​​​​​