开发者

Passing multiple parameters using single input control in JasperServer

I have created jasper report in ireport. I am trying to execute it using jasper server. I want to pass two input parameters to report using single Input Control. This input control is a drop down. It has 开发者_JAVA技巧text and Id. I want to pass both id as well as text to report. Is there any way I can achieve this??


In order to create a report with input parameters you have to pass them through a HashMap. This is where you put any number of values you like and pass them to JasperReport:

        HashMap<String, Object> map = new HashMap<String, Object>();
        map.put("shopName", shopName);
        map.put("month", Integer.parseInt(jComboBox2.getSelectedItem().toString()));
        map.put("Value2", jComboBox2.getSelectedIndex());

        URL reportFileURL = getClass().getResource("../ireports/MyReport.jrxml");
        File reportFile = new File(reportFileURL.toURI());
        JasperDesign jasperDesign = JRXmlLoader.load(reportFile);
        JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
        JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, map, con);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜