Jump to content

Dynamic Jasper reports Help


pnvswamy

Recommended Posts

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

If you have dynamic columns, it means your report template actually changes at runtime.

You can create dynamic report templates at runtime by using the JasperReports API directly like shown in the /demo/samples/noxmldesign sample provided with the project distribution file.

Depending on the actual structure of the document, maybe a crosstab could also help.

In the future we'll probably have a true table component in JasperReports, but for now you have to try the above mentioned solutions.

 

I hope this helps.

Teodor

 

Link to comment
Share on other sites

  • 8 months later...

Hi Teodor,

 

Thanks for guiding/supporting us.

is there any code/sample developed for table component. if so can u post the link.

 

As well u have mentioned: /demo/samples/noxmldesign for dynamic column header & field.

how can we say it as dynamic since the fields are hard coded. Is it possible for us to fetch the fields as array and by hadling the loop is it possible to form the column header & detail band with that array dynamically.

if so can you please post me that code sample

 

Code:

i am expect something like getting field count dynamically & form the column header , detail dynamically  using the loop,

like the one below for column header:

for (i=0; i<count(total); i++){

field.setName(array[i]);		field.setValueClass(java.lang.String.class);		jasperDesign.addField(field);

}

 

for detail,

var leftPosition = 0;

for (i=0; i<count(total); i++){

textField = new JRDesignTextField();
        textField.setX(leftPosition);
        textField.setY(4);
        textField.setWidth(50);
        textField.setHeight(15);
        textField.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_RIGHT);
        textField.setStyle(normalStyle);
        expression = new JRDesignExpression();
        expression.setValueClass(java.lang.String.class);
        expression.setText("$F{array}");
        textField.setExpression(expression);
        band.addElement(textField);

 

leftPosition = leftPosition+100;

}



Post Edited by vembu at 21/07/2009 12:24
Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...