package com.easyway.tbs.commons.ext.views.printer;
import org.ceclipse.reporting.IReport;
import org.ceclipse.reporting.IReportPage;
import org.ceclipse.reporting.Report;
import org.ceclipse.reporting.ReportData;
import org.ceclipse.reporting.ReportUtil;
import org.eclipse.nebula.widgets.grid.Grid;
import org.eclipse.swt.printing.PrintDialog;
import org.eclipse.swt.printing.Printer;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.PlatformUI;
/**
* 采用网上流传的ceclipse.org的组件
* 通用的表格打印组件,目前提供两个方法分别用于打印表格(Grid,Table)
* 我封装了两个方法,一个方法处理SWT提供的Table的打印,另一个处理SWT-星云(Nebula)-Gird的打印,
* 基本上满足我的需要了。贡献出了一个SWT表格打印的项目,可以做到不同表格的直接打印,而且还有跨行跨列的实现.
* Jar下载:
* http://www.blogjava.net/Files/leeguannan/org.ceclipse.printer_1.0.rar
*
* @author longgangbai
*
*/
public class PrintTools {
/**
* 对SWT Table进行打印的操纵
* @param table SWT Table 的对象
* @param title 表头文字描述
*/
public static void printTable(Table table, String title) {
IReportPage page = ReportUtil.convert(table, title);
Report report = new Report();
report.addPage(page);
printToPrinter(report);
}
/**
* 对SWT Gird进行打印的操纵
* @param gird SWT Gird 的对象
* @param title 表头文字描述
*/
public static void printGird(Grid grid, String title) {
IReportPage page = ReportUtil.convert(grid, title);
Report report = new Report();
report.addPage(page);
printToPrinter(report);
printToPrinter(report);
}
/**
* 处理打印以及调用Printer
*@param report
*/
private static void printToPrinter(IReport report) {
ReportData reportData = report.getReportData();
reportData.setJobName("printContent");
reportData.setPrinter(new Printer(new PrintDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell()).open()));
report.print();
}
}
局限性:这个功能在打印的table或者Grid使用滚动条,但滚动条没有出现时打印正常。如果数据过多在表格中不能完全显示那么就不能满足了,最终采用报表工具实现打印报表功能。
相关推荐
eclipse rcp check table
Eclipse+RCP+打印表格,谢谢支持
以前做swt项目的资料,希望多刚接触rcp的朋友有所帮助
一个用RCP实现的CRM例子,包括源码。
基于适配器模式的RCP应用属性视图实现,在做RCP或者Eclipse插件开发的朋友可以用到的,关于如何自定义属性栏信息
RCP与GEF的课件,简单的介绍了RCP和GEF中的各组件的功能,已经工作流程
本系统适用于所有用户,无管理员设置,可以创建多个网络邮箱帐号,可以编辑、接收和发送邮件等,不仅支持文本文件的发送与接收,还支持带附件邮件的发送与接收,支持抄送,还具有通讯录的存储功能。本系统在开发过程...
Eclipse rcp 实现文本内容对比功能,可自己选取对比的文件进行比较
简单地讲, 一个RCP应用就是一个可独立于Eclispe IDE开发环境运行的Eclipse 插件. 下面我们以一个简单的例子开始我们的RCP旅程.
实现数据库与RCP表格的连接,把数据库上的内容映射到表格中
Eclipse表格打印的相关代码。可以打印Table和Grid等。
clipse RCP允许开发者使用eclipse结构风格设计...将涉及以下内容:创建第一个RCP程序,创建菜单和工具栏,查看,编辑,对话,外部JAR的用法,向一个RCP应用程序产品中添加标志和帮助。 每一章可能都基本独立于其他章节
将涉及以下内容:创建第一个RCP程序,创建菜单和工具栏,查看,编辑,对话,外部JAR的用法,向一个RCP应用程序产品中添加标志和帮助。每一章都基本独立于其他章节。欢迎访问我的网站——www.xeclipse.com。
这就是对RCP实现在线升级的说明,实现导出RCP查品,制作升级网站。
Rcp一个简单的入门教程 从一个实例讲解
RCP&OSGI;
NULL 博文链接:https://itssff-yahoo-cn.iteye.com/blog/1030375
一个很好的RCP开发实例,仅供初学者参考!
RCP在线升级RCP在线升级RCP在线升级RCP在线升级RCP在线升级
Eclipse Rich Client Platform (RCP) 的目标是在各种不是集成开发环境 (IDE) 的最终用户应用程序中使用 Eclipse。随着 Eclipse V3.1 的发布,创建 RCP 应用程序变得...本教程将指导您一步步创建自己的 RCP 应用程序。