2011-05-31 76 views

回答

0

如果你想要的是使用iReports,你不需要直接使用NetBeans 7.0。您可以从以下位置下载iReports单机版:http://jasperforge.org/website/ireportwebsite/IR%20Website/ir_download.html?header=project&target=ireport

否则,在加载netbeans 7.0并且已安装iReports插件后,iReports窗口将位于Window菜单下。你应该可以打开它们,并且你的文件可以继续工作。

只要记住要保持您的iReport和JasperServer版本号相同,以使生活更轻松。

0

我可以给你一个示例代码。 您必须在按钮单击事件中调用您的方法。

public void SuppInvoice(String supinvoice){ 
     Connection conn=null; 
     try { 

      conn = Database.con(); 

      JasperDesign jd = JRXmlLoader.load("src\\Reports\\report15.jrxml"); 
      String sql = "select date,pName,name,supinvoice,qty,price from product p,stock s,supplier u where s.pid=p.pid and s.supid=u.supid and s.supinvoice='"+supinvoice+"'"; 
      JRDesignQuery newQuery = new JRDesignQuery(); 
      newQuery.setText(sql); 
      jd.setQuery(newQuery); 
      JasperReport jr = JasperCompileManager.compileReport(jd); 
      JasperPrint jp = JasperFillManager.fillReport(jr, null, conn); 
      JasperViewer.viewReport(jp, false); 


     } catch (ClassNotFoundException | SQLException | JRException e) { 
      JOptionPane.showMessageDialog(null, e); 
      e.printStackTrace(); 

     } 
    }