<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    大夢想家

    5年開發工程師,2年實施經理,X年售前顧問,......
    數據加載中……
    EclipseRCP打印表格
    ??? 做過RCP項目的朋友應該都遇到過打印的問題,在C/S構架中打印應該是最麻煩的事情。SWT提供的打印功能很簡單,特別是在做表格打印的時候,需要大家使用GC自己繪出來,才能打印,對于初級的開發人員和人力不足的公司來說是非常麻煩的事情。
    ?? 還好ceclipse.org的老大yipsilon zheng貢獻出了一個SWT表格打印的項目,可以做到不同表格的直接打印,而且還有跨行跨列的實現,我改造了一下(把項目做了個轉碼utf-8==》GBK),然后打成JAR包放上來給大家使用。
    ?1package?com.glnpu.dmp.client.platform.core.internal.util;
    ?2
    ?3import?org.ceclipse.reporting.IReport;
    ?4import?org.ceclipse.reporting.IReportPage;
    ?5import?org.ceclipse.reporting.Report;
    ?6import?org.ceclipse.reporting.ReportData;
    ?7import?org.ceclipse.reporting.ReportUtil;
    ?8import?org.eclipse.nebula.widgets.grid.Grid;
    ?9import?org.eclipse.swt.printing.PrintDialog;
    10import?org.eclipse.swt.printing.Printer;
    11import?org.eclipse.swt.widgets.Table;
    12import?org.eclipse.ui.PlatformUI;
    13
    14/**
    15?*?通用表格打印組件,目前提供兩個方法分別用于打印表格(Gird,Table);
    16?*?工作任務名:printContent
    17?*?@author?lign
    18?*
    19?*/

    20public?class?PrintContent?{
    21
    22????/**
    23?????*?對Gird進行打印操作
    24?????*?@param?grid?SWT?的nebula項目的Grid
    25?????*?@param?title?表頭文字描述
    26?????*/

    27????public?static?void?printGird(Grid?grid,?String?title)?{
    28????????IReportPage?page?=?ReportUtil.convert(grid,?title);
    29????????Report?report?=?new?Report();
    30????????report.addPage(page);
    31????????printToPrinter(report);
    32????????
    33????}

    34????
    35????/**
    36?????*?對Table進行打印操作
    37?????*?@param?table?SWT?的Table
    38?????*?@param?title?表頭文字描述
    39?????*/

    40????public?static?void?printTable(Table?table,?String?title)?{
    41????????IReportPage?page?=?ReportUtil.convert(table,?title);
    42????????Report?report?=?new?Report();
    43????????report.addPage(page);
    44????????printToPrinter(report);
    45????????
    46????}

    47????
    48????/**
    49?????*?處理打印以及調用Printer
    50?????*?@param?report
    51?????*/

    52????private?static?void?printToPrinter(IReport?report)?{
    53?????????ReportData?reportData?=?report.getReportData();
    54?????????reportData.setJobName("printContent");
    55?????????reportData.setPrinter(new?Printer(new?PrintDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()).open()));
    56?????????report.print();
    57????}

    58}

    59
    我封裝了兩個方法,一個方法處理SWT提供的Table的打印,另一個處理SWT-星云(Nebula)-Gird的打印,基本上滿足我的需要了。
    Jar下載:
    http://m.tkk7.com/Files/leeguannan/org.ceclipse.printer_1.0.rar

    客戶虐我千百遍,我待客戶如初戀!

    posted on 2007-07-20 16:21 阿南 閱讀(3094) 評論(7)  編輯  收藏 所屬分類: Eclipse-RCP西安java用戶群

    評論

    # re: EclipseRCP打印表格 2007-07-24 10:04 阿源

    請問有沒有附帶源碼呢? 我想預覽一下,調用report.preview();出錯的。
      回復  更多評論    

    # re: EclipseRCP打印表格 2007-10-01 12:09 李世虎

    我的信息表格
      回復  更多評論    

    # re: EclipseRCP打印表格 2008-01-23 21:34 winner

    org.eclipse.nebula.widgets.grid.Grid;這個JAR哪兒下載呀,程序老報錯。源碼傳上來看看呀
      回復  更多評論    

    # re: EclipseRCP打印表格 2008-05-28 09:32 求助

    我想用utf-8的老大能給我個嗎

    luiguangshui@163.com
      回復  更多評論    

    # re: EclipseRCP打印表格 2008-07-07 17:50 huangdan

    IReportPage page = ReportUtil.convert(grid, title);
    convert(grid, title)這個方法出錯了,怎么改?
    怎么樣使用這個類來進行打印呀?
    謝謝!!!
      回復  更多評論    

    # re: EclipseRCP打印表格 2008-07-21 23:49 何敏··

    謝謝大家把你們的資源共享。
    hemin108@126.com
      回復  更多評論    

    # re: EclipseRCP打印表格 2010-10-11 16:36 zmh

    博主你好,我在調用打印表格的方法時出現如下錯誤:Exception in thread "main" java.lang.IllegalStateException: Workbench has not been created yet.
    at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
    at com.ytkj.kq.print.PrintContent.printToPrinter(PrintContent.java:55)
    at com.ytkj.kq.print.PrintContent.printTable(PrintContent.java:44)
    at com.ytkj.kq.PersonnelData.PersonnelChange$6.widgetSelected(PersonnelChange.java:404)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
    at com.ytkj.kq.PersonnelData.PersonnelChange.open(PersonnelChange.java:139)
    at com.ytkj.kq.Main$14.widgetSelected(Main.java:852)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
    at com.ytkj.kq.Main.<init>(Main.java:278)
    at com.ytkj.kq.Main.main(Main.java:243)

    能幫忙解決一下嗎,希望能將解決方法發到小弟的郵箱:lqmh18@163.com
    在此先謝過了
      回復  更多評論    
    主站蜘蛛池模板: 国产日产亚洲系列| 大胆亚洲人体视频| 亚洲综合在线成人一区| a毛看片免费观看视频| 亚洲精品国自产拍在线观看| 亚洲AV综合色区无码一二三区| 好吊妞998视频免费观看在线| 亚洲va精品中文字幕| 扒开双腿猛进入爽爽免费视频| 亚洲国产韩国一区二区| 可以免费看黄的网站| 日韩亚洲产在线观看| 四虎成人免费影院网址| 久久综合亚洲色hezyo| 免费国产真实迷j在线观看| 精品在线观看免费| 综合久久久久久中文字幕亚洲国产国产综合一区首 | 曰批全过程免费视频播放网站| 久久久久亚洲AV片无码下载蜜桃 | 亚洲国产区男人本色在线观看| 中文字幕无码视频手机免费看 | 亚洲中文字幕无码久久精品1| 三年片在线观看免费| 久久久久亚洲精品无码蜜桃| 免费毛片a在线观看67194| 亚洲欧美黑人猛交群| 亚洲国产天堂久久久久久| 国产一区二区三区免费| 亚洲福利电影在线观看| 在线播放免费人成视频在线观看| 国产亚洲视频在线观看| 精品亚洲综合在线第一区| 亚洲视频在线观看免费视频| 亚洲精品av无码喷奶水糖心| 亚洲综合AV在线在线播放| 久久精品一本到99热免费| 久久精品国产亚洲AV| 亚洲成av人片在线观看无码不卡| 日韩版码免费福利视频| 一级做a爰片性色毛片免费网站| 久久亚洲精品国产精品黑人|