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?
4 Answers:
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
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.
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.
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>