-
Notifications
You must be signed in to change notification settings - Fork 1
/
MainWindow.xaml.vb
53 lines (45 loc) · 1.86 KB
/
MainWindow.xaml.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
51
52
53
Imports DevExpress.Spreadsheet
Imports DevExpress.Xpf.NavBar
Imports System
Imports System.Windows
Imports System.Windows.Input
Namespace SpreadsheetControl_WPF_API_Part02
''' <summary>
''' Interaction logic for MainWindow.xaml
''' </summary>
Partial Public Class MainWindow
Inherits Window
Private workbook As IWorkbook
Public Sub New()
InitializeComponent()
' Access a workbook.
workbook = spreadsheetControl1.Document
DataContext = Groups.InitData()
End Sub
Private Sub NavigationPaneView_MouseDoubleClick(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
Dim item As NavBarItem = DirectCast(sender, NavBarViewBase).GetNavBarItem(e)
If item IsNot Nothing Then
Dim example As SpreadsheetExample = TryCast(item.Content, SpreadsheetExample)
If example IsNot Nothing Then
workbook.Options.Culture = System.Globalization.CultureInfo.CurrentCulture
LoadDocumentFromFile()
example.Action()(workbook)
SaveDocumentToFile()
End If
End If
End Sub
' ------------------- Load and Save a Document -------------------
Private Sub LoadDocumentFromFile()
' #Region "#LoadDocumentFromFile"
' Load a workbook from a file.
workbook.LoadDocument("Documents\Document.xlsx", DocumentFormat.OpenXml)
' #End Region ' #LoadDocumentFromFile
End Sub
Private Sub SaveDocumentToFile()
' #Region "#SaveDocumentToFile"
' Save the modified document to a file.
workbook.SaveDocument("Documents\SavedDocument.xlsx", DocumentFormat.OpenXml)
' #End Region ' #SaveDocumentToFile
End Sub
End Class
End Namespace