Reputation: 401
I want to update my JasperReports version from 4.0.1 to the current 5.5.0.
My reports are generated, therefore I use a template-report. I have to replace the DetailBand, so I'm using getDetail()
to get the band of my template-detail-section. After extracting some information and creating a new JRDesignBand newBand
I'm using setDetail(newBand)
. Works!
With 5.5.0 this two methods are not available anymore. To get the band I can use something like this:
But how to replace setDetail(newBand)
???
I found this peace of code:
((JRDesignSection)jasperDesign.getDetailSection()).addBand(band);
But this adds the band, so I have 2 bands in my details-section. But I just need the new one...
Thank you!
Upvotes: 1
Views: 1601
Reputation: 8986
You simply need to call removeBand(band)
on the JRDesignSection
to remove the old band. It shouldn't matter whether you do this before or after adding the new band, but it will
leave you with just the new band present. E.g:
((JRDesignSection)jasperDesign.getDetailSection()).addBand(newBand);
((JRDesignSection)jasperDesign.getDetailSection()).removeBand(oldBand);
Upvotes: 1