Ronald
Ronald

Reputation: 301

Report's detail band border list

I want to do a border for a list of elements in the band detail, the border has to be the size of the band detail, it would be :

enter image description here

In the picture of above is the format that I want, but I can't do it, I put a rectangle of the size of the band detail but for each element of the list is created a row with the rectangle that I put, so it's wrong, I would like to know how I can create a static border as the picture, no matter the size of the list of elements, the border is always of the size of the band detail.

Upvotes: 0

Views: 2858

Answers (2)

user1791574
user1791574

Reputation: 1749

You can try this.

<?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="sampleDynamicJasperDesign" pageWidth="595" pageHeight="842" columnWidth="515" leftMargin="40" rightMargin="40" topMargin="20" bottomMargin="20" uuid="f6525a83-6266-4c65-b19b-e8974a462453">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="Sans_Normal" isDefault="true" fontName="DejaVu Sans" fontSize="12" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
<field name="firstName" class="java.lang.String"/>
<field name="lastName" class="java.lang.String"/>
<field name="age" class="java.lang.Integer"/>
<title>
    <band height="20">
        <rectangle>
            <reportElement x="0" y="0" width="515" height="20" uuid="37ccd9d9-942a-4727-b124-dc164b811225"/>
        </rectangle>
        <staticText>
            <reportElement mode="Transparent" x="0" y="0" width="515" height="20" forecolor="#110D0D" backcolor="#F9F7F7" uuid="33c2fe57-3d87-4057-b6e0-f7eefc14abb1"/>
            <textElement textAlignment="Center"/>
            <text><![CDATA[This is title band]]></text>
        </staticText>
    </band>
</title>
<columnHeader>
    <band height="20">
        <textField>
            <reportElement x="320" y="0" width="195" height="20" uuid="aea6e23f-70bc-4a02-9ace-58dbdbea38a6"/>
            <box>
                <pen lineWidth="2.0" lineColor="#FF4532"/>
            </box>
            <textElement markup="html"/>
            <textFieldExpression><![CDATA["Age"]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="160" y="0" width="160" height="20" uuid="d833d2e5-a461-4151-b3b4-f414b0860213"/>
            <box>
                <pen lineWidth="2.0" lineColor="#FF4532"/>
            </box>
            <textFieldExpression><![CDATA["Last Name"]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement mode="Opaque" x="0" y="0" width="160" height="20" uuid="27edec93-cc98-410b-b1b1-90f0acc39f72"/>
            <box>
                <pen lineWidth="2.0" lineColor="#FF4532"/>
            </box>
            <textFieldExpression><![CDATA["First Name"]]></textFieldExpression>
        </textField>
    </band>
</columnHeader>
<detail>
    <band height="20">
        <textField isStretchWithOverflow="true" isBlankWhenNull="true">
            <reportElement stretchType="RelativeToBandHeight" x="0" y="0" width="160" height="20" uuid="a1bf44d8-97fb-48ee-abe4-0d15f3b0d8fc"/>
            <box>
                <leftPen lineWidth="2.0" lineColor="#FF4532"/>
                <rightPen lineWidth="2.0" lineColor="#1B6CFF"/>
            </box>
            <textFieldExpression><![CDATA["First Name: "+$F{firstName}]]></textFieldExpression>
        </textField>
        <textField isStretchWithOverflow="true" isBlankWhenNull="true">
            <reportElement stretchType="RelativeToBandHeight" x="160" y="0" width="160" height="20" uuid="b13594b0-f243-44a2-b628-f7f9c3ee1869"/>
            <box>
                <rightPen lineWidth="2.0" lineColor="#1B6CFF"/>
            </box>
            <textFieldExpression><![CDATA[$F{lastName}+" :Last Name"]]></textFieldExpression>
        </textField>
        <textField isStretchWithOverflow="true" isBlankWhenNull="true">
            <reportElement stretchType="RelativeToBandHeight" x="320" y="0" width="195" height="20" uuid="9319ca54-0b8b-4d57-ae5c-eab44a70549c"/>
            <box>
                <leftPen lineWidth="2.0" lineColor="#1B6CFF"/>
                <rightPen lineWidth="2.0" lineColor="#FF4532"/>
            </box>
            <textElement markup="html"/>
            <textFieldExpression><![CDATA["<html><font color=\"#66FF33\">"+"Age is: "+"</font><font color=\"#6600FF\">"+$F{age}+"</font></html>"]]></textFieldExpression>
        </textField>
    </band>
</detail>
<summary>
    <band height="1">
        <line>
            <reportElement x="0" y="0" width="515" height="1" uuid="ee544ff1-4c19-45b7-9a44-8dca649d9317"/>
        </line>
    </band>
</summary>
</jasperReport>

Also You see code implementation from here. ireport-detail-band-border-list

Enjoy.

Upvotes: 1

tempusfugit
tempusfugit

Reputation: 437

I assume you are using the element 'Table' in the jasper report studio. if you select a column, go to the Borders tab.

  1. First select the 'Pen Width' more than 0.

  2. After that select the 'Default borders style' to a four sided square.

  3. The pen width has to be selected before you select the style.

Do this for every column individually.

Hope it helps

Upvotes: 0

Related Questions