Formatting $ on left and amount on right.

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?

white_falcon02's picture
Joined: Apr 1 2017 - 11:59am
Last seen: 4 years 5 months ago

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

C-Box's picture
23931
Joined: Jul 19 2006 - 5:58pm
Last seen: 3 weeks 3 days ago

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.

Friendly User's picture
Joined: Oct 8 2009 - 5:59am
Last seen: 5 hours 2 min ago

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.

white_falcon02's picture
Joined: Apr 1 2017 - 11:59am
Last seen: 4 years 5 months ago

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>

 
shertage's picture
22160
Joined: Sep 26 2006 - 8:06pm
Last seen: 2 months 2 weeks ago
Feedback