I want to know is that possible to change properties value of fields in iReport, using Java external application.
For example, firstly I create a report name abc.jrxml. Here is a part of XML code of abc.jrxml file.
<reportElement x="117" y="2" width="65" height="20" uuid="2f281676-e098-4213-b1d3-57b845960b2a"/>
I want to change that values: x="117" to x="200". height="20" to height="25". I want to try it by java commands. Is that possible or not. If it is possible how can I can make it.
As Alex K. pointed out, the best way to change attributes with a Java application is to create the Reports with the Jasper Reports API.
For example in one answer to http://community.jaspersoft.com/questions/525188/dynamic-width-textfied-parameter the width of an object was changed before the report was generated:
JasperDesign design = xmlLoader.loadXML(..jrxmlStream..);
JRElement[] elements = design.getDetail().getElements();
String elementKey = ..key of element to modify..;
int newWidth = ..new element width..;
for (int i = 0; i < elements.length; i++)
{
JRDesignElement element = (JRDesignElement) elements[i];
if (elementKey.equals(element.getKey())) {
element.setWidth(newWidth);
}
}
You can use additionally setHeight
, setX()
and setY()
to change the elements properties.
More information is provided here: http://community.jaspersoft.com/wiki/jasperreports-library-reference-materials