下面的示例演示了如何使用 XtraReport.ExportOptions 属性,来指定在打印预览期间导出报表时的所有选项。 注意,在本例中,报表被静默导出,而不对最终用户作出任何提示。
C# | 复制代码 |
---|
(Form1.cs)
using System;
using System.Windows.Forms;
using System.Text;
using System.Globalization;
using System.Drawing.Imaging;
using DevExpress.XtraPrinting;
namespace ExportOpts {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) {
XtraReport1 report = new XtraReport1();
report.CreateDocument();
PrintingSystemBase printingSystem1 = report.PrintingSystem;
ExportOptions options = printingSystem1.ExportOptions;
options.PrintPreview.ActionAfterExport = ActionAfterExport.AskUser;
options.PrintPreview.DefaultDirectory = "C:\\Temp";
options.PrintPreview.DefaultFileName = "Report";
options.PrintPreview.SaveMode = SaveMode.UsingDefaultPath;
options.PrintPreview.ShowOptionsBeforeExport = false;
options.Email.RecipientAddress = "someone@somewhere.com";
options.Email.RecipientName = "Someone";
options.Email.Subject = "Test";
options.Email.Body = "Test";
options.Csv.Encoding = Encoding.Unicode;
options.Csv.Separator =
CultureInfo.CurrentCulture.TextInfo.ListSeparator.ToString();
options.Html.CharacterSet = "UTF-8";
options.Html.RemoveSecondarySymbols = false;
options.Html.Title = "Test Title";
options.Image.Format = ImageFormat.Jpeg;
options.Mht.CharacterSet = "UTF-8";
options.Mht.RemoveSecondarySymbols = false;
options.Mht.Title = "Test Title";
options.Pdf.Compressed = true;
options.Pdf.ImageQuality = PdfJpegImageQuality.Low;
options.Pdf.NeverEmbeddedFonts = "Tahoma;Courier New";
options.Pdf.DocumentOptions.Application = "Test Application";
options.Pdf.DocumentOptions.Author = "Test Team";
options.Pdf.DocumentOptions.Keywords = "Test1, Test2";
options.Pdf.DocumentOptions.Subject = "Test Subject";
options.Pdf.DocumentOptions.Title = "Test Title";
options.Text.Encoding = Encoding.Unicode;
options.Text.Separator =
CultureInfo.CurrentCulture.TextInfo.ListSeparator.ToString();
options.Xls.ShowGridLines = true;
options.Xls.SheetName = "Page 1";
options.Xls.TextExportMode = TextExportMode.Value;
options.Xlsx.ShowGridLines = true;
options.Xlsx.SheetName = "Page 1";
options.Xlsx.TextExportMode = TextExportMode.Value;
report.ShowPreviewDialog();
}
}
}
|
Visual Basic | 复制代码 |
---|
(Form1.vb)
Imports Microsoft.VisualBasic
Imports System
Imports System.Windows.Forms
Imports System.Text
Imports System.Globalization
Imports System.Drawing.Imaging
Imports DevExpress.XtraPrinting
Namespace ExportOpts
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
Dim report As New XtraReport1()
report.CreateDocument()
Dim printingSystem1 As PrintingSystem = report.PrintingSystem
Dim options As ExportOptions = printingSystem1.ExportOptions
options.PrintPreview.ActionAfterExport = ActionAfterExport.AskUser
options.PrintPreview.DefaultDirectory = "C:\Temp"
options.PrintPreview.DefaultFileName = "Report"
options.PrintPreview.SaveMode = SaveMode.UsingDefaultPath
options.PrintPreview.ShowOptionsBeforeExport = False
options.Email.RecipientAddress = "someone@somewhere.com"
options.Email.RecipientName = "Someone"
options.Email.Subject = "Test"
options.Email.Body = "Test"
options.Csv.Encoding = Encoding.Unicode
options.Csv.Separator = CultureInfo.CurrentCulture.TextInfo.ListSeparator.ToString()
options.Html.CharacterSet = "UTF-8"
options.Html.RemoveSecondarySymbols = False
options.Html.Title = "Test Title"
options.Image.Format = ImageFormat.Jpeg
options.Mht.CharacterSet = "UTF-8"
options.Mht.RemoveSecondarySymbols = False
options.Mht.Title = "Test Title"
options.Pdf.Compressed = True
options.Pdf.ImageQuality = PdfJpegImageQuality.Low
options.Pdf.NeverEmbeddedFonts = "Tahoma;Courier New"
options.Pdf.DocumentOptions.Application = "Test Application"
options.Pdf.DocumentOptions.Author = "Test Team"
options.Pdf.DocumentOptions.Keywords = "Test1, Test2"
options.Pdf.DocumentOptions.Subject = "Test Subject"
options.Pdf.DocumentOptions.Title = "Test Title"
options.Text.Encoding = Encoding.Unicode
options.Text.Separator = CultureInfo.CurrentCulture.TextInfo.ListSeparator.ToString()
options.Xls.ShowGridLines = True
options.Xls.SheetName = "Page 1"
options.Xls.TextExportMode = TextExportMode.Value
options.Xlsx.ShowGridLines = True
options.Xlsx.SheetName = "Page 1"
options.Xlsx.TextExportMode = TextExportMode.Value
printingSystem1.PreviewFormEx.ShowDialog()
End Sub
End Class
End Namespace
|
参阅