Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Other Open Source Projects and the fly likes Need help writing Jasper report by hand with Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Need help writing Jasper report by hand with Java" Watch "Need help writing Jasper report by hand with Java" New topic

Need help writing Jasper report by hand with Java

Anne M Crace

Joined: Aug 07, 2013
Posts: 7
Is anybody experienced with Jasper reports? I have a Swing GUI with a JTable and the user can choose the columns they want displayed at runtime. I am passing a DefaultTableModel through my application. I was able to get my report to work when I generated it in iReport with COLUMN_0, COLUMN_1, etc. but it would only display when all the columns were selected. I believe I need to generate the .jasper file manually with JasperReports API. I am able to generate the .jasper file and decompile it with iReport but the first problem I am having is all of the fields I am passing in aren't being generated. The other problem is I need to associate the JRDesignTextFields with the Fields. I'm sure I'm going to have other problems (the commented out lines near the bottom blow up). Anyhow, any help would be appreciated. I am using version 4.7.1 of iReport and Jasper Reports so I don't have quite the latest version. Here is my Java code:
James Boswell

Joined: Nov 09, 2011
Posts: 1012

What happens when you execute the commented out lines? Can you post the entire stack trace of any exception?
Anne M Crace

Joined: Aug 07, 2013
Posts: 7
Here's the stack trace. The last line starts my Swing code so that and anything after is probably irrelevant.
java.lang.ClassCastException: net.sf.jasperreports.engine.fill.JRFillFrame cannot be cast to net.sf.jasperreports.engine.fill.JRFillElementGroup
at net.sf.jasperreports.engine.fill.JRFillElement.<init>(
at net.sf.jasperreports.engine.fill.JRFillTextElement.<init>(
at net.sf.jasperreports.engine.fill.JRFillStaticText.<init>(
at net.sf.jasperreports.engine.fill.JRFillObjectFactory.visitStaticText(
at net.sf.jasperreports.engine.base.JRBaseStaticText.visit(
at net.sf.jasperreports.engine.JRAbstractObjectFactory.getVisitResult(
at net.sf.jasperreports.engine.fill.JRFillElementGroup.<init>(
at net.sf.jasperreports.engine.fill.JRFillElementContainer.<init>(
at net.sf.jasperreports.engine.fill.JRFillBand.<init>(
at net.sf.jasperreports.engine.fill.JRFillObjectFactory.getBand(
at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(
at net.sf.jasperreports.engine.fill.JRFiller.createFiller(
at net.sf.jasperreports.engine.fill.JRFiller.fill(
at net.sf.jasperreports.engine.JasperFillManager.fill(
at net.sf.jasperreports.engine.JasperFillManager.fill(
at net.sf.jasperreports.engine.JasperFillManager.fillReport(
at DTP_utils.PrintRoster.testPrint(
It is sorta covered in the JavaRanch Style Guide.
subject: Need help writing Jasper report by hand with Java
Similar Threads
error while creating jasper report using jasper apis
JasperReports: "Error loading object from file" Exception
Generate excel reports using jasper report
Jasper Reports from a written query of Java
exported Jasper Report has different look than preview in IReport designer