如何使用 Eclipse RCP 的打印选项打印 jasper 报告?

发布于 2024-12-20 23:18:12 字数 307 浏览 1 评论 0原文

我的问题:我在 Eclipse RCP 应用程序中有一个 ViewerComposite,它显示集成到其中的 Jasper Report (*.jrxml)。此 ViewerComposite 中显示的报告可以导出为 PDF、RTF、XML、jrxml、HTML、CSV 等。一切都很好,除了我无法使用 GUI 中 ViewerComposite 顶部提供的打印选项打印此报告。如何使用报告查看器的打印选项使用默认打印机打印报告。 Rem:我可以使用 Oracle JDeveloper 项目中 jasper 报告查看器组合的打印选项来打印 jasper 报告,而无需添加任何更多代码(默认情况下)。

My question : I have a ViewerComposite in Eclipse RCP application which displays Jasper Report (*.jrxml) integrated into it. The report displayed in this ViewerComposite can be exported as PDF,RTF,XML,jrxml,HTML,CSV, etc. Everything is fine except I can not print this report by using the print option provided at top of ViewerComposite in GUI. How can I print the reports by using my default printer by using print option of the report viewer.
Rem: I can print jasper report by using the print option of jasper report viewer composite in Oracle JDeveloper Projects without adding any more codes(by default).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初心未许 2024-12-27 23:18:12

对我来说,在 Eclipse RCP 应用程序中制作 Jasper Reports 的最佳方法如下:

  1. 用 SWT/AWT 复合和 JRViewer (net.sf.jasperreports.view) 替换 ViewerComposite(即 com.jasperassistant.designer.viewer.ViewerComposite.ViewerComposite) .JRViewer)首先。
  2. 将生成的 JasperPrint 文档设置到 JRViewer 对象上。
  3. 将 JRViewer 对象添加到此 SWT/AWT 组合的 ContentPane 上。
  4. 运行报告并检查打印并将报告数据导出为允许的格式,即(.PDF、.ODT、.docx、.jrxml、.jasper、< /em>.xml、.html、.xls 等);一切都会奏效。

详细代码如下:

//generate the jaspser print document
JasperPrint jprint = generateReport(id, nepFromDate, nepToDate);

//initialize JRViewer object 
JRViewer jasperviewer = new JRViewer(jprint);

//add the SWT_AWT compposite for SWING contents of GUI              
final Composite swtAwtComposite = new Composite(comTBReport, SWT.EMBEDDED);
swtAwtComposite.setBounds(10, 0, 767, 600);

Frame frame = SWT_AWT.new_Frame(swtAwtComposite);

Panel panel = new Panel();
frame.add(panel);
panel.setLayout(new BorderLayout(0, 0));

JRootPane rootPane = new JRootPane();
rootPane.setSize(767, 600);
panel.add(rootPane);

//Define a container yourself
Container c = rootPane.getContentPane();

//Add the JRViewer object onto the container to render in GUI
c.add(jasperviewer);

The best way for me to make my Jasper Reports in Eclipse RCP application was as follows :

  1. replace the ViewerComposite (i.e. com.jasperassistant.designer.viewer.ViewerComposite.ViewerComposite) by SWT/AWT composite and JRViewer (net.sf.jasperreports.view.JRViewer) first.
  2. set the generated JasperPrint document onto the JRViewer object.
  3. add the JRViewer object onto the ContentPane of this SWT/AWT composite.
  4. run the report and check printing and exporting the report data into allowed formats ie.(.PDF,.ODT,.docx,.jrxml,.jasper,.xml,.html,.xls etc); all will work.

The details code for this is as follows :

//generate the jaspser print document
JasperPrint jprint = generateReport(id, nepFromDate, nepToDate);

//initialize JRViewer object 
JRViewer jasperviewer = new JRViewer(jprint);

//add the SWT_AWT compposite for SWING contents of GUI              
final Composite swtAwtComposite = new Composite(comTBReport, SWT.EMBEDDED);
swtAwtComposite.setBounds(10, 0, 767, 600);

Frame frame = SWT_AWT.new_Frame(swtAwtComposite);

Panel panel = new Panel();
frame.add(panel);
panel.setLayout(new BorderLayout(0, 0));

JRootPane rootPane = new JRootPane();
rootPane.setSize(767, 600);
panel.add(rootPane);

//Define a container yourself
Container c = rootPane.getContentPane();

//Add the JRViewer object onto the container to render in GUI
c.add(jasperviewer);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文