尝试在java中生成pdf时,Jasper报告中未显示java列表的第一个数据。
MY JRXML代码:
@RequestMapping(value = ClinicRestURIConstants.APPOINTMENTREPORT, method = RequestMethod.GET)
public byte[] appointmentReport(HttpServletRequest request, HttpServletResponse response,@PathVariable Integer clinic_id,@PathVariable Integer branch_id,@PathVariable Integer doctor_id)
throws JRException,IOException,DocumentException,SAXException {
List<Appointment> appointmentList;
appointmentList = appointmentreportservice.appReport(clinic_id,branch_id,doctor_id);
String reportLocation ="E:\\ClinicManagementNew\\Clinic\\src\\main\\webapp\\static\\jrxml\\appointmentReport.jrxml";
JasperReport jasperReport = JasperCompileManager.compileReport(reportLocation);
File image = new File("E:\\ClinicManagementNew\\Clinic\\src\\main\\webapp\\static\\img\\logo.png");
FileInputStream path = new FileInputStream(image);
HashMap map = new HashMap();
map.put("Image",path);
if (jasperReport != null) {
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, map, new JRBeanCollectionDataSource(appointmentList));
response.setHeader("Content-disposition","inline; filename = Report.pdf");
OutputStream outputStream = response.getOutputStream();
JRPdfExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream);
exporter.exportReport();
}
return null;
}
这是我的java控制器代码:
INSERT INTO `users` (`date`, `first_name`, `last_name`, `username`, `email`, `image`, `password`, `role`) VALUES (NULL, '$first_name', '$last_name', '$username', '$email', '$image', '$password', '$role');
此java列表返回两行,但pdf中只显示一行。如何显示该pdf中的第一行。
请有人帮助我解决这个问题。提前谢谢。
答案 0 :(得分:0)
在Jasper工作室
在你的java代码中添加你的列表“appointmentList”作为参数。
map.put("MyDS",appointmentList);