yael Posted February 5, 2007 Share Posted February 5, 2007 Hi, I need generator report for my java program.I want that this generator report will get a query and build me a report. ( and I want to be able to print this reports).Soooo, /I get a recommend from sun forum to use with JasperForge.I don't know what exactly I need to download for use the JasperForge in my java project (Eclips IDE).I got this link:http://www.jasperforge.org/index.php?option=com_content&task=section&id=16&Itemid=277 But I don't understand what I need to download.Am I have iReport, JasperIntelligence, JasperETL to?Or only JasperReports 1.2.8 - General Availability ??Then, I can't find the jar...:whistle:Thanking you in anticipation,Yael Link to comment Share on other sites More sharing options...
wegnerk Posted February 5, 2007 Share Posted February 5, 2007 Hi Yael, if you want to use jasperreports in your java-application, download JasperReports (the newest Version is 1.3.0), take the project.zip. the jar is in the DIST/subfolder. under demo/samples, you find some example reports with java classes and jrxml files, where you can see how to use jasperreports in java. For creating a report, install IReport, there you can visually design a report, create a database connection and query and test the report. hope, this helps a bit Link to comment Share on other sites More sharing options...
yael Posted February 5, 2007 Author Share Posted February 5, 2007 Thanks!!!,I was download iReport & JasperForge.My goal now is to print all names in a report from java.What I need for this?I tried to write this code, but I don't understand why all the examples used whit jasper file, or jrxml file.I have to create this file? Code:public class laporan { public laporan() { } public void geraRelatorio() throws JRException, Exception, SQLException { // design JasperDesign design = JRXmlLoader.load("hello.jrxml"«»); // report JasperReport report = JasperCompileManager.compileReport(design); // THIS // LINE // CRASH // request Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"«»); Connection conn = DriverManager .getConnection( "jdbc:«»sqlserver://matarotsrv:1433;databaseName=qm6", "sa", "sa"«»); Statement stm = conn.createStatement(); String query = "SELECT contacts.first_name FROM contacts"; Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(query); // JRdataSource JRDataSource dataSource = new JRResultSetDataSource(rs); Map params = new HashMap(); // print JasperPrint print = JasperFillManager.fillReport(report, params, dataSource); // exports JasperExportManager.exportReportToHtmlFile(print, "hello.html"«»); } public static void main(String[] args) throws JRException, SQLException, Exception { laporan report = new laporan(); report.geraRelatorio(); }} I just coppy past a few examples and tried to understood them...Thank you :kiss: Link to comment Share on other sites More sharing options...
wegnerk Posted February 5, 2007 Share Posted February 5, 2007 the jrxml file is necessary, because this is where you define, what your report looks like.You can open IReport and generate a new report, where you can set your fields (database fields) and variables and parameter as you like. in java, that jrxml template is compiled and filled with data. If you really want to work a lot with jasper, it would be very good to buy the documentation or a book about it, because at the beginning it could be quite tricky... 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