如何使用XtraReport将报表导出为PDF

 我来答
百度网友4d3212ddb5e
2016-07-25 · TA获得超过3575个赞
知道大有可为答主
回答量:2955
采纳率:93%
帮助的人:507万
展开全部
首先需要在项目中新建一个报表(命名为XtraReport1)。还请注意,如果您希望用于打开系统中*.pdf文件的默认程序自动打开生成的文件,你可以调用StartProcess方法,示例中也有展示。
using System.Diagnostics;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
// ...

private void button1_Click(object sender, EventArgs e)
{
// A path to export a report.
string reportPath = "c:\\Test.pdf";

// Create a report instance.
XtraReport1 report = new XtraReport1();

// Get its PDF export options.
PdfExportOptions pdfOptions = report.ExportOptions.Pdf;

// Set PDF-specific export options.
pdfOptions.Compressed = true;
pdfOptions.ImageQuality = PdfJpegImageQuality.Low;
pdfOptions.NeverEmbeddedFonts = "Tahoma;Courier New";
pdfOptions.DocumentOptions.Application = "Test Application";
pdfOptions.DocumentOptions.Author = "DX Documentation Team";
pdfOptions.DocumentOptions.Keywords = "XtraReports, XtraPrinting";
pdfOptions.DocumentOptions.Subject = "Test Subject";
pdfOptions.DocumentOptions.Title = "Test Title";

// Set the pages to be exported.
pdfOptions.PageRange = "1, 3-5";

// Export the report to PDF.
report.ExportToPdf(reportPath);

// Show the result.
StartProcess(reportPath);
}

// Use this method if you want to automaically open
// the created PDF file in the default program.
public void StartProcess(string path)
{
Process process = new Process();
try
{
process.StartInfo.FileName = path;
process.Start();
process.WaitForInputIdle();
}
catch { }
}

Imports System.Diagnostics
Imports DevExpress.XtraPrinting
Imports DevExpress.XtraReports.UI
' ...

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
' A path to export a report.
Dim reportPath As String = "c:\\Test.pdf"

' Create a report instance.
Dim report As New XtraReport1()

' Get its PDF export options.
Dim pdfOptions As PdfExportOptions = report.ExportOptions.Pdf

' Set PDF-specific export options.
pdfOptions.Compressed = True
pdfOptions.ImageQuality = PdfJpegImageQuality.Low
pdfOptions.NeverEmbeddedFonts = "Tahoma;Courier New"
pdfOptions.DocumentOptions.Application = "Test Application"
pdfOptions.DocumentOptions.Author = "DX Documentation Team"
pdfOptions.DocumentOptions.Keywords = "XtraReports, XtraPrinting"
pdfOptions.DocumentOptions.Subject = "Test Subject"
pdfOptions.DocumentOptions.Title = "Test Title"

' Set the pages to be exported.
pdfOptions.PageRange = "1, 3-5"

' Export the report to PDF.
report.ExportToPdf(reportPath)

' Show the result.
StartProcess(reportPath)
End Sub

' Use this method if you want to automaically open
' the created PDF file in the default program.
Public Sub StartProcess(ByVal path As String)
Dim process As New Process()
Try
process.StartInfo.FileName = path
process.Start()
process.WaitForInputIdle()
Catch
End Try
End Sub
博思aippt
2024-07-20 广告
作为深圳市博思云创科技有限公司的工作人员,对于Word文档生成PPT的操作,我们有以下建议:1. 使用另存为功能:在Word中编辑完文档后,点击文件->另存为,选择PowerPoint演示文稿(*.pptx)格式,即可将文档内容转换为PPT... 点击进入详情页
本回答由博思aippt提供
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式