/
Form1.cs
45 lines (40 loc) · 1.42 KB
/
Form1.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
39
40
41
42
43
44
45
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
using System.Windows.Forms;
using System;
namespace XlsExportExample {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
// Create a report.
XtraReport report = new XtraReport() {
Name = "Report Example",
Bands = {
new DetailBand() {
Controls = {
new XRLabel() {
Text = "Some content goes here...",
}
}
}
}
};
// Specify export options.
XlsExportOptions xlsExportOptions = new XlsExportOptions() {
ExportMode = XlsExportMode.SingleFile,
ShowGridLines = true,
FitToPrintedPageHeight = true
};
// Specify the path for the exported XLS file.
string xlsExportFile =
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) +
@"\Downloads\" +
report.Name +
".xls";
// Export the report.
report.ExportToXls(xlsExportFile, xlsExportOptions);
}
}
}