dashboard-devexpress-dot-dashboardcommon-bfa35092.md
A data source used to extract data from Microsoft Excel workbooks or CSV files.
Namespace : DevExpress.DashboardCommon
Assembly : DevExpress.Dashboard.v25.2.Core.dll
NuGet Package : DevExpress.Dashboard.Core
public class DashboardExcelDataSource :
ExcelDataSource,
IDashboardDataSource,
IDashboardComponent,
IComponent,
IDisposable,
ISupportInitialize,
ISupportPrefix,
IDashboardDataSourceInternal,
IFederationDataProvider
Public Class DashboardExcelDataSource
Inherits ExcelDataSource
Implements IDashboardDataSource,
IDashboardComponent,
IComponent,
IDisposable,
ISupportInitialize,
ISupportPrefix,
IDashboardDataSourceInternal,
IFederationDataProvider
The DashboardExcelDataSource class allows you to extract data from Microsoft Excel workbooks (XLS, XLSX or XLSM files) or CSV files stored on the disk or stream.
You can read files from any directory by default. To protect your application, use the AccessSettings class to explicitly specify where data sources can be read from. To accomplish this, configure rules in the DataResources property to restrict file system access to specified folders. You can call the SetRules(IAccessRule[]) method when your application starts to specify rules before a dashboard control sets its rules. The SetRules(IAccessRule[]) method can be called only once at application startup. Otherwise, the method will raise an exception.
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 that gets data from the A1:L100 range of cells located on the Data worksheet in the SalesPerson.xlsx workbook.
using DevExpress.DashboardCommon;
//...
DashboardExcelDataSource excelDataSource = new DashboardExcelDataSource()
{
FileName = "SalesPerson.xlsx",
SourceOptions = new DevExpress.DataAccess.Excel.ExcelSourceOptions(
new DevExpress.DataAccess.Excel.ExcelWorksheetSettings()
{
WorksheetName = "Data",
CellRange = "A1:L100"
}
)
};
excelDataSource.Fill();
Imports DevExpress.DashboardCommon
' ...
Dim excelDataSource As New DashboardExcelDataSource()
excelDataSource.FileName = "SalesPerson.xlsx"
Dim options As New DevExpress.DataAccess.Excel.ExcelSourceOptions()
Dim importSettings = New DevExpress.DataAccess.Excel.ExcelWorksheetSettings()
importSettings.WorksheetName = "Data"
importSettings.CellRange = "A1:L100"
options.ImportSettings = importSettings
excelDataSource.SourceOptions = options
excelDataSource.Fill()
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)
Object MarshalByRefObject Component DataComponentBase ExcelDataSource DashboardExcelDataSource
See Also