This repository has been archived by the owner on Jun 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
43 lines (37 loc) · 1.64 KB
/
Form1.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Imports DevExpress.DashboardCommon
Imports DevExpress.DataAccess.Excel
Imports DevExpress.XtraEditors
Imports System
Namespace Dashboard_CustomExtractDriver
Partial Public Class Form1
Inherits XtraForm
Private Const extractFileNamePattern As String = """Extract_""yyyyMMddHHmmssfff"".dat"""
Public Sub New()
InitializeComponent()
ExtractDriverStorage.DefaultDriver = New ExtractEncryptionDriver()
Dim extractDataSource As New DashboardExtractDataSource()
extractDataSource.ExtractSourceOptions.DataSource = CreateExcelDataSource()
extractDataSource.FileName = Date.Now.ToString(extractFileNamePattern)
extractDataSource.UpdateExtractFile()
dashboardViewer1.Dashboard = CreateDashboard(extractDataSource)
End Sub
Private Shared Function CreateDashboard(ByVal extractDataSource As DashboardExtractDataSource) As Dashboard
Dim dashboard As New Dashboard()
dashboard.DataSources.Add(extractDataSource)
Dim pivot As New PivotDashboardItem()
pivot.DataSource = extractDataSource
pivot.Values.AddRange(New Measure("Extended Price"), New Measure("Quantity"))
pivot.Columns.Add(New Dimension("OrderDate", DateTimeGroupInterval.Year))
pivot.Rows.Add(New Dimension("ProductName"))
dashboard.Items.Add(pivot)
Return dashboard
End Function
Private Shared Function CreateExcelDataSource() As DashboardExcelDataSource
Dim excelDataSource As New DashboardExcelDataSource() With {
.FileName = "Data\SalesPerson.xlsx", .SourceOptions = New ExcelSourceOptions() With {.ImportSettings = New ExcelWorksheetSettings("Data")}
}
excelDataSource.Fill()
Return excelDataSource
End Function
End Class
End Namespace