views:

106

answers:

1

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

+1  A: 

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);
Gordon
Thanks for your reply your code is right. But while adding this code i got the error "java.lang.IllegalArgumentException: adding a window to a container"This code works properly JFrame j = viewer;But it opens a new JFrame window. Is there any possible option to add that in panel. Thanks in advance.
Samurai