-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyDocumentPreviewControl.cs
38 lines (34 loc) · 1.5 KB
/
MyDocumentPreviewControl.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.Xpf.Printing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.XtraPrinting;
using DevExpress.Xpf.Printing.PreviewControl;
using System.IO;
using DevExpress.XtraPrinting.Native.ExportOptionsControllers;
namespace MinimalisticReportPreviewDemo {
public class MyDocumentPreviewControl : DocumentPreviewControl {
public override void Export(ExportFormat? format) {
if(format.HasValue && format.Value == ExportFormat.Xls) {
var optionsModel = ExportOptionsViewModel.Create(Document.PrintingSystem, format.Value);
optionsModel.OpenFileAfterExport = false;
optionsModel.FileName = "test.xls";
new DocumentPublishEngine(Document.PrintingSystem).Export(optionsModel);
System.Windows.MessageBox.Show("!");
System.Diagnostics.Process.Start("test.xls");
} else {
base.Export(format);
}
}
protected override void Export(ExportOptionsViewModel exportOptionsModel) {
if(string.IsNullOrEmpty(Path.GetExtension(exportOptionsModel.FileName))) {
var extension = ExportOptionsControllerBase
.GetControllerByOptions(exportOptionsModel.ExportOptions)
.GetFileExtension(exportOptionsModel.ExportOptions);
exportOptionsModel.FileName += extension;
}
base.Export(exportOptionsModel);
}
}
}