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

Show vertical result and add new column after the middle.


mfelipe.ayala

Recommended Posts

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

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>
 

Link to comment
Share on other sites

  • 2 weeks later...

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

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...