Jump to content
JasperReports Library 7.0 is now available ×

How to sent datasource from web to iReport


2006 IR Open Dicussion

Recommended Posts

By: apple - apple_it

How to sent datasource from web to iReport

2006-05-27 10:29

How to sent datasource from web to iReport-1.2.1 for make chart.Where should I config in iReport. this is my source code:

 

ServletOutputStream servletOutputStream = response.getOutputStream();

File reportFile = new File("D:/iReport_2/IT_Pie.jasper");

byte[] bytes = null;

try{

Map param = new HashMap();

param.put("dept_name",dept);

ReportDataSource source = new ReportDataSource();

for(int i =0;i<arrITb.length;i++){

ReportItem data = new ReportItem();

data.setField("emp_id",arrITb.getEmp_id());

data.setField("emp_firstname",arrITb.getEmp_firstname());

data.setField("emp_surname",arrITb.getEmp_surname());

data.setField("emp_salary",""+arrITb.getEmp_salary());

data.setField("dept_id",arrITb.getDept_id());

data.setField("dept_name",arrITb.getDept_name());

source.addData(data);

}

source.first();

bytes = JasperRunManager.runReportToPdf("D:/iReport_2/IT_Pie.jasper",param,source);

response.setContentType("application/pdf");

response.setContentLength(bytes.length);

servletOutputStream.write(bytes, 0, bytes.length);

servletOutputStream.flush();

servletOutputStream.close();

}catch (Exception e){

StringWriter stringWriter = new StringWriter();

PrintWriter printWriter = new PrintWriter(stringWriter);

e.printStackTrace(printWriter);

response.setContentType("text/plain");

response.getOutputStream().print(stringWriter.toString());

}

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...