Jump to content

How to set dynamic pattern for text field


archanwizardsqueen

Recommended Posts

I want to show date in text field in jasper report. I've kept expression class of that text field as "java.util.Date" because while exporting that date in excel I want to retain "format cells-category as Date or Custom type" instead of General. So that user can change date format if he wants. I don't want to use "java.text.DateFormat" because of the same above given reason. But I want to pass my date format as parameter to report and use that in report.

like pattern = "$P{myDateFormat}"

myDateFormat can be anything dd-MMM-yyy, dd/MM/yy or just anything given in java

But problem is, pattern property of textField does not take expression. I saw one bug closed for jasper which had same requirement see link. But don't know why it's not working.

http://community.jaspersoft.com/ireport-designer/issues/932

http://community.jaspersoft.com/jasperreports-library/issues/4905

Also read of patternExpression but it's not present in ireport. 

Kindly tell me how to pass dynamic value to pattern.

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

I found the answer from jaspersoft support:-

we can use patternExpression but it's not available in lower versions of iReport IDE so you need to compile and deploy jasper externally.

<textFieldExpression class="java.util.Date"><![CDATA[$P{d8}]]></textFieldExpression>
<patternExpression><![CDATA[$P{userDateFormat}]]></patternExpression>

 

 

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