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 is the purpose of @beforeresult annotation?
List some struts tag libraries?
Why was reload removed from struts (since 1.1)?
Describe the mvc on struts?
What are the reasons for an error message not being displayed while developing struts application?
What is struts.devmode?
When do I need “struts.jar” on my classpath?
What is the difference between plain-validator and field-validator?
What is s token?
Which interceptor is responsible for mapping request parameters to action class Java Bean properties?
In which order struts framework searches for a message bundle?
What’s the difference between struts and espresso?
What types of validations are available in xml based validation in struts2?
Explain the difference between jakarta struts and apache struts?
What is meant by custom tags?