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

howudodat

Members
  • Posts

    5
  • Joined

  • Last visited

howudodat'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. Unfortunately I do not see any page breaks in the sub-report nor in the main report
  2. I have a simple report with an embedded sub-report. The outer loop produces 5 entries and the sub report produces 5 entries that are split across 2 pages. This should produce a 10 page report. However I am getting 11 pages with the first page being just the outer report, with the detail blank. Any ideas? Below is a simple Java function and the two reports Peter Code:Java: protected void tryReport() { try { List<HashMap<String, Object>> clientlist = new ArrayList<HashMap<String, Object>>(); for (int x = 0; x<5; x++) { HashMap<String, Object>row = new HashMap<String, Object>(); row.put("Client", "Client Name"+x); row.put("rep", "Peter"); row.put("assistant", "Helper"); // insert sub report here List<HashMap<String, Object>>homeslist = new ArrayList<HashMap<String, Object>>(); for (int y = 0; y<5; y++) { HashMap<String, Object>rowHome = new HashMap<String, Object>(); rowHome.put("facility", "facility name"+y); rowHome.put("website", "its url"); rowHome.put("address", "12345 Main String MyTown, MS 12345"); homeslist.add(rowHome); } row.put("subrpt", new JRMapArrayDataSource(homeslist.toArray())); clientlist.add(row); } JRMapArrayDataSource dsClients = new JRMapArrayDataSource(clientlist.toArray()); JasperPrint jasperPrint = JasperFillManager.fillReport("reports/client_referral.jasper", new HashMap(), dsClients); JasperViewer jv = new JasperViewer(jasperPrint); jv.setVisible(true); } catch (Exception e) { e.printStackTrace(); System.exit(1); } }client_referral:<?xml version="1.0" encoding="UTF-8"?><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="DbReportDS" pageWidth="612" pageHeight="791" columnWidth="572" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <field name="Client" class="java.lang.String"/> <field name="rep" class="java.lang.String"/> <field name="assistant" class="java.lang.String"/> <field name="facility" class="java.lang.String"/> <field name="website" class="java.lang.String"/> <field name="address" class="java.lang.String"/> <field name="notes" class="java.lang.String"/> <field name="subrpt" class="net.sf.jasperreports.engine.data.JRMapArrayDataSource"/> <pageHeader> <band height="102"> <textField> <reportElement x="1" y="35" width="100" height="20"/> <textElement> <font size="14" isBold="true"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{Client}]]></textFieldExpression> </textField> <textField> <reportElement x="45" y="55" width="100" height="20"/> <textElement verticalAlignment="Bottom"> <font isBold="true"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{rep}]]></textFieldExpression> </textField> <textField> <reportElement x="88" y="73" width="100" height="20"/> <textElement verticalAlignment="Bottom"> <font isBold="true"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{assistant}]]></textFieldExpression> </textField> <staticText> <reportElement x="16" y="59" width="26" height="16"/> <textElement verticalAlignment="Bottom"> <font isBold="true"/> </textElement> <text><![CDATA[Rep:]]></text> </staticText> <staticText> <reportElement x="34" y="77" width="52" height="16"/> <textElement verticalAlignment="Bottom"> <font isBold="true"/> </textElement> <text><![CDATA[Assistant:]]></text> </staticText> </band> </pageHeader> <detail> <band height="172" splitType="Prevent"> <subreport> <reportElement positionType="Float" x="1" y="0" width="571" height="169" isPrintWhenDetailOverflows="true"/> <dataSourceExpression><![CDATA[$F{subrpt}]]></dataSourceExpression> <subreportExpression class="java.lang.String"><![CDATA["client_referral_s1.jasper"]]></subreportExpression> </subreport> </band> </detail></jasperReport>client_referral_s1:<?xml version="1.0" encoding="UTF-8"?><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="DbReportDS" pageWidth="612" pageHeight="791" columnWidth="612" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <field name="Client" class="java.lang.String"/> <field name="rep" class="java.lang.String"/> <field name="assistant" class="java.lang.String"/> <field name="facility" class="java.lang.String"/> <field name="website" class="java.lang.String"/> <field name="address" class="java.lang.String"/> <field name="notes" class="java.lang.String"/> <field name="subrpt" class="net.sf.jasperreports.engine.data.JRMapArrayDataSource"/> <detail> <band height="164" splitType="Prevent"> <textField> <reportElement x="1" y="15" width="234" height="20"/> <textElement verticalAlignment="Bottom"> <font size="14" isBold="true"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{facility}]]></textFieldExpression> </textField> <textField> <reportElement x="470" y="15" width="100" height="20"/> <textElement verticalAlignment="Bottom"/> <textFieldExpression class="java.lang.String"><![CDATA[$F{website}]]></textFieldExpression> </textField> <textField> <reportElement x="16" y="35" width="362" height="15"/> <textElement verticalAlignment="Bottom"> <font isBold="true"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{address}]]></textFieldExpression> </textField> <textField> <reportElement x="173" y="61" width="397" height="93"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{notes}]]></textFieldExpression> </textField> </band> </detail></jasperReport>
  3. Perfect. Here is the final code I used: Peter Code: <style name="strike"> <conditionalStyle> <conditionExpression> $F{telephone}.indexOf( "!" ) == 0 ? Boolean.TRUE : Boolean.FALSE </conditionExpression> <style isStrikeThrough="true" /> </conditionalStyle> </style>
  4. I have a field $F{Telephone} if the first char of the field is a '!' I want the field to be displayed with strikethrough font and trim the '!' so: 111-222-3333 would print as is !444-555-6666 would print as 444-555-6666 (underline = strikethrough) Not sure how to set that up Peter
  5. I am really struggling trying to get my head around this subreport. I've got both reports working independantly and can't get them hooked together. The basic idea is a panel that allows a user to select N number of people, and for each person select from a table the information they want displayed. To simulate this I built this simple set of maps: String [] clients = new String[] {"Peter", "Bob", "Alice", "Sue", "Tom" };Vector<HashMap<String, String>>contacts = new Vector<HashMap<String, String>>();Vector< HashMap<String, String>>contactinfo = new Vector<HashMap<String, String>>();for (int x=0; x<5; x++) { HashMap<String, String>row = new HashMap<String, String>(); row.put("id", ""+x); row.put("name", clients[x]); contacts.add(row); String [] strs = new String[] {"phone", "fax", "email" }; for (String s : strs) { HashMap<String, String>rowi = new HashMap<String, String>(); rowi.put("client", ""+x); rowi.put("info", s+" for client:"+clients[x]); contactinfo.add(rowi); }} Each of the rwo reports load fine independantly: 1: list of contact names 2: list of contact info I can embed the sub report, but how do I link the contact 'id' with the contactinfo 'client' field? Also can the xml of a sub report be embedded directly, or does it need to be in its own file and the file be referenced with: <subreportExpression class="java.lang.String"><![CDATA["reports/srptContactInfo.jasper"]]> Peter Code:Main Report: <field name="name" class="java.lang.String"/> <pageHeader> <band height="60"> <staticText> <reportElement x="0" y="0" width="112" height="24"/> <textElement verticalAlignment="Bottom"/> <text><![CDATA[Name:]]></text> </staticText> <textField> <reportElement x="112" y="10" width="372" height="14"/> <textElement textAlignment="Center"> <font isBold="true"/> </textElement> <textFieldExpression class="java.lang.String"><![CDATA[$F{name}]]></textFieldExpression> </textField> </band> </pageHeader> <detail> <band height="505"> <subreport> <reportElement x="0" y="0" width="572" height="505"/> <subreportParameter name="state"> <subreportParameterExpression> <![CDATA[$P{client}]]> </subreportParameterExpression> </subreportParameter> <subreportExpression class="java.lang.String"><![CDATA["reports/srptContactInfo.jasper"]]></subreportExpression> </subreport> </band> </detail>SubReport: <field name="info" class="java.lang.String"/> <columnHeader> <band height="25"> <staticText> <reportElement x="0" y="0" width="112" height="24"/> <textElement verticalAlignment="Bottom"/> <text><![CDATA[info:]]></text> </staticText> </band> </columnHeader> <detail> <band height="30"> <textField> <reportElement x="0" y="0" width="100" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{info}]]></textFieldExpression> </textField> </band> </detail>
×
×
  • Create New...