-
Notifications
You must be signed in to change notification settings - Fork 0
/
Code.vb
50 lines (42 loc) · 1.69 KB
/
Code.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
44
45
46
47
48
49
50
Imports DevExpress.DataAccess.Excel
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Namespace ExcelDataSourceSnippets
Public Class Code
Private Sub ExcelDataSourceBindingToCSV()
' Create a new Excel data source.
Dim excelDataSource As New ExcelDataSource()
excelDataSource.FileName = "Northwind.csv"
' Specify import settings.
Dim csvSourceOptions As New CsvSourceOptions()
csvSourceOptions.DetectEncoding = True
csvSourceOptions.DetectNewlineType = True
csvSourceOptions.DetectValueSeparator = True
excelDataSource.SourceOptions = csvSourceOptions
End Sub
Private Sub ExcelDataSourceBindingToXLS()
' Create a new Excel data source.
Dim excelDataSource As New ExcelDataSource()
excelDataSource.FileName = "Northwind.xlsx"
' Select a required worksheet.
Dim excelWorksheetSettings As New ExcelWorksheetSettings()
excelWorksheetSettings.WorksheetName = "Sheet_Categories"
' Specify import settings.
Dim excelSourceOptions As New ExcelSourceOptions()
excelSourceOptions.ImportSettings = excelWorksheetSettings
excelSourceOptions.SkipHiddenRows = False
excelSourceOptions.SkipHiddenColumns = False
excelDataSource.SourceOptions = excelSourceOptions
End Sub
Public Shared Function CreateExcelDataSource() As ExcelDataSource
Dim excelDataSource = New ExcelDataSource() With {.Name = "Excel_Products"}
excelDataSource.FileName = "Products.xlsx"
excelDataSource.SourceOptions = New ExcelSourceOptions() With {.ImportSettings = New ExcelWorksheetSettings("Sheet")}
excelDataSource.RebuildResultSchema()
Return excelDataSource
End Function
End Class
End Namespace