2005 IR Help Posted August 26, 2006 Share Posted August 26, 2006 By: sunnf - sunnf subreport with custom data source is error 2004-05-27 01:57 only run subreport ,it is ok. but run master report,second page data of subreport display error. show it here: http://bbs.wan-bo.com/UploadFile/200452716584149614.jpg By: sunnf - sunnf RE: subreport with custom data source is error 2004-05-28 03:48 any idea!!! By: sunnf - sunnf cdeal . can you help me? 2004-05-31 17:58 I do not know how i do. By: C-Box - c-box RE: subreport with custom data source is error 2004-05-31 22:57 Just post a bit more (precisely)... out of your JPG I can't read how you designed/compiled/filled your report. C-Box By: sunnf - sunnf RE: subreport with custom data source is error 2004-06-01 19:03 my custom data source class: package wj_XunLian.bean; import dori.jasper.engine.*; public class XL_t_030_002_12PrintCustomDS implements JRDataSource{ public XL_t_030_002_12PrintCustomDS() { } /*下面的操作是把一些数据组织起来,按照打印的格式组成数组,如果数据量大,对性能的影响我没有进行测试 QuFen在QuFenLine="a"时画线。NianDuXunLianChenJi在NianDuXunLianChenJiLine="1"画线。 XunLianDengJiPingDing在XunLianDengJiPingDingLine="1"时画线。 这个只是一个简单的例子,在实际中要从数据库中或其他的方式,按下面的格式组织数据。 */ private Object[][] data = { {"区分1","0", "课目1", "85", "250","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分1","0", "课目2", "59", "277","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分1","0", "课目3", "67", "339","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分1","0", "课目4", "87", "358","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分1","a", "课目5", "79", "202","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分2","0", "课目1", "75", "250","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分2","0", "课目2", "97", "277","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分2","0", "课目3", "87", "339","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分2","0", "课目4", "38", "358","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分2","a", "课目5", "96", "202","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分3","0", "课目1", "49", "250","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分3","0", "课目2", "47", "277","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分3","0", "课目3", "71", "339","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分3","0", "课目4", "78", "358","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分3","a", "课目5", "49", "202","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分4","0", "课目1", "46", "250","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分4","0", "课目2", "52", "277","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分4","0", "课目3", "72", "339","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分4","0", "课目4", "82", "358","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分4","0", "课目1", "46", "250","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分4","0", "课目2", "52", "277","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分4","0", "课目3", "72", "339","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分4","0", "课目4", "82", "358","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分4","0", "课目2", "52", "277","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分4","0", "课目3", "72", "339","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分4","0", "课目4", "82", "358","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分4","0", "课目1", "46", "250","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分4","0", "课目2", "52", "277","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分5","0", "课目3", "72", "339","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分5","0", "课目4", "82", "358","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分5","0", "课目2", "52", "277","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分5","0", "课目3", "72", "339","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分5","0", "课目4", "82", "358","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分5","a", "课目1", "46", "250","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分6","0", "课目2", "52", "277","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分6","0", "课目3", "72", "339","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分6","0", "课目4", "82", "358","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分6","0", "课目2", "52", "277","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分6","a", "课目3", "72", "339","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分7","0", "课目4", "82", "358","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分7","0", "课目1", "46", "250","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分7","0", "课目2", "52", "277","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分7","0", "课目3", "72", "339","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分7","0", "课目4", "82", "358","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分7","0", "课目2", "52", "277","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分7","0", "课目3", "72", "339","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分7","a", "课目4", "82", "358","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分8","0", "课目1", "46", "250","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分8","0", "课目2", "52", "277","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分8","0", "课目3", "72", "339","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分8","0", "课目4", "82", "358","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分8","0", "课目2", "52", "277","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分8","0", "课目3", "72", "339","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分8","0", "课目4", "82", "358","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分8","0", "课目1", "46", "250","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分8","a", "课目2", "52", "277","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分9","0", "课目3", "72", "339","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分9","0", "课目4", "82", "358","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分9","0", "课目2", "52", "277","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分9","0", "课目3", "72", "339","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分9","0", "课目4", "82", "358","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分9","0", "课目1", "46", "250","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分9","0", "课目2", "52", "277","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分9","0", "课目3", "72", "339","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分9","0", "课目4", "82", "358","102","0","训练等级评定","0","优秀教员","0","89","0"}, {"区分9","a", "课目5", "93", "202","102","1","训练等级评定","1","优秀教员","1","89","1"} //{"-1","-1", "-1", "-1", "-1","-1","-1","-1","-1","-1","-1","-1","-1"} }; private int index = -1; /** * */ public boolean next() throws JRException { index++; return (index < data.length); } /** *下面的是字字段的格式,如同select QuFen,QuFenLine,KeMu ,.... from table_name,在custom datasource中没有 * 表名这个概念。 * */ public Object getFieldValue(JRField field) throws JRException { Object value = null; String fieldName = field.getName(); if ("QuFen".equals(fieldName)) { value = data[index][0]; } else if ("QuFenLine".equals(fieldName)) { value = data[index][1]; } else if ("KeMu".equals(fieldName)) { value = data[index][2]; } else if ("LiangNianZhi".equals(fieldName)) { value = data[index][3]; } else if ("SiNianZhi".equals(fieldName)) { value = data[index][4]; } else if ("NianDuXunLianChenJi".equals(fieldName)) { value = data[index][5]; } else if ("NianDuXunLianChenJiLine".equals(fieldName)) { value = data[index][6]; } else if ("XunLianDengJiPingDing".equals(fieldName)) { value = data[index][7]; } else if ("XunLianDengJiPingDingLine".equals(fieldName)) { value = data[index][8]; } else if ("YuXiuJiaoYuan".equals(fieldName)) { value = data[index][9]; } else if ("YuXiuJiaoYuanLine".equals(fieldName)) { value = data[index][10]; } else if ("BiWuJingSai".equals(fieldName)) { value = data[index][11]; } else if ("BiWuJingSaiLine".equals(fieldName)) { value = data[index][12]; } return value; } //return data source for ireport to design public static dori.jasper.engine.JRDataSource getXL_t_030_002_12PrintCustomDS( ) { return new XL_t_030_002_12PrintCustomDS(); } } compile and copy XL_t_030_002_12PrintCustomDS.class to iReport0.2.3/classes/classes/wj_XunLian/bean/ folder my subreport: connect properties tab: type of connection/datasoure->CustomJRDSource Factory class->wj_XunLian.bean.XL_t_030_002_12PrintCustomDS The static method to call retrive the JRDataSource->getXL_t_030_002_12PrintCustomDS only run subreport is ok!!! my masterreport: Subreport tab: Connection/DataSource Expression->Use Datasource expression input:new wj_XunLian.bean.XL_t_030_002_12PrintCustomDS() now run masterreport: deplay error.look at it here: http://bbs.wan-bo.com/UploadFile/2004621051126119.jpg By: C-Box - c-box RE: subreport with custom data source is error 2004-06-01 23:21 Well, What DataSource do you use for filling MasterReport? Is it the same like you use for your SubReport? And how many times a subreport will called? Once for each MasterReport-Record? Or do you just use the MasterReport for dummygroups and better layout-management? I wouldn't create everytime a new instance of your "XL_t_030_002_12PrintCustomDS" with all your data... everytime the MasterReport calls the SubReport a new instance is created and all the data come again that the previous call of your subreport already listed. Is this what you want? Or do you want to filter out some records by the subreport that do match some criteria given by the masterreports current record? C-Box By: sunnf - sunnf RE: subreport with custom data source is error 2004-06-02 17:10 my masterreport only one recorder,and masterreport using an empty datasource.in application : jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,new dori.jasper.engine.JREmptyDataSource()); By: sunnf - sunnf RE: subreport with custom data source is error 2004-06-05 02:14 c-box, help me!!! By: C-Box - c-box RE: subreport with custom data source is error 2004-06-06 22:56 Well, I can't say more, that you should downgrade your report to a simple design containing one MasterReport with just one SubReport and pass your DataSource and your compiled subreport as parameter when filling your mastereport. So I would try these steps: 1.) load MasterReport from XML/InputStream 2.) load SubReport from XML/InputStream 3.) compile MasterReport to a JasperReport-Object 4.) compile SubReport to a JasperReport-Object 5.) fill your JRBeanDataSource for your SubReport (or whatever model you like) into a JRDataSource-Object 6.) put the JRDataSource-Object and your compiled SubReport into a parameter-HashMap 7.) fill your MasterReport-Object with parameter-HashMap and an empty DataSource (JREmptyDataSource) in your XML-desgin you should have two paratemers - one e.g. "paraSubReport" and one e.g. "paraDataSource" and in the DataSourceExpression you should enter the $P{paraDataSource} and in the SubReportExpression you should enter the $P{paraSubReport} and that should work. Also note, that the SubReport is opaque and has the same papersize as the MasterReport and that the margins are ok. Some people here encountered problems with the defined sizes and overlaying some bands when page breaks etc. - you could search the forum for it. more I can't say - sorry hth C-Box By: sunnf - sunnf RE: subreport with custom data source is error 2004-06-07 02:09 sorry! my error! in my masterreport,subreport->common->top=3,display error! but top=2,display ok!!!! subreport ->common->bands->detail. I do not know why ? By: sunnf - sunnf RE: subreport with custom data source is error 2004-06-07 02:22 Thank c-box for reply my answer very much !!!! By: C-Box - c-box RE: subreport with custom data source is error 2004-06-07 03:59 never mind, does it work now? C-Box By: sunnf - sunnf RE: subreport with custom data source is error 2004-06-07 21:24 Yes! it work very well! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now