/
MainWindow.xaml.cs
38 lines (35 loc) · 1.34 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
37
38
using DevExpress.Export;
using DevExpress.Export.Xl;
using DevExpress.XtraPrinting;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Windows;
namespace WpfApplication80 {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
ObservableCollection<Item> items = new ObservableCollection<Item>();
for (int i = 1; i < 30; i++) {
items.Add(new Item() { Name = "Name" + i, MinValue = i + 4, MaxValue = i + 10 });
}
grid.ItemsSource = items;
}
private void Button_Click(object sender, RoutedEventArgs e) {
XlsxExportOptionsEx options = new XlsxExportOptionsEx() {
UnboundExpressionExportMode = UnboundExpressionExportMode.AsFormula,
LayoutMode = LayoutMode.Table
};
options.BeforeExportTable += options_BeforeExportTable;
view.ExportToXlsx("Document.xlsx", options);
Process.Start("Document.xlsx");
}
void options_BeforeExportTable(BeforeExportTableEventArgs e) {
e.Table.Style.Name = XlBuiltInTableStyleId.Light4;
}
}
public class Item {
public string Name { get; set; }
public int MinValue { get; set; }
public int MaxValue { get; set; }
}
}