Jump to content
We've recently updated our Privacy Statement, available here ×

Jasper Reports


askme

Recommended Posts

Hi all,

                   I am new to jasper reports. I tried to work around with some sample code and by using a .jrxml file. But i had  errors as i progressed.

Can somebody help me with generating the jasper report without using .jrxml file. It's like using the jave code . Below mentioned is the code that i tried.

If you can see the code below i have set the page height as a static data. Is it possible that i can set the pageheight dynamically according to the data that i have in my hashmap.

And  probably i may have 500 rows of data which should come under proper column headings like

Student Name         Class            Total Marks              Result

aaa                             X                      1000                        Pass

bbb                             X                         870                       Pass

 

And all the passed students Result should be shown in green color and the failed students Result should be shown in red color.

And if the data exceeds a particular page height the remaining results should be shown in the next page and so on. and finally the report should be exported to .pdf format.

 

How to include all these features with java code rather than using the .jrxml file

 

 

Any help would be appreciated

Thanks

Code:
JRDesignTextField mJRDesignTextField;        JRDesignExpression mJRDesignExpression;        JRDesignParameter mJRDesignParameter;        JRFont mJRFont;JasperDesign jasperDesign = new JasperDesign();	    jasperDesign.setName("Report");	    jasperDesign.setLeftMargin(10);	    jasperDesign.setRightMargin(10);	    jasperDesign.setBottomMargin(10);	    jasperDesign.setTopMargin(10);	    jasperDesign.setPageHeight(2000);	    jasperDesign.setPageWidth(800);	   	    jasperDesign.setIgnorePagination(false); JRDesignStyle titleText = new JRDesignStyle();        titleText.setName("titleText");        titleText.setDefault(false);        titleText.setMode(JRElement.MODE_OPAQUE);        titleText.setFontName("Arial");        titleText.setBackcolor(new Color(10025880));        titleText.setFontSize(16);                titleText.setLineSpacing(new Byte((byte) 10));        titleText.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_CENTER);        try {			jasperDesign.addStyle(titleText);		} catch (JRException e) {			e.printStackTrace();		}JRDesignStyle headingText = new JRDesignStyle();        headingText.setName("headingText");        headingText.setMode(JRElement.MODE_OPAQUE);        headingText.setFontName("Arial");        headingText.setForecolor(new Color(16777215));        headingText.setBackcolor(new Color(6776679));        headingText.setFontSize(10);        try {			jasperDesign.addStyle(headingText);		} catch (JRException e) {						e.printStackTrace();		}JRDesignBand band = new JRDesignBand();        band.setHeight(30);        JRDesignStaticText statictextField = new JRDesignStaticText();        statictextField.setText("Student Report");        statictextField.setX(0);        statictextField.setY(0);        statictextField.setWidth(775);        statictextField.setHeight(26);        statictextField.setStyle(titleText);        JRDesignLine line = new JRDesignLine();        line.setX(0);        line.setY(26);        //line.setWidth(515);        line.setHeight(0);        band.addElement(statictextField);        band.addElement(line);        jasperDesign.setTitle(band); 
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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...