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

How to display the query


yael

Recommended Posts

Hi,

How can I display the result of a query as a table in JasperViewe??

Code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport
PUBLIC "-//JasperReports//DTD Report Design//EN"
"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport name="example1">
<reportFont name="Arial_Normal" isDefault="true" fontName="Arial" size="12"
isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false"
pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false" />
<reportFont name="Arial_Bold" isDefault="false" fontName="Arial" size="12"
isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false"
pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false" />
<reportFont name="Arial_Italic" isDefault="false" fontName="Arial" size="12"
isBold="false" isItalic="true" isUnderline="false" isStrikeThrough="false"
pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1252" isPdfEmbedded="false" />
<parameter name="Title"/>
<queryString language="sql">
<![CDATA[ SELECT first_name,last_name,contact_id FROM contacts
]]>
</queryString>
<field name="first_name" class="java.lang.String" />
<field name="last_name" class="java.lang.String" />
<field name="contact_id" class="java.lang.Integer" />

<title>
<band height="35">
<textField isBlankWhenNull="true">
<reportElement mode="Transparent" x="0" y="0" width="520" height="30" forecolor="#FF3300" backcolor="#FFFFFF" key="staticText-1" stretchType="NoStretch" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false" />
<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000" />
<textElement textAlignment="Center" verticalAlignment="Top" rotation="None" lineSpacing="Single">
<font fontName="Arial" pdfFontName="Helvetica-Bold" size="24" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded="false" pdfEncoding="Cp1252" isStrikeThrough="false" />
</textElement>
<textFieldExpression class="java.lang.String">
$P{Title}
</textFieldExpression>
</textField>
<line>
<reportElement x="0" y="30" width="520" height="1" />
<graphicElement />
</line>
</band>
</title>

<pageHeader>
<band></band>
</pageHeader>

<columnHeader>
<band height="20">
<staticText>
<reportElement x="10" y="0" width="180" height="20"/>
<textElement textAlignment="Center">
<font fontName="Arial" isBold="true" isUnderline="true"/>
</textElement>
<text><![CDATA[First Name]]></text>
</staticText>
<staticText>
<reportElement x="90" y="0" width="180" height="20"/>
<textElement textAlignment="Center">
<font fontName="Arial" isBold="true" isUnderline="true"/>
</textElement>
<text><![CDATA[Last Name]]></text>
</staticText>
<staticText>
<reportElement x="180" y="0" width="180" height="20"/>
<textElement textAlignment="Center">
<font fontName="Arial" isBold="true" isUnderline="true"/>
</textElement>
<text><![CDATA[iD]]></text>
</staticText>
</band>
</columnHeader>


<detail>
<band height="20">
<textField>
<reportElement x="10" y="0" width="180" height="20" />
<textElement textAlignment="Center">
<font fontName="Arial"/>
</textElement>
<textFieldExpression class="java.lang.String">
<![CDATA[$F{first_name}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement x="90" y="0" width="180" height="20" />
<textElement textAlignment="Center">
<font fontName="Arial"/>
</textElement>
<textFieldExpression class="java.lang.String">
<![CDATA[$F{last_name}]]>
</textFieldExpression>
</textField>
<textField>
<reportElement x="180" y="0" width="180" height="20" />
<textElement textAlignment="Center">
<font fontName="Arial"/>
</textElement>
<textFieldExpression class="java.lang.Integer">
<![CDATA[$F{contact_id}]]>
</textFieldExpression>
</textField>
</band>
</detail>

<pageFooter>
<band height="40">
<line>
<reportElement x="0" y="10" width="515" height="1" />
<graphicElement />
</line>
<textField>
<reportElement x="200" y="20" width="80" height="15" />
<textElement textAlignment="Right" />
<textFieldExpression class="java.lang.String">
<![CDATA["Page "]]>
</textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement x="280" y="20" width="75" height="15" />
<textElement />
<textFieldExpression class="java.lang.String">
<![CDATA[" of "]]>
</textFieldExpression>
</textField>
</band>
</pageFooter>

</jasperReport>

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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