Jump to content
We've recently updated our Privacy Statement, available here ×

essaghir.bouchra

Members
  • Posts

    4
  • Joined

  • Last visited

essaghir.bouchra's Achievements

Rookie

Rookie (2/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. Hello, Try adding isRemoveLineWhenBlank="true" in the report element of the subreport like this: <reportElement isRemoveLineWhenBlank="true" x="0" y="30" width="555" height="40" uuid="746e05bc-ff80-45b1-9093-762398715789"> Hope it helps.
  2. Hello, I'm writing a java program which is supposed to generate a jasperreport. It uses subreports who have different XPath and when I try to generate it, the contents of the subreport doesn't display and I'm guessing it's because of XML connection to the subreports. I tried to pass the JasperReport as parameter but it didn't work.. So, my question would be how to add the XPath to the subreport and then pass it to the main report ? Thank you, here is my java code: File xmlDataSourceFile = new File ("C:/Users/bessaghi/Documents/Jasper/AirbusDataForReport.xml"); JRXmlDataSource xmlDataSourceXPath_mainReport = new JRXmlDataSource (xmlDataSourceFile, "/request"); JRXmlDataSource xmlDataSourceXPath_subReport_ElectronicDistributionList = new JRXmlDataSource (xmlDataSourceFile, "/request/distributionlist/actor"); /* Compile the template */ JasperReport jasperMainReport = JasperCompileManager.compileReport ("C:/Users/bessaghi/Documents/Jasper/reportNewForm.jrxml"); JasperReport jaspersubReport_ElectronicDistributionList = JasperCompileManager.compileReport ("C:/Users/bessaghi/Documents/Jasper/reportNewForm_subreportElectronicDistributionList.jrxml"); JasperPrint jasperCompiledsubReport_ElectronicDistributionList = JasperFillManager.fillReport (jaspersubReport_ElectronicDistributionList, new HashMap (), xmlDataSourceXPath_subReport_ElectronicDistributionList); JasperExportManager.exportReportToHtmlFile(jasperCompiledsubReport_ElectronicDistributionList, "C:/Users/bessaghi/Documents/Jasper/subReport_ElectronicDistributionList.html"); HashMap parameters = new HashMap (); parameters.put("imageAirbusPath", "C:/Users/bessaghi/JaspersoftWorkspace/MyReports/GTN/Airbus.JPG"); parameters.put("imagesPath", "C:/Users/bessaghi/Documents/Jasper/images/"); /* Create the JasperPrint object with the template and the data */ JasperPrint jasperCompiledReport = JasperFillManager.fillReport (jasperMainReport, parameters, xmlDataSourceXPath_mainReport); /* Export the report to pdf format if needed*/ JasperExportManager.exportReportToHtmlFile(jasperCompiledReport, "C:/Users/bessaghi/Documents/Jasper/MyReport.html"); System.out.println("Done!");
  3. I found the answer, thank you. I just added isRemoveLineWhenBlank="true" in the report element of subreport: The report: <subreport><reportElement x="16" y="153" width="514" height="67" isRemoveLineWhenBlank="true" uuid="188baf76-b389-419c-bdbe-aa441c2a60f3"/><subreportParameter name="SUBREPORT_DIR"><subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression></subreportParameter><subreportParameter name="XML_DATA_DOCUMENT"><subreportParameterExpression><![CDATA[$P{XML_DATA_DOCUMENT}]]></subreportParameterExpression></subreportParameter><dataSourceExpression><![CDATA[(net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}.dataSource("/request/distributionlist/actor")]]></dataSourceExpression><subreportExpression><![CDATA["reportNewForm_subreportElectronicDistributionList.jasper"]]></subreportExpression></subreport>
  4. Hello, I am trying to generate a report using XML data sources. I created a subreport where I want to display an information which works fine. In the main report, I call this subreport and when I execute I got 5 lines as expected but they all show "null" ! The subreport: <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="reportNewForm_subreportElectronicDistributionList" language="groovy" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="b9a625d5-6c7d-4713-b6c4-4bd250a184cd"><property name="ireport.zoom" value="1.0"/><property name="ireport.x" value="0"/><property name="ireport.y" value="0"/><property name="com.jaspersoft.studio.data.defaultdataadapter" value="GTN XML DataSource"/><parameter name="SUBREPORT_DIR" class="java.lang.String"><defaultValueExpression><![CDATA["./"]]></defaultValueExpression></parameter><queryString language="XPath"><![CDATA[/request/distributionlist/actor]]></queryString><field name="name" class="java.lang.String"><fieldDescription><![CDATA[name]]></fieldDescription></field><field name="department" class="java.lang.String"><fieldDescription><![CDATA[department]]></fieldDescription></field><background><band splitType="Stretch"/></background><title><band splitType="Stretch"/></title><pageHeader><band splitType="Stretch"/></pageHeader><columnHeader><band splitType="Stretch"/></columnHeader><detail><band height="15" splitType="Stretch"><property name="com.jaspersoft.studio.unit.height" value="pixel"/><textField><reportElement x="0" y="0" width="554" height="15" uuid="7557e80c-b639-4dd7-aa66-777934a7c319"><property name="com.jaspersoft.studio.unit.height" value="pixel"/></reportElement><textFieldExpression><![CDATA[$F{name}]]></textFieldExpression></textField></band></detail><columnFooter><band splitType="Stretch"/></columnFooter><pageFooter><band splitType="Stretch"/></pageFooter><summary><band splitType="Stretch"/></summary></jasperReport>The report: <subreport> <reportElement x="16" y="153" width="514" height="67" uuid="188baf76-b389-419c-bdbe-aa441c2a60f3"/> <subreportParameter name="XML_DATA_DOCUMENT"><subreportParameterExpression><![CDATA[$P{XML_DATA_DOCUMENT}]]></subreportParameterExpression></subreportParameter><dataSourceExpression><![CDATA[(net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}.dataSource("/request/distributionlist/actor")]]></dataSourceExpression><subreportExpression><![CDATA["reportNewForm_subreportElectronicDistributionList.jasper"]]></subreportExpression></subreport>The XML: <request> <distributionlist> <actor id="0"> <name>Fabien</name> <department>dep</department> </actor> <actor id="1"> <name>Eric</name> <department>dep</department> </actor> <actor id="2"> <name>Sebastien</name> <department>dep2</department> </actor> <actor id="3"> <name>David</name> <department>dep</department> </actor> <actor id="4"> <name>Mickel</name> <department>dep</department> </actor> </distributionlist></request> Thank you for your help.
×
×
  • Create New...