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 the aware interfaces in struts2?
What is the front controller in struts2?
How is a lookup dispatch action created?
How do you convert struts to springs?
What are the core components of a struct2 based application?
How struts2 supports internationalization?
What is the use of execAndWait interceptor?
What do you mean by tiles in struts?
Difference between struts and spring?
What are the two types of validations supported by validator framework?
What is the struts in java?
How can we group related actions in one group in Struts?
How many struts config file in a struts application?
What is the procedure of operation of a form tag?
What are action errors?