Jasper Reports subreport text alignment is wrong only when in main report - jasper-reports

When I preview my jasper subreport, text is aligned to the right (what I want).
But when it is used in the main report, text is aligned to the left
On both reports, per element styling is used, set in Jasper Studio.
The jrxml per element looks like...
<textElement textAlignment="Right" markup="html">
<paragraph leftIndent="2"/>
</textElement>
<textFieldExpression><![CDATA[$F{col_1_initials}]]> </textFieldExpression>
The element including the subreport looks like
<band height="161" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<subreport isUsingCache="false" runToBottom="false">
<reportElement x="-20" y="0" width="595" height="161" uuid="4e6fb330-c43f-4d47-b7aa-6884dad63d14"/>
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("weekPairs")]]></dataSourceExpression>
<subreportExpression><![CDATA["weeksubreport.jasper"]]></subreportExpression>
</subreport>
</band>
I'm not using report Style Templates because for a reason I can't diagnose, Jaspersoft Studio crashes instantly trying to assign a style template.
What about the main report ovverides the subreport text-aligment and what would I have to change in the source to fix this?
EDIT
In the report designer->properties of a jrxml file there is a checkbox for "Derive Attributes". I've tried that both on and off, but nothing changed.

Related

remove the white space from columnFooter because columnFooter is only shown on the last page on Jasper [duplicate]

I have a report made in iReport. I included a textFieldExpression in the column footer. My problem is that even though the line is blank it still takes up the space of the height of the band and thus sending the rest of fields to another sheet.
The code that I have is the following:
<columnFooter>
<band height="12" splitType="Stretch">
<printWhenExpression><![CDATA[$F{descripcionComentario}!=null]]></printWhenExpression>
<textField>
<reportElement x="42" y="0" width="100" height="12" uuid="5a9cbe9d-486a-4dd4-a865-d421cd7366a6"/>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{descripcionComentario}]]></textFieldExpression>
</textField>
</band>
</columnFooter>
The columnFooter is not resizable at run time, you need to find another report structure to solve your issue.
The solution often is to use groups where you have access to the groupFooter band.

Jasper Report assign a variable value from a DTO to the backcolor tag [duplicate]

I am using Jasper Report for designing report. I have a report where there is a static text. I want to set the background color of it by parameter value. In the XML it generates for the text like this:
<reportElement mode="Opaque" x="434" y="0" width="121" height="12" backcolor="#A6A6A6" uuid="e088bd9f-a0ac-4f34-9375-df765c829ec2"/>.
Now I need to set the backcolor from a parameter which will come from database. for here like #A6A6A6.
What can I try next? I have researched it, but no luck.
You can do that with net.sf.jasperreports.style.* element level properties (for which you can have expressions as values).
In your case you would need
<textField>
<reportElement ...>
<propertyExpression name="net.sf.jasperreports.style.backcolor">$P{someColor}</propertyExpression>
</reportElement>
...

Unable to add extra content into exported word doument from jasper report

I am using TIBCO Jaspersoft Studio-6.2.0.final for generating report . I am able to generate report in word (.docx).
I added some sample text. In export word sample text shown inside a frame. But when I am trying to update or add any extra text into that report in word, its hiding inside the frame. When I expand that frame, then it showing.
How I can generate report in word without any frame like normal word? So that I can add any text, so it will show normally.
Below I added jrxml code.
<queryString>
<![CDATA[SELECT 1 FROM DUal]]>
</queryString>
<field name="1" class="java.math.BigDecimal"/>
<detail>
<band height="20" splitType="Stretch">
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="1" width="510" height="19" uuid="68ec5b9f-416e-45d6-b2aa-4d1f31a08250">
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement>
<font fontName="Arial" size="11"/>
</textElement>
<textFieldExpression><![CDATA["This is the sample text for testing.To test in word"]]></textFieldExpression>
</textField>
</band>
</detail>
Update:
Is any one having any update on this?
Currently there is no possibility to generate paragraph-oriented docx content. The built-in .docx exporter is a grid-layout exporter, so it will generate a table-based document. This is why enclosing frames/table cells are present in the document. Even if you'd use a single huge textfield for your entire document, a table with a single cell will be generated as docx output.
The only way to get the desired behavior is to implement and use a custom paragraph-oriented docx exporter, based on existing JasperReports APIs.
I hope this helps.
Jasper export .docx as grid/table. In your exported document use Layout -> View Gridlines to show those tables. You can edit them manually if it's a single report what you need. Else, check Aspose library or try to implement manually a custom exporter.
If your only problem is that fields doesn't expand when you write, just add this code to your report properties:
<property name="net.sf.jasperreports.export.docx.flexible.row.height" value="true"/>

JasperReports: How to remove new page blank in subreport

I have create one report and put subreport into summary. I have problem to remove the new page blank in subreport because i have put clicks "run to bottom" in subreport's properties. After that, i run my report properly. The data appear correctly but problem comes when one new page blank appear after page. I don't know how to remove the blank page. Anyone know about this?
i know my mistakes is not put sub report by size band. Size band and sub ​​report must be the same size so that no blank page will come out.
I solve this adding the attribute isRemoveLineWhenBlank="true" for the reportElement tag:
<reportElement mode="Opaque" x="0" y="0" width="802" height="60" isRemoveLineWhenBlank="true" ...
And the band height, reportElement height and the subreport height must be equals:
<detail>
<band height="60" splitType="Stretch">
<subreport>
<reportElement mode="Opaque" x="0" y="0" width="802" height="60" ...

Make lines with iReport?

How can I do this with iReport (using iReport v4.0)?
Here is jrxml file
it depend on the size of Sub-report, check the sub-repot preview, if you want to increase the size of sub-rport in main report , for this you have to increase the size of sub-reportas where it is separately created.
You could try using background band for those lines.
Maybe inside your parent report
When you create a sub-report you can delete; Page Header, Column Header and Page Footer bands on your main report. After then, you can drag and drop sub-report icon on Summary part of your main report. You will probably use ColumnHeader and Detail bands on your Sub-Report. (It depends on your design. If you use subreports recursively, you can use again summary band.) Later,you will select Remove Report Margins on your subreport. To get expected result; your subreport icon Width on main report should equal your subreport page width.
Adding borders worked great for me. Expand your text element to cell size, right click -> Padding and Borders and add them all around. It's easier than having to handle draw lines. Less elements and faster editing.
You can add lines via the iReport Designer gui interface using the Palette (go to Window > Palette, then click Line, then drag it over to the Designer).
You can also add lines by modifying the jrxml code directly. I haven't found guidance in the documentation on this. But this answer to another question shows how to create a vertical line:
<line>
<reportElement x="0" y="0" width="1" height="30"/>
</line>
And it also shows how to create a horizontal line:
<line>
<reportElement x="0" y="0" width="30" height="1"/>
</line>
Also, the JRXML Sources and Jasper Files section of the documentation has some more involved code such as the following, which uses a direction parameter with value BottomUp (there are also references to TopDown in the community site or here):
<line direction="BottomUp">
<reportElement key="line" x="1" y="4" width="554" height="1"/>
</line>
And this, which uses positionType parameter of FixRelativeToBottom:
<line>
<reportElement positionType="FixRelativeToBottom" x="0" y="51" width="555"
height="1"/>
</line>