Tom
Tom

Reputation: 6663

How to add a table header to an existing jasper table component?

Is there a way to add a table header to an existing jasper report table?

I have an existing jasper report that contains a table component that does not have a table header. I would like to add a table header now, but cannot find any way to do this without completely recreating the table.

Does anyone know of a way to add a Table Header to an existing jasper table component?

Upvotes: 2

Views: 6922

Answers (1)

Petter Friberg
Petter Friberg

Reputation: 21710

You have 2 options, add it directly in jrxml (xml) or use the IDE

1. Add directly to jrxml (go to source view)

In every jr:column you like to have a header add the jr:tableHeader tag as first element

<jr:column width="100" uuid="accf01ee-c512-4854-ae58-97dee667c054">
     <jr:tableHeader style="Table_TH" height="30">
       <staticText>
            <reportElement x="0" y="0" width="100" height="30" uuid="41f6fe02-194f-483e-ab7b-97a6061e2c27"/>
            <text><![CDATA[My header]]></text>
        </staticText>
    </jr:tableHeader>
   ....
</jr:column>

2. Use the IDE directly

Double click the table component this make it possibile to edit it, navigate in outline to the header node, for every column you like header create the cell and then you will be able to drag a static or dynamic textfield to it.

enter image description here

Upvotes: 3

Related Questions