Jump to content

edu-de

Members
  • Posts

    9
  • Joined

  • Last visited

 Content Type 

Forum

Downloads

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Security Advisories

Events

Profiles

Posts posted by edu-de

  1. Are there any plans to support Jasperreports with Groovy 3 soon?
    As I can read here:
    https://stackoverflow.com/questions/63192049/after-updating-to-groovy-3-0-5-jasper-reports-compiled-with-groovy-wont-compile

    it seems to be very easy to:
    The only code change (other than upgrading the dependency version) is to change extends into implements at this line (as CompilationUnit.ClassgenCallback changed from an abstract class into an interface in Groovy 3.x).

  2. Hello,

    I have two jrxml files which should only display a static text "Report Title". The only difference between them is the query string:

    with query string:

    <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.4.0.final using JasperReports Library version 6.4.1 --><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="myReport"              pageWidth="842" pageHeight="595" orientation="Landscape"              columnWidth="744"              leftMargin="56" rightMargin="42"              topMargin="42" bottomMargin="42"              uuid="d532c1f1-3e7b-435c-8633-998b6d336727">    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>    <property name="com.jaspersoft.studio.data.sql.tables"    value=""/>    <property name="com.jaspersoft.studio.data.sql.SQLQueryDesigner.sash.w1" value="171"/>    <property name="com.jaspersoft.studio.data.sql.SQLQueryDesigner.sash.w2" value="822"/>    <property name="com.jaspersoft.studio.unit.pageHeight"    value="pixel"/>    <property name="com.jaspersoft.studio.unit.pageWidth"     value="pixel"/>    <property name="com.jaspersoft.studio.unit.columnWidth"   value="pixel"/>    <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>    <queryString>        <![CDATA[select 1]]>    </queryString>    <background>        <band splitType="Stretch"/>    </background>    <title>        <band height="46" splitType="Stretch">            <staticText>                <reportElement mode="Transparent" x="0" y="10" width="496" height="21"                               uuid="fad5deb0-680c-4a56-a6b6-f9792ef1527a"/>                <text><![CDATA[Report Title]]></text>            </staticText>        </band>    </title></jasperReport>[/code]

    without query string:

    just delete this:

    <queryString><![CDATA[select 1]]></queryString>[/code]

    Both files are identical, their only difference is the queryString tag.

    When running the reports in Jaspersoft Studio, both reports run correctly and I see "Report Title" on both reports.

    When running them from java, I only see "Report Title" in the report with queryString. In the report without queryString I only see a blank page. How can this be ?

    The java program to test:

    import java.sql.Connection;import java.sql.DriverManager;import java.util.HashMap; import net.sf.jasperreports.engine.JasperCompileManager;import net.sf.jasperreports.engine.JasperExportManager;import net.sf.jasperreports.engine.JasperFillManager;import net.sf.jasperreports.engine.JasperPrint; public class JasperGenerator {    public static void main(String[] args) {        // System.out.println("Usage: ReportGenerator ....");         try {            System.out.println("Start ....");            // Get jasper report            String jrxmlFileName = "withoutQuery.jrxml";            String jasperFileName = "withoutQuery.jasper";            String pdfFileName = "withoutQuery.pdf";             JasperCompileManager.compileReportToFile(jrxmlFileName, jasperFileName);             String dbUrl = "jdbcURL";            String dbDriver = "jdbcDriver"; // for example            String dbUname = "username";            String dbPwd = "password";             // Load the JDBC driver            Class.forName(dbDriver);            // Get the connection            Connection conn = DriverManager.getConnection(dbUrl, dbUname, dbPwd);             // Create arguments            HashMap hm = new HashMap();             // Generate jasper print            JasperPrint jprint = (JasperPrint) JasperFillManager.fillReport(jasperFileName, hm, conn);             // Export pdf file            JasperExportManager.exportReportToPdfFile(jprint, pdfFileName);             System.out.println("Done exporting reports to pdf");         } catch (Exception e) {            System.out.print("Exception" + e);        }    }}[/code]

    I tested with the latest jasperreports library 6.6.0.

  3. Why don't you just select all your needed fields in the query (select A,B,C,D,E,F,G,H) , and, depending on the parameters given, let some fields be shown or hidden? You can use "printWhenExpression" for this, e.g. for the field C: printWhenExpression= $P{showC}.equals("true"). So the user will only see the field "C" when the parameter "showC" is "true".

    In this way you can show only the requested fields.

  4. I have a jasperreport and I am trying to reduce the vertical size of its two frames. As you can see in this screenshot

    Bildschirmfoto2015-12-23um17_04_48.png.b16a2296ce25a3c91d31f52a1aabebd1.png

    The 3 frames (the surrounding frame and the two internal frames) are larger than the contents.

    I have been struggling to reduce their size to the size of the contents but without success. Any ideas what I can do? The par1 = null, par2=2, par3=3, par4=4.

    My jasperreport:

    <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0  --><!-- 2015-12-23T17:08:07 --><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="report2" language="groovy" pageWidth="979" pageHeight="693" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="979" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="a6ccd207-3a74-42e6-8486-fc3b01795fb5">    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>    <parameter name="par1" class="java.lang.String">        <defaultValueExpression><![CDATA[null]]></defaultValueExpression>    </parameter>    <parameter name="par2" class="java.lang.String">        <defaultValueExpression><![CDATA[null]]></defaultValueExpression>    </parameter>    <parameter name="par3" class="java.lang.String">        <defaultValueExpression><![CDATA[null]]></defaultValueExpression>    </parameter>    <parameter name="par4" class="java.lang.String">        <defaultValueExpression><![CDATA[null]]></defaultValueExpression>    </parameter>    <title>        <band height="80" splitType="Stretch">            <line>                <reportElement x="10" y="6" width="520" height="1" uuid="ebfc40ae-a2ee-40fc-b585-4236e9fa3c63"/>            </line>            <line>                <reportElement x="10" y="72" width="520" height="1" uuid="7657216f-1366-4455-adb0-db58e2333b5c"/>            </line>            <frame>                <reportElement x="329" y="10" width="172" height="59" isRemoveLineWhenBlank="true" uuid="0fbab6b3-f5ea-4716-b954-9371b4640781">                    <property name="ShowOutOfBoundContent" value="false"/>                </reportElement>                <box>                    <topPen lineWidth="0.4"/>                    <leftPen lineWidth="0.4"/>                    <bottomPen lineWidth="0.4"/>                    <rightPen lineWidth="0.4"/>                </box>                <frame>                    <reportElement positionType="Float" x="13" y="3" width="60" height="54" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="8a663ee5-c983-40f9-b85e-11bc852f46cc">                        <property name="ShowOutOfBoundContent" value="false"/>                    </reportElement>                    <box>                        <topPen lineWidth="0.4"/>                        <leftPen lineWidth="0.4"/>                        <bottomPen lineWidth="0.4"/>                        <rightPen lineWidth="0.4"/>                    </box>                    <textField isBlankWhenNull="true">                        <reportElement x="1" y="20" width="52" height="20" isRemoveLineWhenBlank="true" uuid="84504631-a04d-4f75-bcb2-9e20741f29ad"/>                        <box>                            <topPen lineWidth="1.0"/>                            <leftPen lineWidth="1.0"/>                            <bottomPen lineWidth="1.0"/>                            <rightPen lineWidth="1.0"/>                        </box>                        <textFieldExpression><![CDATA[$P{par3} == null ? null : "P3: " + $P{par3}]]></textFieldExpression>                    </textField>                    <textField isBlankWhenNull="true">                        <reportElement x="1" y="0" width="52" height="20" isRemoveLineWhenBlank="true" uuid="52c7e555-7e36-4992-8e59-b533fea31533"/>                        <box>                            <topPen lineWidth="1.0"/>                            <leftPen lineWidth="1.0"/>                            <bottomPen lineWidth="1.0"/>                            <rightPen lineWidth="1.0"/>                        </box>                        <textFieldExpression><![CDATA[$P{par1} == null ? null : "P1: " + $P{par1}]]></textFieldExpression>                    </textField>                </frame>                <frame>                    <reportElement positionType="Float" x="73" y="3" width="70" height="54" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="3a53c02d-6559-4c64-8ca8-21254b50435e">                        <property name="ShowOutOfBoundContent" value="false"/>                    </reportElement>                    <box>                        <topPen lineWidth="0.4"/>                        <leftPen lineWidth="0.4"/>                        <bottomPen lineWidth="0.4"/>                        <rightPen lineWidth="0.4"/>                    </box>                    <textField isBlankWhenNull="true">                        <reportElement x="1" y="0" width="52" height="20" isRemoveLineWhenBlank="true" uuid="b0ca90f0-9364-4c4c-a8cf-1a54c60189a0"/>                        <box>                            <topPen lineWidth="1.0"/>                            <leftPen lineWidth="1.0"/>                            <bottomPen lineWidth="1.0"/>                            <rightPen lineWidth="1.0"/>                        </box>                        <textFieldExpression><![CDATA[$P{par2} == null ? null : "P2: " + $P{par2}]]></textFieldExpression>                    </textField>                    <textField isBlankWhenNull="true">                        <reportElement x="1" y="20" width="52" height="20" isRemoveLineWhenBlank="true" uuid="f8b11d9c-fa8c-4e58-805a-4a8305b1bec1"/>                        <box>                            <topPen lineWidth="1.0"/>                            <leftPen lineWidth="1.0"/>                            <bottomPen lineWidth="1.0"/>                            <rightPen lineWidth="1.0"/>                        </box>                        <textFieldExpression><![CDATA[$P{par4} == null ? null : "P4: " + $P{par4}]]></textFieldExpression>                    </textField>                </frame>            </frame>        </band>    </title></jasperReport>[/code]

    I tried to reduce the size of the frames and set their removeLineWhenBlank property to true, and now everything disappears if I set the values par1=par2=null, par3=3, par4=4. Why ? I only want to remove the lines that are blank, not all of them:

    <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0  --><!-- 2015-12-23T18:22:07 --><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="report2" language="groovy" pageWidth="979" pageHeight="693" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="979" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="a6ccd207-3a74-42e6-8486-fc3b01795fb5">    <parameter name="par1" class="java.lang.String">        <defaultValueExpression><![CDATA[null]]></defaultValueExpression>    </parameter>    <parameter name="par2" class="java.lang.String">        <defaultValueExpression><![CDATA[null]]></defaultValueExpression>    </parameter>    <parameter name="par3" class="java.lang.String">        <defaultValueExpression><![CDATA[null]]></defaultValueExpression>    </parameter>    <parameter name="par4" class="java.lang.String">        <defaultValueExpression><![CDATA[null]]></defaultValueExpression>    </parameter>    <title>        <band height="141" splitType="Stretch">            <line>                <reportElement x="10" y="6" width="520" height="1" uuid="ebfc40ae-a2ee-40fc-b585-4236e9fa3c63"/>            </line>            <line>                <reportElement x="0" y="110" width="520" height="1" uuid="7657216f-1366-4455-adb0-db58e2333b5c"/>            </line>            <frame>                <reportElement x="329" y="10" width="172" height="43" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="0fbab6b3-f5ea-4716-b954-9371b4640781">                    <property name="ShowOutOfBoundContent" value="false"/>                </reportElement>                <box>                    <topPen lineWidth="0.4"/>                    <leftPen lineWidth="0.4"/>                    <bottomPen lineWidth="0.4"/>                    <rightPen lineWidth="0.4"/>                </box>                <frame>                    <reportElement positionType="Float" x="13" y="3" width="60" height="40" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="8a663ee5-c983-40f9-b85e-11bc852f46cc">                        <property name="ShowOutOfBoundContent" value="false"/>                    </reportElement>                    <box>                        <topPen lineWidth="0.4"/>                        <leftPen lineWidth="0.4"/>                        <bottomPen lineWidth="0.4"/>                        <rightPen lineWidth="0.4"/>                    </box>                    <textField isBlankWhenNull="true">                        <reportElement x="1" y="20" width="52" height="20" isRemoveLineWhenBlank="true" uuid="84504631-a04d-4f75-bcb2-9e20741f29ad"/>                        <box>                            <topPen lineWidth="1.0"/>                            <leftPen lineWidth="1.0"/>                            <bottomPen lineWidth="1.0"/>                            <rightPen lineWidth="1.0"/>                        </box>                        <textFieldExpression><![CDATA[$P{par3} == null ? null : "P3: " + $P{par3}]]></textFieldExpression>                    </textField>                    <textField isBlankWhenNull="true">                        <reportElement x="1" y="0" width="52" height="20" isRemoveLineWhenBlank="true" uuid="52c7e555-7e36-4992-8e59-b533fea31533"/>                        <box>                            <topPen lineWidth="1.0"/>                            <leftPen lineWidth="1.0"/>                            <bottomPen lineWidth="1.0"/>                            <rightPen lineWidth="1.0"/>                        </box>                        <textFieldExpression><![CDATA[$P{par1} == null ? null : "P1: " + $P{par1}]]></textFieldExpression>                    </textField>                </frame>                <frame>                    <reportElement positionType="Float" x="73" y="3" width="70" height="40" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="3a53c02d-6559-4c64-8ca8-21254b50435e">                        <property name="ShowOutOfBoundContent" value="false"/>                    </reportElement>                    <box>                        <topPen lineWidth="0.4"/>                        <leftPen lineWidth="0.4"/>                        <bottomPen lineWidth="0.4"/>                        <rightPen lineWidth="0.4"/>                    </box>                    <textField isBlankWhenNull="true">                        <reportElement x="1" y="0" width="52" height="20" isRemoveLineWhenBlank="true" uuid="b0ca90f0-9364-4c4c-a8cf-1a54c60189a0"/>                        <box>                            <topPen lineWidth="1.0"/>                            <leftPen lineWidth="1.0"/>                            <bottomPen lineWidth="1.0"/>                            <rightPen lineWidth="1.0"/>                        </box>                        <textFieldExpression><![CDATA[$P{par2} == null ? null : "P2: " + $P{par2}]]></textFieldExpression>                    </textField>                    <textField isBlankWhenNull="true">                        <reportElement x="1" y="20" width="52" height="20" isRemoveLineWhenBlank="true" uuid="f8b11d9c-fa8c-4e58-805a-4a8305b1bec1"/>                        <box>                            <topPen lineWidth="1.0"/>                            <leftPen lineWidth="1.0"/>                            <bottomPen lineWidth="1.0"/>                            <rightPen lineWidth="1.0"/>                        </box>                        <textFieldExpression><![CDATA[$P{par4} == null ? null : "P4: " + $P{par4}]]></textFieldExpression>                    </textField>                </frame>            </frame>        </band>    </title></jasperReport>[/code]

    What am I doing wrong?

×
×
  • Create New...