white_falcon02 Posted March 20, 2019 Share Posted March 20, 2019 In a text box, I am looking to format an amount so that the $ appears on the right side of the box, and the amount on the left similar to how excel displays amounts. This report will actually be exported to Excel when it is ran and sent to the accountants. Is it possible to do as I ask? Link to comment Share on other sites More sharing options...
C-Box Posted March 21, 2019 Share Posted March 21, 2019 Try to use a PATTERN-Expression (not the static pattern) like this:"###,###.000" + $F{Currency}for your right aligned textfield. So the whole field content sould be right aligned with the currency appended .Your thread-subject actually inverses your question!?!?!? So in subject you ask for currency to the left and amount on the right. So I'm a little bit confused, what you actually want to reach!?!?But just inverse the pattern expression in this case:$F{Currency} + "###,###.000"hth + regards C-Box Link to comment Share on other sites More sharing options...
Friendly User Posted March 21, 2019 Share Posted March 21, 2019 as previous poster said, your question is confusing because in the title you ask one thing and in the question text itself the opposite. Regardless, you can use both Pattern and Pattern expression for this. For example pattern ¤#### will put the currency symbol in front, ####¤ will put it in the end. Link to comment Share on other sites More sharing options...
white_falcon02 Posted March 22, 2019 Author Share Posted March 22, 2019 My title is the correct format. I was tired! I was looking to place the $ sign completely left-justified and the amount completely right-justified in the box and a whole lot of white space between no matter what the amount is. Excel does this with the accounting format. Link to comment Share on other sites More sharing options...
szaharia Posted March 22, 2019 Share Posted March 22, 2019 As already discussed above, you'll need to set a currency pattern for the textfield, to be considered in output formats other than Excel (PDF, HTML, etc).For the Excel output, you also need to set the net.sf.jasperreports.export.xls.pattern property for that textfield, in order to generate an Excel-specific accounting pattern when exporting to Excel. Try to use the following expression:<propertyExpression name="net.sf.jasperreports.export.xls.pattern"> <![CDATA["$\ * #,##0.00;$\ * -#,##0.00"]]></propertyExpression> Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now