Jasper report formatting and font issues - jasper-reports

I have the following Jasper Report subreport .jrxml file and it's producing very strange results.
Each row of data returned gets mysteriously split into 2 separate lines on the report. Specifically, the very last character in location_name appears on a new line (unless there's a comma in the data, in which case a new line starts there). Why does that happen?
<?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">
<queryString>
<![CDATA[SELECT substr(location_name, 1, 5) as location_name from location]]>
</queryString>
<field name="location_name" class="java.lang.String"/>
<detail>
<band height="25">
<textField>
<reportElement x="0" y="0" width="100" height="25"/>
<box topPadding="1"><topPen lineWidth="0.5"/></box>
<textElement>
<font fontName="Times New Roman" size="8"
isBold="true" pdfFontName="Helvetica-Bold"/>
</textElement>
<textFieldExpression class="java.lang.String">
<![CDATA[$F{location_name}]]>
</textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
One possible clue is that when I opened this in Jaspersoft Studio I got a warning, "The use of pdf font is deprecated and replaced by the font extension". So I tried removing fontName and pdfFontName, leaving textElement as just:
...
<textElement>
<font size="8" isBold="true" />
</textElement>
...
That helps in that each line of data now appears on a single line, but the isBold has no effect.
Barring a solution, does anyone have a sample of how to bold text in a Jasper report?

I resolved this by upgrading from jasperreports-4.0.2.jar to jasperreports-5.1.0.jar.

Related

In jasper Soft Studio ,I have 2 page footers. For footer1. I want the position should be normal, and for footer 2. I want position force to bottom [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 months ago.
Improve this question
In jasper Soft Studio ,I have 2 page footers. For footer one, I want the position should be normal and for footer 2, I want position force to bottom. How can I do that?
If I am setting the position to force to bottom by default the position for both changes to force to bottom but I want one at bottom and second at normal.
I don't think you are using page footers. I'm assuming you have two footer bands for one group. As both of these footer bands belong to the same group they share the same properties. I'd say maybe use one group footer band (set to normal) and the page footer (which is at the bottom by default) or a second group with a same expression which will give you two independent group footers.
Here is an example that groups on $F{Country} with two (independent) groups.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.20.0.final using JasperReports Library version 6.1.1 -->
<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_A4_" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="62ac07f5-f11e-4179-aedb-a42e850c1ea8">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="northwind"/>
<queryString language="jsonql">
<![CDATA[Northwind.Customers]]>
</queryString>
<field name="City" class="java.lang.String">
<property name="net.sf.jasperreports.jsonql.field.expression" value="City"/>
<fieldDescription><![CDATA[City]]></fieldDescription>
</field>
<field name="Country" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="Country"/>
<fieldDescription><![CDATA[Country]]></fieldDescription>
</field>
<field name="ContactName" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="ContactName"/>
<fieldDescription><![CDATA[ContactName]]></fieldDescription>
</field>
<sortField name="Country"/>
<group name="City" footerPosition="ForceAtBottom">
<groupExpression><![CDATA[$F{Country}]]></groupExpression>
</group>
<group name="Group1">
<groupExpression><![CDATA[$F{City}]]></groupExpression>
</group>
<group name="Country 1" footerPosition="ForceAtBottom">
<groupExpression><![CDATA[$F{Country}]]></groupExpression>
<groupHeader>
<band height="52">
<textField>
<reportElement x="180" y="0" width="200" height="52" uuid="ecbaf5bf-be63-4f90-930c-dabb2c385d33"/>
<textElement textAlignment="Center">
<font size="35"/>
</textElement>
<textFieldExpression><![CDATA[$F{Country}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
<groupFooter>
<band height="20">
<textField>
<reportElement x="180" y="0" width="200" height="20" uuid="fc3ccc02-ea1b-4aa3-84d0-e40ba46f3966"/>
<textElement textAlignment="Center">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{Country}]]></textFieldExpression>
</textField>
</band>
</groupFooter>
</group>
<group name="Country 2">
<groupExpression><![CDATA[$F{Country}]]></groupExpression>
<groupFooter>
<band height="20">
<textField>
<reportElement x="180" y="0" width="200" height="20" uuid="fb7c7dad-07c1-428d-873e-cb1eae0c00d7"/>
<textElement textAlignment="Center">
<font size="14"/>
</textElement>
<textFieldExpression><![CDATA[$F{Country}]]></textFieldExpression>
</textField>
</band>
</groupFooter>
</group>
<detail>
<band height="30">
<textField>
<reportElement x="180" y="0" width="365" height="30" uuid="8edf2d40-c8e5-40d0-9bcd-3051581e7acb"/>
<textFieldExpression><![CDATA[$F{City}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="0" width="170" height="30" uuid="4fa050bf-8bbb-47ce-8108-6e9ba25ac668"/>
<textFieldExpression><![CDATA[$F{ContactName}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>

How can I know if jasper reports is evaluating the summary band?

I have report footer with page number and a confidential disclaimer. I need to hide confidential disclaimer in summary pages but need page number as it is.
I have added isSummaryNewPage="true" and isSummaryWithPageHeaderAndFooter="true" to the report.
Is there any flag to check whether the page is summary page or detail page inside <printWhenExpression> </printWhenExpression> or <textFieldExpression> </textFieldExpression>?
AFIK There is no built in property that tells you that you are on summary band.
However, I think this is a case where you safely can use what I call the "parameter hack" solution if summary band is on multiple page or for any another reason you don't like to use the lastPageFooter band.
The parameter hack solution
Add a parameter that is a java.util.Set (you can also use List, Map or other similar classes). Instance it with an empty HashSet.
<parameter name="paramHack" class="java.util.Set">
<defaultValueExpression><![CDATA[new java.util.HashSet()]]> </defaultValueExpression>
</parameter>
In a textField (in your case first on summary band), add a key to it in printWhenExpression, be careful the expression can be evaluated more then one time so always make sure it returns true.
<printWhenExpression><![CDATA[$P{paramHack}.add("summary") || true]]></printWhenExpression>
You can now use $P{paramHack}.contains("summary") to know if the textField has been evaluated, hence in case to know if we have arrived to summary band and not print the "confidential disclaimer".
<printWhenExpression><![CDATA[!$P{paramHack}.contains("summary")]]></printWhenExpression>
Example
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="WhenSummary" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isSummaryNewPage="true" isSummaryWithPageHeaderAndFooter="true" uuid="bbec9a5c-d9fc-4e29-b2b0-cea6d7a50394">
<parameter name="paramHack" class="java.util.Set">
<defaultValueExpression><![CDATA[new java.util.HashSet()]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[]]>
</queryString>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<detail>
<band height="40">
<staticText>
<reportElement x="0" y="0" width="545" height="40" uuid="74f6c3de-9867-4895-b7bb-c9cdb124fbdc"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="26"/>
</textElement>
<text><![CDATA[First just an empty page]]></text>
</staticText>
</band>
</detail>
<pageFooter>
<band height="40" splitType="Stretch">
<textField>
<reportElement x="50" y="0" width="440" height="40" uuid="af5f6f4c-fe77-4f07-a080-035230123f50">
<printWhenExpression><![CDATA[!$P{paramHack}.contains("summary")]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="26"/>
</textElement>
<textFieldExpression><![CDATA["Confidential"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="493" y="0" width="60" height="40" uuid="78b7b8bd-4189-42ea-8120-5a09a8b5701c"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="22"/>
</textElement>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band height="40" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="545" height="40" uuid="9ee45216-e7e1-4e5a-bbed-1f057ade1967">
<printWhenExpression><![CDATA[$P{paramHack}.add("summary") || true]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="26"/>
</textElement>
<text><![CDATA[Summary page]]></text>
</staticText>
</band>
</summary>
</jasperReport>
Output
If you also like to use this solution for summary pageHeader (that starts before summary, but after detail band) you can for example add a "fake" group and in the group footer band (that is evaluated after detail band, but before page header on summary band) add another property to our paramHack parameter detail_end.
<group name="FakeGroup">
<groupExpression><![CDATA["dummy"]]></groupExpression>
<groupFooter>
<band height="1">
<textField>
<reportElement x="0" y="0" width="553" height="1" uuid="373fc74e-011a-4f03-9cd4-9d5d9464ab06">
<printWhenExpression><![CDATA[$P{paramHack}.add("detail_end") && false]]></printWhenExpression>
</reportElement>
<textFieldExpression><![CDATA["Hidden used just to know when detail band ends"]]></textFieldExpression>
</textField>
</band>
</groupFooter>
</group>
Note: I have used another name, since this will be set before pageFooter on last detail band page, hence you can't use same name of flag for both pageFooter and pageHeader. To clarify on last detail band page in pageFooter the $P{paramHack}.contains("detail_end") is true but $P{paramHack}.contains("summary") is false.
Then in page header use this other flag to determine if to show or not show content.

How to add a tab in Jasper Report TextField

I want to add tab to a text field in my Jasper template. Below is my text field.
<staticText>
<reportElement key="" style="Table_CH" positionType="Float" x="0" y="37" width="802" height="112" uuid="db0d6ece-871a-4e7d-8f74-0abca53b1280"/>
<textElement markup="styled">
<font fontName="SansSerif" size="8" isBold="false"/>
<paragraph lineSpacing="Single"/>
</textElement>
<text>
<![CDATA[ Reader - please note: <li>List element1</li><li>List element2</li>]]>
</text>
</staticText>
I want to place a tab before each list element.
The adding tab symbol after the bullet can be done is several ways:
using \t (tab) sybmol
using to rendering tab in html code
using   character entity
Example
<?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="Tabs sample" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="583" leftMargin="2" rightMargin="10" topMargin="2" bottomMargin="2">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<title>
<band height="283">
<textField>
<reportElement positionType="Float" x="10" y="20" width="802" height="53" />
<textElement markup="styled"/>
<textFieldExpression><![CDATA["List without tabs:<li>List element1</li><li>List element2</li>"]]></textFieldExpression>
</textField>
<textField>
<reportElement positionType="Float" x="10" y="90" width="802" height="53" />
<textElement markup="styled"/>
<textFieldExpression><![CDATA["List with basic tab:<li>\tList element1</li><li>\tList element2</li>"]]></textFieldExpression>
</textField>
<textField>
<reportElement positionType="Float" x="10" y="160" width="802" height="53" />
<textElement markup="html"/>
<textFieldExpression><![CDATA["List with html tab:<li> List element1</li><li> List element2</li>"]]></textFieldExpression>
</textField>
<textField>
<reportElement positionType="Float" x="10" y="230" width="802" height="53" />
<textElement markup="html"/>
<textFieldExpression><![CDATA["List with emsp tab:<li> List element1</li><li> List element2</li>"]]></textFieldExpression>
</textField>
</band>
</title>
</jasperReport>
Please note that I used textField for showing \t symbol.
Output result
The result in Jaspersoft Studio will be:
More info:
How to insert spaces/tabs in text using HTML/CSS?
HTML: Tab space instead of multiple non-breaking spaces (“nbsp”)?
Markup in JasperReports
For adding spaces before bullet you can use html component with real html code. This component is not supplying complex html codes, only basic ones.
Example
<?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="Html component" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<parameter name="htmlCode" class="java.lang.String">
<defaultValueExpression><![CDATA["<div>\n" +
"<h3>List of elements</h3>\n" +
"<ul>\n" +
"<li>element1</li>\n" +
"<li>element2</li>\n" +
"<li>element3</li>\n" +
"</ul>\n" +
"</div>"]]></defaultValueExpression>
</parameter>
<title>
<band height="742">
<componentElement>
<reportElement x="0" y="0" width="190" height="70"/>
<hc:html xmlns:hc="http://jasperreports.sourceforge.net/htmlcomponent" xsi:schemaLocation="http://jasperreports.sourceforge.net/htmlcomponent http://jasperreports.sourceforge.net/xsd/htmlcomponent.xsd" scaleType="RealHeight" horizontalAlign="Left" verticalAlign="Top">
<hc:htmlContentExpression><![CDATA[$P{htmlCode}]]></hc:htmlContentExpression>
</hc:html>
</componentElement>
</band>
</title>
</jasperReport>
I've used parameter for setting html code for showing list. You can play with code for getting better result.
Output result
The result in Jaspersoft Studio will be:
More info:
How to show html code in report: Export html content to pdf using JasperReports
bulleted list with different indentation
How to add space before bullet points in HTML

Jasper Reports: Page Number inside subreport does not work

I have several similar reports in my application, for this reason I have created a basic structure with a subreport inside the Title and another one inside the Page Footer.
The problem is that I have 70 similar reports and if one day I need to change the footer structure I don´t wanna have to change 70 reports I prefer change only one.
In the footer subreport I have 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="reportFooterV" pageWidth="550" pageHeight="650" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="550" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="6a63a92f-0859-4b0b-84b8-6166c2fe0951">
<property name="ireport.zoom" value="1.5"/>
<property name="ireport.x" value="19"/>
<property name="ireport.y" value="0"/>
<parameter name="date" class="java.lang.String" isForPrompting="false"/>
<title>
<band height="19">
<textField>
<reportElement uuid="89a04d3d-73e0-4f28-9747-3206c4022769" x="0" y="0" width="191" height="19" forecolor="#999999"/>
<textElement verticalAlignment="Bottom">
<font fontName="Roboto" size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{date}]]></textFieldExpression>
</textField>
<textField evaluationTime="Auto">
<reportElement uuid="89a04d3d-73e0-4f28-9747-3206c4022769" x="352" y="0" width="99" height="19" forecolor="#999999"/>
<textElement textAlignment="Right" verticalAlignment="Bottom">
<font fontName="Roboto" size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</title>
</jasperReport>
But the variable PAGE_NUMBER, doesnt work and always show 1 in the page.
In the main report I have this in the pageFooter area
<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="systemParametersSummary" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" resourceBundle="properties.Messages" isIgnorePagination="true" uuid="6a63a92f-0859-4b0b-84b8-6166c2fe0951">
....
<pageFooter>
<band height="22">
<subreport>
<reportElement uuid="ac3cfc74-4e5a-45bc-945a-7ca6c82c4f6a" x="2" y="0" width="150" height="22"/>
<subreportParameter name="date">
<subreportParameterExpression><![CDATA[$P{date}]]></subreportParameterExpression>
</subreportParameter>
<subreportExpression><![CDATA[$P{footer}]]></subreportExpression>
</subreport>
</band>
</pageFooter>
</jasperReport>
I dont know why I cant find the workaround for this, if anyone can help me...thank you!
If you're only using these sub-reports for the page-numbering then this is why you are getting an error. Each of these sub-reports is only 1 page long, so it will always be page 1 of 1.
Neither is there usually a need to use sub-reports for page numbering in this way, as the overhead for calling sub-reports is more than it's usually worth for any benefit you get from doing so.
I'd suggest that you get rid of your sub-reports, and just allow the main report to do the heavy-lifting e.g. page numbers across a full report with the use of Master report engine data by putting your text field for the date in the main report footer and also using this code for the page numbering:
<textField evaluationTime="Master">
<reportElement uuid="89a04d3d-73e0-4f28-9747-3206c4022769" x="352" y="0" width="99" height="19" forecolor="#999999"/>
<textElement textAlignment="Right" verticalAlignment="Bottom">
<font fontName="Roboto" size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$V{MASTER_CURRENT_PAGE} + " of " + $V{MASTER_TOTAL_PAGES}]]></textFieldExpression>
</textField>
So, in your main report, you should end up with:
<pageFooter>
<band height="22">
<textField>
<reportElement uuid="89a04d3d-73e0-4f28-9747-3206c4022769" x="0" y="0" width="191" height="19" forecolor="#999999"/>
<textElement verticalAlignment="Bottom">
<font fontName="Roboto" size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{date}]]></textFieldExpression>
</textField>
<textField evaluationTime="Master">
<reportElement uuid="89a04d3d-73e0-4f28-9747-3206c4022769" x="352" y="0" width="99" height="19" forecolor="#999999"/>
<textElement textAlignment="Right" verticalAlignment="Bottom">
<font fontName="Roboto" size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$V{MASTER_CURRENT_PAGE} + " of " + $V{MASTER_TOTAL_PAGES}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
Not forgetting that if you're using a sub-report in the main report Title band for a similar purpose then you should probably re-think the approach for that as well.
If there is a specific reason for this you can apply the same logic in a sub-report to be used as per the original question. As you are using Master page-numbering this will also give the correct results e.g. your sub-report code would look 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="reportFooterV" pageWidth="550" pageHeight="650" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="550" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="6a63a92f-0859-4b0b-84b8-6166c2fe0951">
<parameter name="date" class="java.lang.String" isForPrompting="false"/>
<title>
<band height="22">
<textField>
<reportElement x="0" y="0" width="191" height="19" forecolor="#999999" uuid="89a04d3d-73e0-4f28-9747-3206c4022769"/>
<textElement verticalAlignment="Bottom">
<font fontName="Roboto" size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{date}]]></textFieldExpression>
</textField>
<textField evaluationTime="Master">
<reportElement x="352" y="0" width="99" height="19" forecolor="#999999" uuid="89a04d3d-73e0-4f28-9747-3206c4022769"/>
<textElement textAlignment="Right" verticalAlignment="Bottom">
<font fontName="Roboto" size="10" isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$V{MASTER_CURRENT_PAGE} + " of " + $V{MASTER_TOTAL_PAGES}]]></textFieldExpression>
</textField>
</band>
</title>
</jasperReport>
It's an old question, but there's now a variable MASTER_TOTAL_PAGES which works in my footer subreport.
The corresponding MASTER_CURRENT_PAGE didn't work for me, but you can easily pass in the current page number from the main report.

Report with Horizontal print order: Issue with truncating long text in textField

I am using JasperReports 4.0.2 (not tied to it in the long run, but for now we are).
I am having a problem with a sub-report which is set up to support 3 columns of data. I have 2 text fields which are being printed, and when the data is too long for the text field it is being truncated. After following advice in JasperReport - wrap text to show long text in textfield post I am still struggling to get the text field to overflow properly to display the data.
Here is my report file:
<?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="record" language="groovy" columnCount="3" printOrder="Horizontal" pageWidth="572" pageHeight="752" columnWidth="157" columnSpacing="50" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
<field name="geoName" class="java.lang.String"/>
<field name="count" class="java.lang.Integer"/>
<variable name="count" class="java.lang.String">
<variableExpression><![CDATA[new java.text.DecimalFormat("###,###,###,###").format($F{count})]]></variableExpression>
</variable>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="15" splitType="Stretch">
<textField isStretchWithOverflow="true">
<reportElement x="0" y="0" width="90" height="15" stretchType="RelativeToBandHeight" positionType="Float"/>
<textElement verticalAlignment="Middle">
<font fontName="Arial"/>
</textElement>
<textFieldExpression><![CDATA[$F{geoName}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement x="90" y="0" width="67" height="15" stretchType="RelativeToBandHeight" positionType="Float"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="Arial"/>
</textElement>
<textFieldExpression><![CDATA[$V{count}]]></textFieldExpression>
</textField>
<line>
<reportElement x="182" y="0" width="1" height="15" forecolor="#CCCCCC" stretchType="RelativeToBandHeight" positionType="Float"/>
</line>
</band>
</detail>
</jasperReport>
The report generally works properly and expands horizontally as it should, but if the data in either of the text fields is too long, it simply truncates it. The only workaround I have is to increase the band size, but that doesn't look good. I have also tried the isPrintWhenDetailOverflows="true" flag as well.
I have found my answer, and it is just a limitation of jasper.
http://jasperreports.sourceforge.net/sample.reference/horizontal/index.html
When filling report templates horizontally, dynamic text fields inside
the detail section do not stretch to their entire text content,
because this might cause misalignment on the horizontal axis of
subsequent detail sections. The detail band actually behaves the same
as the page and column footers, preserving its declared height when
horizontal filling is used.
So long story short, when filling horizontally you can't expect a vertical expansion as well, bummer!