-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.xaml.cs
36 lines (34 loc) · 1.25 KB
/
MainWindow.xaml.cs
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
using DevExpress.Spreadsheet;
using System;
using System.Globalization;
using System.Windows;
namespace WpfSpreadsheet_DataBinding
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
spreadsheet.Options.Culture = new CultureInfo("en-US");
spreadsheet.LoadDocument(@"Documents/Expenses_template.xlsx", DocumentFormat.Xlsx);
}
void spreadsheet_DocumentLoaded(object sender, EventArgs e)
{
#region #BindGridToSpreadsheetTable
IWorkbook workbook = spreadsheet.Document;
Worksheet worksheet = workbook.Worksheets[0];
// Access the table on the worksheet.
Table expensesTable = worksheet.Tables[0];
// Specify the data source settings.
RangeDataSourceOptions options = new RangeDataSourceOptions();
options.PreserveFormulas = true;
options.SkipHiddenRows = true;
// Bind the grid control to the table data.
grid.ItemsSource = expensesTable.DataRange.GetDataSource(options);
#endregion #BindGridToSpreadsheetTable
}
}
}