I have configured my data source to be a csv file. The configured source looks as follows:
I then create an empty report template and add a table with the same datasource:
The table is added and looks as follows:
But when I try to preview , I get an error saying:
I just cannot understand the reason for this. How could I resolve this issue?
Here is the 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="Blank_Letter" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="445d22e8-c434-459d-9696-8f6167fa66e5">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="DataAdapter.xml"/>
<style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="Dataset1" uuid="43a885cc-1f9a-413f-a114-e5e0e287ffec">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="DataAdapter.xml"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="Name" class="java.lang.String"/>
</subDataset>
<queryString>
<![CDATA[]]>
</queryString>
<field name="Name" class="java.lang.String"/>
<detail>
<band height="332" splitType="Stretch">
<componentElement>
<reportElement x="207" y="132" width="200" height="200" uuid="ec75e03d-be8f-4abb-be6c-29c86cc6f2b9"/>
<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="Dataset1" uuid="ae4afac3-2a54-4e7c-a3cd-c8a246f79ec4">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION} ]]></connectionExpression>
</datasetRun>
<jr:column width="200" uuid="8d7d6c5b-2448-486d-a1e3-0a4d9e5f40a3">
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement x="0" y="0" width="200" height="30" uuid="aabc6fa0-086b-4bba-b92c-79c0a3467048"/>
<text><![CDATA[Name]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="200" height="30" uuid="783860ab-a9f1-402c-ab54-fa056bd29350"/>
<textFieldExpression><![CDATA[$F{Name}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
</jasperReport>
My csv looks like this:
Name,ID
Daphne Kub,1
Karolann Lebsack,2
Charlotte Parisian,3
Jairo Mayert,4
Please let me know if I could add more inputs.
You made a lot of mistakes.
You have to move table component to the Title or Summary band, because you are using only Dataset1 subdataset, not main dataset.
You can pass $P{REPORT_DATA_SOURCE}
to the dataSourceExpression.
You don't need even declare the main dataset (I removed it at this example).
The jrxml will be like this:
<?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="Blank_Letter" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="445d22e8-c434-459d-9696-8f6167fa66e5">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="DataAdapter.xml"/>
<subDataset name="Dataset1" uuid="43a885cc-1f9a-413f-a114-e5e0e287ffec">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="DataAdapter.xml"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="Name" class="java.lang.String"/>
</subDataset>
<title>
<band height="60" splitType="Stretch">
<componentElement>
<reportElement x="180" y="0" width="200" height="60" uuid="ec75e03d-be8f-4abb-be6c-29c86cc6f2b9"/>
<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="Dataset1" uuid="85f0f7ec-24c1-49f2-bde8-0287a608d0e0">
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
</datasetRun>
<jr:column width="200" uuid="8d7d6c5b-2448-486d-a1e3-0a4d9e5f40a3">
<jr:columnHeader height="30">
<staticText>
<reportElement x="0" y="0" width="200" height="30" uuid="aabc6fa0-086b-4bba-b92c-79c0a3467048"/>
<text><![CDATA[Name]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="30">
<textField>
<reportElement x="0" y="0" width="200" height="30" uuid="783860ab-a9f1-402c-ab54-fa056bd29350"/>
<textFieldExpression><![CDATA[$F{Name}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</title>
</jasperReport>
The result at JSS will be: