开发者

Ireports and netbeans 7.0

I just started using ireports in netbeans 7.开发者_StackOverflow社区0. am wondering how I can open an ireport from a button click! Thank you

Brian


If all you want is to use iReports, you don't need to use netbeans 7.0 directly. You can download the iReports standalone from: http://jasperforge.org/website/ireportwebsite/IR%20Website/ir_download.html?header=project&target=ireport

Otherwise after netbeans 7.0 is loaded and you have installed the plug-in for iReports the iReports windows will be located under the Window menu. You should be able to open them and your files an keep working.

Just remember to keep your iReport and JasperServer version numbers the same to make life easier.


I can give you a sample code. You have to call your method in the button click event.

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();

        }
    } 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜