Back to Devexpress

Binding to CSV Files

dashboard-114768-winforms-dashboard-winforms-designer-create-dashboards-in-the-winforms-designer-providing-data-excel-data-source-binding-to-csv-files.md

latest3.9 KB
Original Source

Binding to CSV Files

  • Sep 24, 2025
  • 4 minutes to read

The Dashboard Designer allows you to select data from CSV files. You can select all data from the file or you can select the required cell range using Data Access API.

Creating a Data Source in the Data Source Wizard

To bind a dashboard to a CSV file, do the following.

  1. Click the New Data Source button in the Data Source ribbon tab.

  2. On the first page of the invoked Data Source Wizard dialog, specify whether you want to use an existing data connection or create a new data connection.

  3. On the next page, select the Microsoft Excel workbook / CSV file and click Next.

  4. On the next page, locate the required CSV file by clicking the ellipsis button and selecting the file.

  5. Then, specify import settings used to extract data from the CSV file.

  6. On the final page, you can select columns to be included to a data source and specify their settings. The Name column allows you to specify the column name while Type allows you to specify its type.

Creating a Data Source in Code

The DashboardExcelDataSource class allows you to extract data from Microsoft Excel workbooks (XLS, XLSX or XLSM) or CSV files stored on the disk or stream.

To extract data from the specified workbook or CSV file, do the following.

Finally, add the created DashboardExcelDataSource object to the Dashboard.DataSources collection.

The following code snippet shows how to create an Excel data source and select the A1:L100 range of cells from the specified CSV file.

csharp
using DevExpress.DashboardCommon;
using DevExpress.DataAccess.Excel;
// ...
            Dashboard dashboard = new Dashboard();
            DashboardExcelDataSource csvDataSource = new DashboardExcelDataSource();
            csvDataSource.FileName = @"c:\temp\SalesPerson.csv";
            csvDataSource.SourceOptions = new CsvSourceOptions() { CellRange = "A1:L100" };
            csvDataSource.Fill();
            dashboard.DataSources.Add(csvDataSource);
vb
Imports DevExpress.DashboardCommon
Imports DevExpress.DataAccess.Excel
' ...
            Dim dashboard As New Dashboard()
            Dim csvDataSource As New DashboardExcelDataSource()
            csvDataSource.FileName = "c:\temp\SalesPerson.csv"
            csvDataSource.SourceOptions = New CsvSourceOptions() With {.CellRange = "A1:L100"}
            csvDataSource.Fill()
            dashboard.DataSources.Add(csvDataSource)