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

How do you display a table?


jedmalveda

Recommended Posts

Good day,

I am having trouble displaying table data from my php application. I am sure that my query returns a result since its just a simple select statement. I am using Ireport 5.6

when previewing the report using ireport it works fine. However when viewing on web using phpjasperxml and tcpdf the table is not showing.

JRXML:

<?xml version="1.0" encoding="UTF-8"?>
<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="report1" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isSummaryWithPageHeaderAndFooter="true" uuid="72cf83d7-2ff8-4e64-8765-411cb947aafa">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <style name="table">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_TH" mode="Opaque" backcolor="#DC143C">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_CH" mode="Opaque" backcolor="#FFBFCC">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 1">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 1_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 1_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 1_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 2">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 2_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 2_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 2_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 3">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 3_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 3_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 3_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 4">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 4_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 4_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 4_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 5">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 5_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 5_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 5_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 6">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 6_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 6_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 6_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 7">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 7_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 7_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 7_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 8">
        <box>
            <pen lineWidth="1.0" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 8_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 8_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="table 8_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="New Dataset 1" uuid="82d6351d-2c4f-4190-972d-13dc70f59ce5">
        <queryString language="SQL">
            <![CDATA[sELECT
     tblusers.`id` AS tblusers_id,
     tblusers.`lname` AS tblusers_lname
FROM
     `tblusers` tblusers]]>
        </queryString>
        <field name="tblusers_id" class="java.lang.Long"/>
        <field name="tblusers_lname" class="java.lang.String"/>
    </subDataset>
    <queryString language="SQL">
        <![CDATA[sELECT
     tblusers.`id` AS tblusers_id,
     tblusers.`lname` AS tblusers_lname
FROM
     `tblusers` tblusers]]>
    </queryString>
    <field name="tblusers_id" class="java.lang.Long"/>
    <field name="tblusers_lname" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="79" splitType="Stretch">
            <staticText>
                <reportElement x="67" y="41" width="100" height="20" uuid="11ad734f-099f-4c0c-825e-9ebb6836ff0a"/>
                <text><![CDATA[static text]]></text>
            </staticText>
        </band>
    </title>
    <pageHeader>
        <band height="50" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="20" splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="140" splitType="Stretch">
            <componentElement>
                <reportElement key="table 8" style="table 8" x="0" y="0" width="555" height="140" uuid="43cb1078-ef93-47c8-b1f6-287022e885d0"/>
                <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
                    <datasetRun subDataset="New Dataset 1" uuid="e6b8f824-528c-4c0a-adcd-4fe1f6197408">
                        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                    </datasetRun>
                    <jr:column width="90" uuid="aee8600e-c5a1-4d2f-a923-cf7b6e3ed094">
                        <jr:tableHeader style="table 8_TH" height="30" rowSpan="1"/>
                        <jr:tableFooter style="table 8_TH" height="30" rowSpan="1"/>
                        <jr:columnHeader style="table 8_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="90" height="30" uuid="9fc5c126-d0d6-4af0-81a0-785a955c2312"/>
                                <text><![CDATA[tblusers_id]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="table 8_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="table 8_TD" height="20" rowSpan="1">
                            <textField>
                                <reportElement x="0" y="0" width="90" height="20" uuid="58ec5135-62db-4aa8-9879-d3bf30dfe1f8"/>
                                <textFieldExpression><![CDATA[$F{tblusers_id}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                    <jr:column width="274" uuid="b3c592f1-a7fe-450e-bb95-578355afdaf8">
                        <jr:tableHeader style="table 8_TH" height="30" rowSpan="1"/>
                        <jr:tableFooter style="table 8_TH" height="30" rowSpan="1"/>
                        <jr:columnHeader style="table 8_CH" height="30" rowSpan="1">
                            <staticText>
                                <reportElement x="0" y="0" width="90" height="30" uuid="67143f21-4693-4741-8220-ffb45ae7ca69"/>
                                <text><![CDATA[tblusers_lname]]></text>
                            </staticText>
                        </jr:columnHeader>
                        <jr:columnFooter style="table 8_CH" height="30" rowSpan="1"/>
                        <jr:detailCell style="table 8_TD" height="20" rowSpan="1">
                            <textField>
                                <reportElement x="0" y="0" width="256" height="20" uuid="ee4326b7-6bc6-4e03-9d76-6373cca044e6"/>
                                <textFieldExpression><![CDATA[$F{tblusers_lname}]]></textFieldExpression>
                            </textField>
                        </jr:detailCell>
                    </jr:column>
                </jr:table>
            </componentElement>
        </band>
    </detail>
    <columnFooter>
        <band height="38" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="100" height="20" uuid="6df38c2e-78d0-4e24-bd9b-a218d0919977"/>
                <text><![CDATA[static text]]></text>
            </staticText>
        </band>
    </summary>
</jasperReport>

 

<?xml version="1.0" encoding="UTF-8"?>

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Just add a static text e.g. "No f***ing data found" into the "No Data" Band and set the property "WhenNoData" to "No Data Section" ... 

If you then run the report again and you see this static text in your generated PDF, then you could track down the problem to the database connection or to the query itself that could throw an error or something like this when accessing from your php-app.

Otherwise you will have to view the logfiles if the error is thrown perhaps when exporting to pdf or perhaps already when filling the JasperPrintObject.

hth + regards

C-Box

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