[英]How to integrate JRViewer in Eclipse RCP
我有一個 RCP 應用程序,它運行良好......直到現在。
我要升級一些讀寫xlsm和xlsx文件的模塊,所以我升級了poi。
但它打破了我的 JasperReport 報告,版本很舊,2.0.3,所以我也嘗試升級到 6.1.0,其中包含我需要的 poi 版本。
但我不能讓它在 viewpart 內工作。
這就是它現在的樣子,使用 jasperreports2.0.3
導出/另存為按鈕不起作用,出現以下錯誤:
net.sf.jasperreports.engine.JRPrintHyperlink.getHyperlinkType()
用谷歌搜索,我得到了升級和使用 JRViewer 的提示。
我試圖遵循這個問題: 如何使用其打印選項在 Eclipse RCP 中打印 jasper 報告? 但我沒有得到它的工作。
有人可以給我一些線索嗎?
我知道了! ... 修改 CreatePartControl...
public void createPartControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FillLayout(SWT.HORIZONTAL));
//viewerComposite = new ViewerComposite(container,SWT.BORDER);
//viewerComposite.setLayoutData(new GridData(GridData.FILL,GridData.FILL,true,true));
//desde aca
//add the SWT_AWT compposite for SWING contents of GUI
final Composite swtAwtComposite = new Composite(container, 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
c = rootPane.getContentPane();
super.setPartName("Reportes");
}
我從其他視圖傳遞 JasperPrint 對象,所以我創建了一個 void 方法......
public void setJasperPrint(JasperPrint jrPrint){
this.jrPrint = jrPrint;
//
jasperviewer = new JRViewer(jrPrint);
//Add the JRViewer object onto the container to render in GUI
c.add(jasperviewer);
}
奇跡般有效!
新造型! 但它有效!
此致
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.