koolkhel Posted February 20, 2010 Share Posted February 20, 2010 I'm trying to generate report by hand (not by iReport).I have following code:try { Map parameters = new HashMap(); parameters.put("HIBERNATE_SESSION", sessionManager.getSession()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); File sourceFile = new File(waybillPaymentJRXML.getResource().toURL().toURI()); File compiledFile = new File(JRProperties.getProperty(JRProperties.COMPILER_TEMP_DIR) + "/" + sourceFile.getName() + ".jasper"); JasperCompileManager.compileReportToFile(sourceFile.getPath(), compiledFile.getPath()); JasperReport report = (JasperReport) JRLoader.loadObject(compiledFile); JasperPrint actualJasperPrint = JasperFillManager.fillReport(report, parameters); JRAbstractExporter exporter = new JROdtExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, actualJasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos); exporter.exportReport(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); return StreamResponseFactory.getStreamResponse(ResponseType.ODT, bais); } catch (Exception e) { logger.error(e.getMessage()); return null; } }where "waybillPaymentJRXML" is jrxml file with report design. I have it attached.The report has following HQL query:select sum(waybill.passengersTransported * 10) as summary, waybill.driver.name as driverNamefrom Waybill as waybillgroup by waybill.driver.namefields are:<field name="summary" class="java.lang.Long"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="driverName" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field>And when I try to generate this report by this code the column with field "summary" has _no_ data.<textField> <reportElement x="284" y="0" width="124" height="26"/> <textElement> <font fontName="SansSerif" size="12"/> </textElement> <textFieldExpression class="java.lang.Long"><![CDATA[$F{summary}]]></textFieldExpression> </textField>while adjanced filed with driverName is ok.How do I cope with it?iReport 3.7.1 use jasperreports 3.7.1 but in my project this jasperreports version generates just column headers (i have no idea why), so I use jasperreports 3.5.3 -- it does everything ok but that missing column data. preview in iReport is absolutely ok.nothing interesting through log4j.category.net.sf.jasperreports=debugPost Edited by koolkhel at 02/20/2010 12:40 Link to comment Share on other sites More sharing options...
koolkhel Posted February 20, 2010 Author Share Posted February 20, 2010 okay, it was reports fault: it has overlapping text elements.but shouldn't there be a big red warning about this case?And has anyone an idea why could jasperreports 3.7.1 retain only column band of that report while 3.5.3 works ok? 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