greenfield82 Posted April 28, 2008 Share Posted April 28, 2008 Hi, I have a collection of data that I need to display in the report and create .PDF file after that. The problem is the size of collection is not fixed, and I don't know how to create report columns dynamically. For example, a collection of Dates {Date_1, Date_2, ..., Date_n}, each Date_# takes 1 column in the report. Please share with me if there are some ways to do that with Jasper Report. Another small problem is how to wrap data in 1 cell of the report. I have a column called 'Name', some names are so long that they can't be displayed fully in a cell. Is there any way to wrap it? Tkx... Post edited by: greenfield82, at: 2008/04/27 18:47 Link to comment Share on other sites More sharing options...
dnvsrikanth Posted April 28, 2008 Share Posted April 28, 2008 hi greenfield82 U can do this by using Velocity framework along with JasperReports. Refer this link: http://www.ibm.com/developerworks/websphere/library/techarticles/0505_olivieri/0505_olivieri.html For the second problem you have mentioned, there will be an attribute called isStretchWithOverflow for every text field. Set that attribute to true. The text in the text field will get wrapped within the text field in the report DNV Srikanth Link to comment Share on other sites More sharing options...
dima_toxsoft Posted April 28, 2008 Share Posted April 28, 2008 Hi! Sorry for my poor English.When i faced the same ptoblem (dynamical column) i generateв reports on fly. Here java sample: private JasperDesign getSubreportDesign( int aSubreportNumber, List<String> aColumnNames ) throws JRException { JasperDesign jasperDesign = new JasperDesign();... // Dynamic columns int dynamicColumnWidth = (DEFAULT_COLUMN_WIDTH - (DATE_COLUMN_WIDTH + REGISTER_COLUMN_WIDTH + PARALLEL_COLUMN_WIDTH)) / columnQtty; int start_x = DATE_COLUMN_WIDTH + REGISTER_COLUMN_WIDTH + PARALLEL_COLUMN_WIDTH; for( int i = 0; i < columnQtty; i++ ) { staticText = new JRDesignStaticText(); staticText.setX( start_x ); staticText.setY( 0 ); staticText.setWidth( dynamicColumnWidth ); staticText.setHeight( SUBREPORT_COLUMN_HEADER_HEIGHT ); staticText.setHorizontalAlignment( JRAlignment.HORIZONTAL_ALIGN_CENTER ); staticText.setVerticalAlignment( JRAlignment.VERTICAL_ALIGN_MIDDLE ); staticText.setText( convert2HTML(aColumnNames.get( i )) ); setBox( staticText, (i == (columnQtty - 1)) ); staticText.setStyledText( true ); band.addElement( staticText ); start_x += dynamicColumnWidth; } jasperDesign.setColumnHeader( band ); The same manner make detail fields Link to comment Share on other sites More sharing options...
broschb Posted May 22, 2008 Share Posted May 22, 2008 I have run into the same problem, I just created a blog post that goes through solving this issue using a JRBeanCollectionDataSource, and specifying the columns at runtime. Check it out and let me know if you have any questions. http://broschb.blogspot.com/2008/05/dynamic-jasper-report-using-crosstabs.html Link to comment Share on other sites More sharing options...
amirage_m_b Posted June 24, 2008 Share Posted June 24, 2008 I agree with Dima,.. I use to generate the report on the fly,.. I make some function that generate some static and field text according to the data query that we want to create,.. Link to comment Share on other sites More sharing options...
pvradhakrishna Posted June 25, 2008 Share Posted June 25, 2008 I would really appreciate if you guys amirage_m_b and dima_toxsoft post example code with as much detail as possible or post as an attachment. Looking forward for the example source!!! ThanksKrishnaPost edited by: pvradhakrishna, at: 2008/06/25 14:24 Link to comment Share on other sites More sharing options...
amirage_m_b Posted June 27, 2008 Share Posted June 27, 2008 maybe you should try this,.. mm, i'm sorry but i used my mother language, so maybe you don't uderstand some of the functions,.. [file name=Report_v2.zip size=3969] Post edited by: amirage_m_b, at: 2008/06/27 03:33 Link to comment Share on other sites More sharing options...
djmamana Posted June 27, 2008 Share Posted June 27, 2008 Hi there, actually there is a Java API that works over JasperReports that attacks exactly the dynamic columns issue. It is called DynamicJasper It is pretty well documented with lots of examples. Here you have an example Code: and this is the results size=404]http://dynamicjasper.sourceforge.net/images/examples/group-default-style.jpg (broken image link} As you can see, you can also define groups, styles, etc... Luckily it will meet your needs Regards Dj Post edited by: djmamana, at: 2008/06/27 03:39 Link to comment Share on other sites More sharing options...
ronelvcabrera007 Posted August 31, 2016 Share Posted August 31, 2016 is there a PHP format for this? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now