dashboard-114768-winforms-dashboard-winforms-designer-create-dashboards-in-the-winforms-designer-providing-data-excel-data-source-binding-to-csv-files.md
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.
To bind a dashboard to a CSV file, do the following.
Click the New Data Source button in the Data Source ribbon tab.
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.
On the next page, select the Microsoft Excel workbook / CSV file and click Next.
On the next page, locate the required CSV file by clicking the ellipsis button and selecting the file.
Then, specify import settings used to extract data from the CSV file.
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.
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.
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);
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)