2011-05-31 77 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(); 

     } 
    }