2001 JI Open Discussion Posted August 17, 2006 Share Posted August 17, 2006 By: Gianluca - potenza Problem with many subreports 2002-10-01 01:27I have a complex report which uses 8 subreports to create the various blocks on the report. Thin to two subreports there are not problems but from third subreport the resulting pdf is completely confused and strange. I've tried the various options in the reportElement for the subreport to work. This is the code: <?xml version="1.0"?> <!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="report_cartella_clinica" pageWidth="595" pageHeight="842" columnWidth="515" columnSpacing="0" leftMargin="40" rightMargin="40" topMargin="50" bottomMargin="25"> <reportFont name="Arial_Normal" isDefault="true" fontName="Arial" size="11" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> <reportFont name="Arial_Bold" isDefault="false" fontName="Arial" size="11" isBold="true" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> <reportFont name="Arial_Italic" isDefault="false" fontName="Arial" size="11" isItalic="true" pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1252" isPdfEmbedded="false"/> <parameter name="CUSTOM_CONNECTION" class="java.sql.Connection"/> . . . <title> <band height="95"> <!-- ################# Logo ################# --> <image scaleImage="FillFrame"> <reportElement x="243" y="0" width="100" height="75"/> <graphicElement pen="None"/> <imageExpression>"logo.jpg"</imageExpression> </image> <staticText> <reportElement x="0" y="65" width="515" height="25"/> <textElement textAlignment="Left" lineSpacing="Single"> <font reportFont="Arial_Normal" size="18"/> </textElement> <text>Cartella clinica</text> </staticText> <line> <reportElement x="0" y="94" width="515" height="0"/> <graphicElement stretchType="NoStretch"/> </line> </band> </title> <pageHeader> <band/> </pageHeader> <columnHeader> <band height="0"/> </columnHeader> <detail> <band height="647"> <!--################## Cognome ########################--> <staticText> <reportElement x="5" y="5" width="110" height="15"/> <textElement textAlignment="Right" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>Cognome:</text> </staticText> <textField isBlankWhenNull="true"> <reportElement x="117" y="5" width="360" height="15" isPrintWhenDetailOverflows="false"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>$F{cognome}</textFieldExpression> </textField> <!--################## Nome ########################--> <staticText> <reportElement x="5" y="20" width="110" height="15"/> <textElement textAlignment="Right" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>Nome:</text> </staticText> <textField isBlankWhenNull="true"> <reportElement x="117" y="20" width="360" height="15" isPrintWhenDetailOverflows="false"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>$F{nome}</textFieldExpression> </textField> <!--################## Data di nascita ########################--> <staticText> <reportElement x="5" y="35" width="110" height="15"/> <textElement textAlignment="Right" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>Data di nascita:</text> </staticText> <textField isBlankWhenNull="true"> <reportElement x="117" y="35" width="100" height="15" isPrintWhenDetailOverflows="false"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>$F{data_nascita}</textFieldExpression> </textField> <!--################## Luogo di nascita ########################--> <staticText> <reportElement x="5" y="50" width="110" height="15"/> <textElement textAlignment="Right" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>Luogo di nascita:</text> </staticText> <textField isBlankWhenNull="true"> <reportElement x="117" y="50" width="360" height="15" isPrintWhenDetailOverflows="false"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>$F{luogo_nascita}</textFieldExpression> </textField> <!--################## Sesso ########################--> <staticText> <reportElement x="5" y="65" width="110" height="15"/> <textElement textAlignment="Right" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>Sesso:</text> </staticText> <textField isBlankWhenNull="true"> <reportElement x="117" y="65" width="100" height="15" isPrintWhenDetailOverflows="false"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>$F{sesso}</textFieldExpression> </textField> <!--################## Citt di residenza ########################--> <staticText> <reportElement x="5" y="80" width="110" height="15"/> <textElement textAlignment="Right" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>Citt di residenza:</text> </staticText> <textField isBlankWhenNull="true"> <reportElement x="117" y="80" width="360" height="15" isPrintWhenDetailOverflows="false"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>$F{citta_di_residenza}</textFieldExpression> </textField> <!--################## Cap ########################--> <staticText> <reportElement x="5" y="95" width="110" height="15"/> <textElement textAlignment="Right" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>Cap:</text> </staticText> <textField isBlankWhenNull="true"> <reportElement x="117" y="95" width="360" height="15" isPrintWhenDetailOverflows="false"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>$F{cap}</textFieldExpression> </textField> <!--################## Indirizzo ########################--> <staticText> <reportElement x="5" y="110" width="110" height="15"/> <textElement textAlignment="Right" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>Indirizzo:</text> </staticText> <textField isBlankWhenNull="true"> <reportElement x="117" y="110" width="360" height="15" isPrintWhenDetailOverflows="false"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>$F{indirizzo}</textFieldExpression> </textField> <!--################## Telefono ########################--> <staticText> <reportElement x="5" y="125" width="110" height="15"/> <textElement textAlignment="Right" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>Telefono:</text> </staticText> <textField isBlankWhenNull="true"> <reportElement x="117" y="125" width="360" height="15" isPrintWhenDetailOverflows="false"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>$F{telefono}</textFieldExpression> </textField> <!--################## Tessera sanitaria ########################--> <staticText> <reportElement x="5" y="140" width="110" height="15"/> <textElement textAlignment="Right" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>Tessera sanitaria:</text> </staticText> <textField isBlankWhenNull="true"> <reportElement x="117" y="140" width="360" height="15" isPrintWhenDetailOverflows="false"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>$F{tessera_sanitaria}</textFieldExpression> </textField> <!--################## Medico curante ########################--> <staticText> <reportElement x="5" y="155" width="110" height="15"/> <textElement textAlignment="Right" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>Medico curante:</text> </staticText> <textField isBlankWhenNull="true"> <reportElement x="117" y="155" width="180" height="15" isPrintWhenDetailOverflows="false"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>$F{medico_curante}</textFieldExpression> </textField> <!--################## Telefono Medico curante ########################--> <staticText> <reportElement x="297" y="155" width="40" height="15"/> <textElement textAlignment="Right" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>Tel:</text> </staticText> <textField isBlankWhenNull="true"> <reportElement x="337" y="155" width="120" height="15" isPrintWhenDetailOverflows="false"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>$F{tel_medico}</textFieldExpression> </textField> <!--################## Persona di riferimento ########################--> <staticText> <reportElement x="5" y="170" width="150" height="15"/> <textElement textAlignment="Right" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>Persona di riferimento:</text> </staticText> <textField isBlankWhenNull="true"> <reportElement x="157" y="170" width="180" height="15" isPrintWhenDetailOverflows="false"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>$F{persona_di_riferimento}</textFieldExpression> </textField> <!--################## Telefono Persona di riferimento ########################--> <staticText> <reportElement x="337" y="170" width="40" height="15"/> <textElement textAlignment="Right" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>Tel:</text> </staticText> <textField isBlankWhenNull="true"> <reportElement x="377" y="170" width="120" height="15" isPrintWhenDetailOverflows="false"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>$F{tel_medico}</textFieldExpression> </textField> <!--#################################################################--> <!--############### SUBREPORT MANSIONI PRECEDENTI ###############--> <!--#################################################################--> <subreport isUsingCache="true"> <reportElement x="5" y="190" width="510" height="40" positionType="Float"/> <subreportParameter name="matricola_addetto"> <subreportParameterExpression> $F{matricola_addetto} </subreportParameterExpression> </subreportParameter> <connectionExpression> $P{CUSTOM_CONNECTION} </connectionExpression> <subreportExpression class="java.lang.String"> "subreport_prec_mansioni.jasper" </subreportExpression> </subreport> <!--#################################################################--> <!--############### SUBREPORT MANSIONI ATTUALI ####################--> <!--#################################################################--> <subreport isUsingCache="true"> <reportElement x="5" y="230" width="510" height="40" isPrintWhenDetailOverflows="false" positionType="Float"/> <subreportParameter name="matricola_addetto"> <subreportParameterExpression> $F{matricola_addetto} </subreportParameterExpression> </subreportParameter> <connectionExpression> $P{CUSTOM_CONNECTION} </connectionExpression> <subreportExpression class="java.lang.String"> "subreport_mansione_attuale.jasper" </subreportExpression> </subreport> <!--################## Gruppo sanguigno ########################--> <line> <reportElement x="5" y="275" width="515" height="0" positionType="Float"/> <graphicElement stretchType="NoStretch"/> </line> <staticText> <reportElement x="5" y="280" width="110" height="15" positionType="Float"/> <textElement textAlignment="Left" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>Gruppo sanguigno:</text> </staticText> <textField isBlankWhenNull="true"> <reportElement x="115" y="280" width="50" height="15" positionType="Float"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>$F{gruppo_sanguigno}</textFieldExpression> </textField> <staticText> <reportElement x="240" y="280" width="45" height="15" positionType="Float"/> <textElement textAlignment="Left" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>HBsAg:</text> </staticText> <textField isBlankWhenNull="true"> <reportElement x="285" y="280" width="70" height="15" positionType="Float"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>($F{hbsag}.equals("S")?"positivo":"negativo")</textFieldExpression> </textField> <staticText> <reportElement x="420" y="280" width="25" height="15" positionType="Float"/> <textElement textAlignment="Left" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>HIV:</text> </staticText> <textField isBlankWhenNull="true"> <reportElement x="445" y="280" width="70" height="15" positionType="Float"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>($F{hiv}.equals("S")?"positivo":"negativo")</textFieldExpression> </textField> <!--#################################################################--> <!--################### SUBREPORT ALLERGIE #######################--> <!--#################################################################--> <subreport isUsingCache="true"> <reportElement x="5" y="295" width="510" height="40" isPrintWhenDetailOverflows="false" positionType="Float"/> <subreportParameter name="matricola_addetto"> <subreportParameterExpression> $F{matricola_addetto} </subreportParameterExpression> </subreportParameter> <connectionExpression> $P{CUSTOM_CONNECTION} </connectionExpression> <subreportExpression class="java.lang.String"> "subreport_allergie.jasper" </subreportExpression> </subreport> <!--################## Note allergie ########################--> <staticText> <reportElement x="5" y="335" width="80" height="15" isRemoveLineWhenBlank="true" positionType="Float"/> <textElement textAlignment="Left" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>Note allergie:</text> </staticText> <textField isBlankWhenNull="true" isStretchWithOverflow="true"> <reportElement x="85" y="335" width="430" height="15" isRemoveLineWhenBlank="true" positionType="Float"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>$F{note_allergie}</textFieldExpression> </textField> <line> <reportElement x="5" y="355" width="515" height="0" positionType="Float"/> <graphicElement stretchType="NoStretch"/> </line> <!--#################################################################--> <!--################### SUBREPORT VACCINAZIONI #######################--> <!--#################################################################--> <subreport isUsingCache="true"> <reportElement x="5" y="360" width="510" height="40" isPrintWhenDetailOverflows="false" positionType="Float"/> <subreportParameter name="matricola_addetto"> <subreportParameterExpression> $F{matricola_addetto} </subreportParameterExpression> </subreportParameter> <connectionExpression> $P{CUSTOM_CONNECTION} </connectionExpression> <subreportExpression class="java.lang.String"> "subreport_vaccinazioni.jasper" </subreportExpression> </subreport> <!--#################################################################--> <!--################### SUBREPORT MALATTIE #######################--> <!--#################################################################--> <subreport isUsingCache="true"> <reportElement x="5" y="400" width="510" height="40" isPrintWhenDetailOverflows="false" positionType="Float"/> <subreportParameter name="matricola_addetto"> <subreportParameterExpression> $F{matricola_addetto} </subreportParameterExpression> </subreportParameter> <connectionExpression> $P{CUSTOM_CONNECTION} </connectionExpression> <subreportExpression class="java.lang.String"> "subreport_malattie.jasper" </subreportExpression> </subreport> <!--################## note malattie ########################--> <staticText> <reportElement x="5" y="440" width="50" height="15" isRemoveLineWhenBlank="true" positionType="Float"/> <textElement textAlignment="Left" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>Note:</text> </staticText> <textField isBlankWhenNull="true" isStretchWithOverflow="true"> <reportElement x="55" y="440" width="450" height="15" isRemoveLineWhenBlank="true" positionType="Float"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>($F{note_malattie} == null?"":$F{note_malattie})</textFieldExpression> </textField> <line> <reportElement x="5" y="460" width="515" height="0" positionType="Float"/> <graphicElement stretchType="NoStretch"/> </line> <!--################## Interventi chirurgici ########################--> <staticText> <reportElement x="5" y="465" width="120" height="15" isRemoveLineWhenBlank="true" positionType="Float"/> <textElement textAlignment="Left" lineSpacing="Single"> <font reportFont="Arial_Bold"/> </textElement> <text>Interventi chirurgici:</text> </staticText> <textField isBlankWhenNull="true" isStretchWithOverflow="true"> <reportElement x="125" y="465" width="390" height="15" isRemoveLineWhenBlank="true" positionType="Float"/> <textElement> <font reportFont="Arial_Normal"/> </textElement> <textFieldExpression>($F{interventi_chirurgici} == null?"Nessuno di rilevante":$F{interventi_chirurgici})</textFieldExpression> </textField> <!--#################################################################--> <!--############# SUBREPORT MALATTIE PROFESSIONALI ###############--> <!--#################################################################--> <subreport isUsingCache="true"> <reportElement x="5" y="480" width="510" height="40" isPrintWhenDetailOverflows="true" positionType="Float" isPrintInFirstWholeBand="true"/> <subreportParameter name="matricola_addetto"> <subreportParameterExpression> $F{matricola_addetto} </subreportParameterExpression> </subreportParameter> <connectionExpression> $P{CUSTOM_CONNECTION} </connectionExpression> <subreportExpression class="java.lang.String"> "subreport_malattie_professionali.jasper" </subreportExpression> </subreport> <!--#################################################################--> <!--########### SUBREPORT POSTUMI PERMANENTI INFORTUNI ##########--> <!--#################################################################--> <subreport isUsingCache="true"> <reportElement x="5" y="520" width="510" height="40" isPrintWhenDetailOverflows="true" positionType="Float" isPrintInFirstWholeBand="true"/> <subreportParameter name="matricola_addetto"> <subreportParameterExpression> $F{matricola_addetto} </subreportParameterExpression> </subreportParameter> <connectionExpression> $P{CUSTOM_CONNECTION} </connectionExpression> <subreportExpression class="java.lang.String"> "subreport_infortuni.jasper" </subreportExpression> </subreport> <!--#################################################################--> <!--################## SUBREPORT ALTRE INVALIDITA' #################--> <!--#################################################################--> <subreport isUsingCache="true"> <reportElement x="5" y="460" width="560" height="40" isPrintWhenDetailOverflows="true" positionType="Float" isPrintInFirstWholeBand="true"/> <subreportParameter name="matricola_addetto"> <subreportParameterExpression> $F{matricola_addetto} </subreportParameterExpression> </subreportParameter> <connectionExpression> $P{CUSTOM_CONNECTION} </connectionExpression> <subreportExpression class="java.lang.String"> "subreport_altre_invalidita.jasper" </subreportExpression> </subreport> </band> </detail> <columnFooter> <band height="0"/> </columnFooter> <pageFooter> <band height="25"> <line> <reportElement x="0" y="0" width="515" height="0"/> <graphicElement stretchType="NoStretch"/> </line> <textField> <reportElement x="200" y="10" width="80" height="15"/> <textElement textAlignment="Right"/> <textFieldExpression class="java.lang.String"> "Pagina " + String.valueOf($V{PAGE_NUMBER}) + " di" </textFieldExpression> </textField> <textField evaluationTime="Report"> <reportElement x="280" y="10" width="75" height="15"/> <textElement textAlignment="Left"/> <textFieldExpression class="java.lang.String"> " " + String.valueOf($V{PAGE_NUMBER}) </textFieldExpression> </textField> </band> </pageFooter> <summary> <band height="0"/> </summary> </jasperReport> thanks By: Teodor Danciu - teodord RE: Problem with many subreports 2002-10-23 12:49 Hi, I think it is the positionType="Float" that seems to not work in your case. This is because you have to put some little space between your elements, if you want them to float. If one element (a subreport element for example), touches the element that it is immediatly above it, it won't float and they will overlap. Some of your report elements, if not all of them, touch each other top to bottom. Element e2 will float after e1 only if this condition is satisfied: e1.y + e1.height < e2.y This is not the case in your report design. (e1y + e1.height = e2.y) I hope this helps. Teodor By: Giulio Toffoli - gt78 RE: Problem with many subreports 2002-10-24 02:22Ciao Gianluca, Scarica iReport e prova a visualizzare il tuo report. Vedrai che hai sovrapposto in maniera strana i tuoi sottoreport. Downlaod iReport and try to view you report. You will see that subreport are positioned in a strange manner. ireport.sourceforge.net Giulio 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