62,614
社区成员
发帖
与我相关
我的任务
分享
public class PrintContent {
/** */
/**
* 对Gird进行打印操作
*
* @param grid
* SWT 的nebula项目的Grid
* @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);
}
/** */
/**
* 对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);
}
/** */
/**
* 处理打印以及调用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();
}