andber Posted July 31, 2010 Share Posted July 31, 2010 I am needing print only a attributes from a object without DB connection and dataset.I have for example the object "Student" and I need print the following attributes:NameLast NameYearI am using the following source code: try { String strFile; Map Data= new HashMap(); Data.put("Name", "Pepe"); Data.put("Lastname", "Perez"); Data.put("Year", "2010"); strFile = "StudentReport.jasper"; JasperReport masterReport = null; masterReport = (JasperReport) JRLoader.loadObject(strFile); JasperPrint jp = JasperFillManager.fillReport(masterReport, Data, new JREmptyDataSource()); JasperViewer view = new JasperViewer(jp,false); view.setTitle("title"); view.setVisible(true); } catch (JRException ex) { Logger.getLogger(ImpApp.class.getName()).log(Level.SEVERE, null, ex); }This code print a withe paper, why? I need this print the data:PepePerez2010How I can do that?Thanks in advance,Andrés. Link to comment Share on other sites More sharing options...
marciopd Posted August 1, 2010 Share Posted August 1, 2010 Take a look at this post:http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=76965&topid=77042#77042Maybe what you really need is a JRBeanDataSource. Very simple to use. You pass a collection of your own beans to the reports as a datasource, so the fileds of the report are your bean's fields (whth getter and setters). hope it helps 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