专业网站建设品牌,十四年专业建站经验,服务6000+客户--广州京杭网络
免费热线:400-683-0016      微信咨询  |  联系我们

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

当前位置:网站建设 > 技术支持
资料来源:网络整理       时间:2023/3/9 2:01:27       共计:3560 浏览

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

首先需要在项目中新建一个报表(命名为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

版权说明:
本网站凡注明“广州京杭 原创”的皆为本站原创文章,如需转载请注明出处!
本网转载皆注明出处,遵循行业规范,如发现作品内容版权或其它问题的,请与我们联系处理!
欢迎扫描右侧微信二维码与我们联系。
·上一条:如何用python爬取知网论文数据_java | ·下一条:如何将json数据生成json文件格式_java

Copyright © 广州京杭网络科技有限公司 2005-2025 版权所有    粤ICP备16019765号 

广州京杭网络科技有限公司 版权所有