Jump to content

Column Names when using TableModel as data source


tedhill

Recommended Posts

I am trying to create a simple report based on a JTable TableModel for a data source.

My problem is with the column names.

In my jrxml file I have done this for column names:

=======================================

<field name="COLUMN_0" class="java.lang.String"/>

<columnHeader>
        <band height="61" splitType="Stretch">
            <staticText>
                <reportElement x="26" y="0" width="100" height="20"/>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <text><![CDATA[COLUMN_0]]></text>
            </staticText>
        </band>
    </columnHeader>

and this for a table row cell:

=====================

<detail>
        <band height="42" splitType="Stretch">
            <textField>
                <reportElement x="26" y="0" width="100" height="20"/>
                <textElement/>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{COLUMN_0}]]></textFieldExpression>
            </textField>
</detail>

In the finished report, the content of the rows is the data pulled from the TableModel, this is good.

However, the names of the columns are not being pulled from the TableModel data source, they appear as the strings

COLUMN_0, etc.

How can I get the column names from the TableModel to appear in the report without "hard coding" them into the jrxml?

Is there some way to pass the column names as a parameter list and then access the parameters in the jrxml file?

Thanks,

Ted

 


 

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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