This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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: 8
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: 1051

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: 8
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(
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Need help writing Jasper report by hand with Java
It's not a secret anymore!