Jump to content
JasperReports Library 7.0 is now available ×

Table in textFeild for pdf report


Go to solution Solved by Shadowfax58,

Recommended Posts

 

I've searched Google and read the documentation but haven't found a proper solution for adding a table to a textField in Jaspersoft 6.12.2. I tried like this:
 

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.12.2.final using JasperReports Library version 6.12.2-75c5e90a222ab406e416cbf590a5397028a52de3  -->
<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="memoTextReport" pageWidth="555" pageHeight="752" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="3a2d19d1-8c22-4eb3-a2d0-8ddff71bdb55">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
    <property name="ireport.zoom" value="2.0000000000000027"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="160"/>
    <import value="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
    <style name="BoldFont" isBold="true"/>
    <field name="text" class="java.lang.String"/>
    <title>
        <band splitType="Stretch"/>
    </title>
    <detail>
        <band height="20" splitType="Stretch">
            <property name="com.jaspersoft.studio.unit.height" value="px"/>
            <printWhenExpression><![CDATA[$F{text} != null || !$F{text}.isEmpty()]]></printWhenExpression>
            <textField textAdjust="StretchHeight" isBlankWhenNull="true">
                <reportElement positionType="Float" x="0" y="0" width="555" height="20" isRemoveLineWhenBlank="true" uuid="892c5253-222c-4bf8-838b-e2c1263d8339">
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <textElement markup="html">
                    <font size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{text}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>


Here text in XML can be like this:
 

<table style="width: 832pt;"><tbody><tr><td style="height: 45pt; width: 147pt;">Cell 1</td><td>Cell 2</td></tr><tr><td>Cell 3</td><td>Cell 4</td></tr></tbody></table>

However, the report always prints in plain text instead of a row-column format, like this:

Cell 1 Cell 2 Cell 3 Cell 4

Can anyone please suggest any proper solution for rendering table in textField?

Thanks in advance

Link to comment
Share on other sites

  • 1 month later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

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