JAVA Reporting Tool iReport

2019-04-15 23:47发布

Can we get a reporting page which is like .Net's Crystal report using iReport? That is I need to get the report inside the frame.

1条回答
劳资没心,怎么记你
2楼-- · 2019-04-15 23:56

Assuming you are using Swing, here is an example how to do it.

Edit:

Try getting the JasperViewer container and add that to the main JFrame or JPanel.

Bit of a hack job but it should do the trick.

JasperDesign jd = JRXMLoader.load("FilePath"); 
JasperReport jr = JasperCompileManager.compileReport(jd);
JasperPrint jp = JasperFillManager.fillReport((jr),null,con);
// Create an instance of the JasperViewer instead of using the static call
JasperViewer viewer=new JasperViewer(jp,false);
// Get the viewers container and add that to the main frame or panel
Container container = viewer.getContentPane();
myMainJFrame.add(container);
查看更多
登录 后发表回答