Set the border of the sub-report of jasper with a heading and a group of parts

I am working on a grails project that uses a jasper plugin to download a document in pdf and doc format.

I have several jasper subargents and using these subscriptions in a dynamic jasper to load a pdf and docx document. I use the dynamic jasper report because the sublease positions of jasper can be different.

My jasper sub has a header and a group of details.

enter image description here

output

enter image description here

Now my problem is the border. A border is required, for example:

enter image description here

I tried to set the rectangle, the frame, but all failed because the two stripes did not share the same sky (component).

My requirement is a border through jasper report or through dynamic jasper. I have no idea how to set the border.

EDIT ................................................. .......................

I also tried to set the border using a frame and a rectangle using a dynamic jasper code, and the output is:

enter image description here

frame and rectangle not covering the entire subordinate. Here is my code:

JRDesignRectangle rectangle = new JRDesignRectangle(); //JRDesignFrame rectangle = new JRDesignFrame(); rectangle.setX(subReport.getX()); rectangle.setY(subReport.getY()); rectangle.setHeight(subReport.getHeight()); rectangle.setWidth(subReport.getWidth()); rectangle.setPositionType(PositionTypeEnum.FLOAT); band.addElement(rectangle); 
+4
source share
1 answer

If you are using the jasper report plugin, you can open the JRXML file and say something like

  <box> <topPen lineWidth="1.0"/> <leftPen lineWidth="1.0"/> <bottomPen lineWidth="1.0"/> <rightPen lineWidth="1.0"/> </box> 

Jasper reports come with a great designer called " IReport Designer ." You can use the concept of frames in the IReport designer and put your sub-report in a frame, and then apply the property border on the frame itself. You can also find BorderAroundTable . I would definitely recommend these links.

How to add a border to a subport

Frame around two add-ons

Jasper Report Border

Let us know if this solution works for you.

If it can work for subtitles that have a summary and page title, then this can also help your case.

Editing and adding a main report and an auxiliary message code with a border

Source code of the main report

 <?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="testborder" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <background> <band splitType="Stretch"/> </background> <detail> <band height="421" splitType="Stretch"> <subreport> <reportElement x="25" y="148" width="200" height="100"/> <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression> <subreportExpression><![CDATA["C:\\jaspersamples\\testborder_subreport1.jasper"]]></subreportExpression> </subreport> <frame> <reportElement x="45" y="119" width="390" height="176"/> <box> <topPen lineWidth="2.0" lineStyle="Solid"/> <leftPen lineWidth="2.0" lineStyle="Solid"/> <bottomPen lineWidth="2.0" lineStyle="Solid"/> <rightPen lineWidth="2.0" lineStyle="Solid"/> </box> </frame> </band> </detail> </jasperReport> 

Subreport Source Code

 <?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="testborder_subreport1" language="groovy" pageWidth="802" pageHeight="555" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="802" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <background> <band splitType="Stretch"/> </background> <pageHeader> <band height="29" splitType="Stretch"> <staticText> <reportElement x="317" y="5" width="100" height="20"/> <textElement/> <text><![CDATA[HELLO TEST]]></text> </staticText> </band> </pageHeader> <summary> <band height="29" splitType="Stretch"> <staticText> <reportElement x="317" y="0" width="100" height="20"/> <textElement/> <text><![CDATA[i am testing BORDER]]></text> </staticText> </band> </summary> </jasperReport> 

The result is somewhat similar to this.

enter image description here

+3
source

Source: https://habr.com/ru/post/1496538/


All Articles