I need to print two numbers in the same row with spaces or commas as 442233378,556664446 in this way I need to print using jasper reports.I am using the variable as $F(alias_name) to print these numbers.But it is printing out of the page as shown in the image it has to print the number above the line where the first number is printed.Please help me.
Asked
Active
Viewed 361 times
0
-
You should post your *jrxml* file and improve the problem's decription – Alex K Jan 22 '16 at 06:43
-
OK can I add () for textfieldespression.Please help me – Mouni Jan 22 '16 at 06:52
-
($F{paid_amount} == null)?(new DecimalFormat("#,##0.00")).format(0):(new DecimalFormat("#,##0.00")).format($F{paid_amount}) I need to print this expression between the ().It is not working for me.Please help me. – Mouni Jan 22 '16 at 06:53
-
What is a right result for you? – Alex K Jan 22 '16 at 07:01
-
the expression is printing correctly but i want to print (expresion) in this way – Mouni Jan 22 '16 at 07:05
-
Like this: "(" + $F{strValue} + ")" ? – Alex K Jan 22 '16 at 07:08
-
Can you please add for my expression.it is showing syntax error – Mouni Jan 22 '16 at 07:09
-
$V{total} == null ? "(0.00)" : "(" + new DecimalFormat ("#,##0.00").format($V{total}) + ")" – Alex K Jan 22 '16 at 07:13
-
Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/101374/discussion-between-alex-k-and-mouni). – Alex K Jan 22 '16 at 07:48
-
BigDecimal total = null; String str = total == null ? "(0.00)" : "(" + new DecimalFormat ("#,##0.00").format(total) + ")"; - this is correct snippet from *Java* code – Alex K Jan 22 '16 at 07:53
-
You should set *Java* as language for your report – Alex K Jan 22 '16 at 07:54
-
why it is duplicate it formatting a string to currency it is not the right solution for me.You need to give a possible answer already i have seen that question and i asked in this.Please help me.It is very important for me – Mouni Jan 22 '16 at 09:14
-
Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/101397/discussion-between-mouni-and-alex-k). – Mouni Jan 22 '16 at 11:46
-
Could you specify what type of database you are using? An easier solution could be possible through editing of the query itself. – Cameron Downer Jan 22 '16 at 12:01
-
can we get the list of the id's and can convert into array and print is it possible?? – Mouni Jan 22 '16 at 12:15
-
I have used this quey
<![CDATA[select alias_name from service_alias where service_id in(select id from service where order_id in (select id from purchase_order where id in (select order_id from order_process where invoice_id = $P{invoiceId}) and period_id!=1) and status_id=47 and deleted=0) and deleted=0 order by id limit 2;]]> but it is printing the same as image – Mouni Jan 22 '16 at 12:18
1 Answers
1
I think you get get a solution for this by just changing your query.
I have added a GROUP_CONCAT
function onto your alias_name
field, you can read more on what this does here.
SELECT
GROUP_CONCAT(DISTINCT alias_name SEPARATOR ', ') AS alias_name
FROM
service_alias
WHERE
service_id IN
(
SELECT
id
FROM
service
WHERE
order_id IN
(
SELECT
id
FROM
purchase_order
WHERE
id IN
(
SELECT
order_id
FROM
order_process
WHERE
invoice_id = $P{invoiceId}
)
AND
period_id != 1
)
)
Here is the query added into the entityDetails.jrxml file:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Entity details" pageWidth="595" pageHeight="875" whenNoDataType="AllSectionsNoDetail" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" >
<property name="com.jasperassistant.designer.GridHeight" value="12"/>
<property name="com.jasperassistant.designer.GridWidth" value="12"/>
<property name="com.jasperassistant.designer.SnapToGrid" value="false"/>
<property name="com.jasperassistant.designer.Grid" value="false"/>
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="invoiceId" class="java.lang.Integer"/>
<queryString>
<![CDATA[
SELECT
GROUP_CONCAT(DISTINCT alias_name SEPARATOR ', ') AS alias_name
FROM
service_alias
WHERE
service_id IN
(
SELECT
id
FROM
service
WHERE
order_id IN
(
SELECT
id
FROM
purchase_order
WHERE
id IN
(
SELECT
order_id
FROM
order_process
WHERE
invoice_id = $P{invoiceId}
)
AND
period_id!=1
)
)
]]>
</queryString>
<field name="alias_name" class="java.lang.String"/>
<title>
<band splitType="Stretch"/>
</title>
<detail>
<band height="62">
<textField isBlankWhenNull="true">
<reportElement x="50" y="5" width="197" height="15" />
<textElement>
<font size="10" isBold="true"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{alias_name}]]></textFieldExpression>
</textField>
<image>
<reportElement x="18" y="4" width="18" height="13" />
<imageExpression><![CDATA["/opt/apps/openbrm-2.0/openbrm/resources/logos/phone-symbol.png"]]></imageExpression>
</image>
</band>
</detail>
</jasperReport>

Cameron Downer
- 1,839
- 17
- 26
-
-
it is getting error as alias_name unknown column after adding your query – Mouni Jan 22 '16 at 12:56
-
-
-
I have now changed the answer to a corrected query (hopefully) and to include the jrxml code as well. – Cameron Downer Jan 22 '16 at 14:13
-
-
-
This may be because your text field isn't large enough to show all of the contents of the field. Do you know how many alias_names are being returned on your query? – Cameron Downer Jan 22 '16 at 15:18