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

How to do Conditional Text Align


h.leininger

Recommended Posts

Hi,

I have a table with a cell defined with text Alignment Right.
I want to have "Left" text Alignment for this cell if it is the first Row of the table. Is this possible?

extract of the XML:
...

        <textField textAdjust="StretchHeight" evaluationTime="Auto">
            <reportElement positionType="Float" stretchType="ElementGroupHeight" x="0" y="0" width="78" height="26" uuid="54183d43-a1b4-4edd-bd56-8f8819c52b59">
                <property name="com.jaspersoft.studio.unit.width" value="cm"/>
            </reportElement>
            <box padding="0">
                <pen lineWidth="0.25"/>
                <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
            </box>
            <textElement textAlignment="Right" markup="styled">
                <font fontName="Carlito" size="11"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{proband}]]></textFieldExpression>
        </textField>


...

Thanks
Helmut Leininger

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

If your requirement is the following image, you can achieve it by using conditional style.


w20210907_image.png.299bd8c63ea006e12d51c424b8743b5f.png

w20210907_style.png.703f73f33146070330028d75b38d90da.png

 

The configuration procedure is as follows.

1. Create a new Style (ex:Style1)
   --> In this case, set TextAlignment=Right.
w20210907_style1.png.bbed8fdd2ec74c9314c03b2691d0413f.png

 

2. Create a conditional style for Style1 (Expression:$V{COLUMN_COUNT} == 1)
   --> Here, set TextAlignment=Left.

w20210907_style1_2.png.5da549038a51b258968deaa582b6a989.png

 

3. Define 'Style1' for the text field style.
w20210907_text.png.d621416e043ce4a8b93ce4136aa52a46.png

 

* (Reference) style code

    <style name="Style1" hTextAlign="Right">        <conditionalStyle>            <conditionExpression><![CDATA[$V{COLUMN_COUNT} == 1]]></conditionExpression>            <style hTextAlign="Left"/>        </conditionalStyle>    </style>

 

* (Reference) textField code

            <textField>                <reportElement style="Style1" x="240" y="0" width="80" height="30" uuid="4440143f-b9f3-4e00-95d8-f429250bfe50">                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="94e4996e-866d-42e7-b3c5-8507f14bf0f9"/>                </reportElement>                <box>                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>                </box>                <textElement verticalAlignment="Middle">                    <font size="14"/>                </textElement>                <textFieldExpression><![CDATA[$F{seq}]]></textFieldExpression>            </textField>

 

 

I hope this is useful to you.

 

 

 

 

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...