Show vertical result and add new column after the middle.

0

Hi everyone,

I would like to show a subreport using this detail.

Prod1  Price1       Prod5  Price5
Prod2  Price2       Prod6  Price6
Prod3  Price3       Prod7  Price7
Prod4  Price4       Prod7  Price8

I hope that someone can help me.

Thanks!

mfelipe.ayala's picture
Joined: Nov 28 2016 - 3:27pm
Last seen: 6 months 1 week ago

Thanks reportdev,

The solutions works fine. Thanks!

However, it prints all the records vertically using all the high size. It means, we show all the records in one colum and then show the other column. For example:

Prod1  Price1       Prod8  Price8
Prod2  Price2       
Prod3  Price3       
Prod4  Price4 
Prod5  Price5
Prod6  Price6
Prod7  Price7

I would like to show them using the two columns like this.

Prod1  Price1       Prod5  Price5
Prod2  Price2       Prod6  Price6
Prod3  Price3       Prod7  Price7
Prod4  Price4       Prod7  Price8

Thanks

 

mfelipe.ayala - 2 years 11 months ago

Hi,

so do you have only 8 values that will be displayed all the time?

  1. if yes, then you can decrease the page height to 60-80 pixels and the report truncates it all the time.
  2. if no and you cannot guess the number of records, then i would suggest leave the report as is.
reportdev - 2 years 11 months ago

1 Answer:

1

use this code and replace your fields

 

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0  -->
<!-- 2016-12-02T14:26:12 -->
<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="sss" columnCount="2" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="376" columnSpacing="50" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d636513c-6fad-4279-973d-754c6d542965">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="PRODSUP"/>
    <property name="com.jaspersoft.studio.unit." value="pixel"/>
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
    <style name="Crosstab_CH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Crosstab_CG" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="RowBanding">
        <conditionalStyle>
            <conditionExpression><![CDATA[$V{REPORT_COUNT}%2==0]]></conditionExpression>
            <style mode="Opaque" backcolor="#F2F2F2"/>
        </conditionalStyle>
    </style>
    <queryString>
        <![CDATA[select  (trunc(sysdate+1) + level -1) as business_date, extract(year from (trunc(sysdate+1) + level -1)) year
from    dual
connect by sysdate + level -1 < sysdate + 5000]]>
    </queryString>
    <field name="BUSINESS_DATE" class="java.sql.Timestamp"/>
    <field name="YEAR" class="java.math.BigDecimal"/>
    <columnHeader>
        <band height="20">
            <staticText>
                <reportElement mode="Opaque" x="180" y="0" width="200" height="20" forecolor="#FFFFFF" backcolor="#FF0400" uuid="dc1f8377-01ea-460d-975c-9a8cf7d3c401"/>
                <textElement textAlignment="Center">
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Price]]></text>
            </staticText>
            <staticText>
                <reportElement mode="Opaque" x="0" y="0" width="180" height="20" forecolor="#FFFFFF" backcolor="#FF0400" uuid="eb0beb3c-cced-47bf-804e-8a7f768f1f0c"/>
                <textElement textAlignment="Center">
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[Product]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="20">
            <textField>
                <reportElement style="RowBanding" x="1" y="0" width="180" height="20" uuid="076918a4-6c44-440b-b20e-9cb79f67212f"/>
                <textElement textAlignment="Center"/>
                <textFieldExpression><![CDATA[$F{YEAR}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement style="RowBanding" x="180" y="0" width="201" height="20" uuid="049aea15-a587-4d2d-a222-ac399f6496d5"/>
                <textElement textAlignment="Center"/>
                <textFieldExpression><![CDATA[$F{BUSINESS_DATE}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>
 

reportdev's picture
1222
Joined: Oct 12 2015 - 12:05pm
Last seen: 20 hours 40 min ago
Feedback