can anyone help me to send the code for Jasper Reporting in
java?plz
Answer Posted / ram
//this code is very easy any one can understand easily
//1. these are the packages which we need to import
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.design.JRDesignQuery;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.view.JasperViewer;
//2. this is the java code for developing reports
try{
Connection con=(Connection)
Connectivity.makeconnection();// Database Connection
File path=new File("Report/");
JasperDesign jasperDesign =
JRXmlLoader.load(path.getAbsolutePath()+"\\allbooksreport.jrxml");//here
allbooksreport is my jrxml file name ...//xml file
Map parameters = new HashMap();
parameters.put("DataSource" ,con);
JRDesignQuery query =new JRDesignQuery();
query.setText("select * from add_book");
jasperDesign.setQuery(query);
JasperReport jasperReport =
JasperCompileManager.compileReport(jasperDesign);
JasperPrint jasperPrint =
JasperFillManager.fillReport(jasperReport,parameters,con);
JasperViewer vwrpt = new
JasperViewer(jasperPrint,false);
vwrpt.show(); //...//view the report
vwrpt.setTitle("All Books Report");
} catch(Exception e) {
e.getMessage();
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What are action errors and error and what are the consequences they impose?
Can explain about the validations and in your project where did u used the validations?
in struts how to use hibernate with struts>
What is the purpose of @emailvalidator annotation?
How to combine the struts with velocity template?
What is the purpose of @conversionerrorfieldvalidator annotation?
Why it called struts?
How is forward action used for integration?
What is the use of struts?
How to build struts application in eclipse?
What is controller in struts2?
In struts, how can we access java beans and their properties?
How does struts2 token work?
Which class is the Front Controller in Struts2?
What is Custom Type Converter in Struts2?