NumberFormatException: For input string: "200%"

I can't seem to log an issue into the bug system, so reporting it here:

I've got an isStyledText==true field, and it just so happened that the field's value evaluated to:

<font size="200%">public </font>notes.

This resulted in the following exciting exception:

java.lang.NumberFormatException: For input string: "200%"
at java.lang.NumberFormatException.forInputString(
at java.lang.FloatingDecimal.readJavaFormatString(
at java.lang.Float.valueOf(
at java.lang.Float.<init>(
at net.sf.jasperreports.engine.util.JRStyledTextParser.parseStyle(
at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(
at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(
at net.sf.jasperreports.engine.fill.JRFillTextElement.getText(
at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(
at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(
at net.sf.jasperreports.engine.fill.JRFillBand.fill(
at net.sf.jasperreports.engine.fill.JRFillBand.fill(
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupFooter(
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupFooters(
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportContent(
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(
at net.sf.jasperreports.engine.JasperFillManager.fillReport(
at net.sf.jasperreports.engine.JasperFillManager.fillReport(
at net.sf.jasperreports.engine.JasperRunManager.runReportToPdf(

That's a bit harsh. Perhaps like in other cases where the styled text violates the styled rules, JasperReports should just output the raw text rather than throwing such a nasty exception.

This is particularly painful for me, because the text is submitted by the user -- for me, it is not part of the report defininition, so it is very hard to catch such a problem.

Dave Cherkassky
DJiNN Software.
dcherk's picture
Joined: Jul 18 2006 - 11:13pm
Last seen: 15 years 6 months ago

2 Answers:


When the styled text content is not a valid XML, we interpret it as raw text, without raising any exceptions.
But in this particular case, the styled text is a valid XML, with tags that our styled text recognizes, is just that the value for the size attribute is unexpected.
Our HTML support in styled text right now, does not support the % character, or any other letter. It only supports integer numbers there representing the size of the font as you would normally specify using the fontSize attribute in JasperReports.

Note that our HTML support is limited, so any other HTML constructs that would work in a browser do not necessarily work in JR.

Thank you,
teodord's picture
Joined: Jun 30 2006 - 9:00am
Last seen: 1 week 3 days ago

I understand why it happened from a technical point of view, and I've already implemented a work-around.

But what I am saying is that its not very usable from a business point of view, so I think you might want to improve the functionality here a little bit...

Thanks for your explanation though -- it'll help me think of other scenarios that might result in similar issues and write some preventitive code.

Dave Cherkassky.
dcherk's picture
Joined: Jul 18 2006 - 11:13pm
Last seen: 15 years 6 months ago