@RequestMapping("seatCheckInAndCheckOutQuery")
public ModelAndView seatCheckInAndCheckOutQuery(HttpServletRequest request,SignIn sign, String format ,HttpServletResponse response) throws Exception{
JasperDesign jdesign = JRXmlLoader
.load("D:/callcenter2017uat/callcenter/WebRoot/WEB-INF/jasper/actionDataJasper/seatCheckInAndCheckOut.jrxml");
HashMap map = new HashMap();
if(null != sign.getSignInId() && !"".equals(sign.getSignInId())){
map.put("signInTime","1");
}
JasperReport jreport = JasperCompileManager.compileReport(jdesign);
List<JasperInfoTen> list = signService.findSeatCheckInAndOutCondtion(sign);
JRDataSource jrDataSource = new JRBeanCollectionDataSource(list);
JasperPrint jprint = JasperFillManager.fillReport(jreport, map,
jrDataSource);
if("html".equals(format)){
JasperExportManager.exportReportToHtmlFile(jprint,
"D:\\BaiduMusic\\demo.html");
}else{
SimpleXlsxReportConfiguration conf = new SimpleXlsxReportConfiguration();
conf.setOnePagePerSheet(Boolean.FALSE);
conf.setRemoveEmptySpaceBetweenRows(Boolean.FALSE);
conf.setWhitePageBackground(Boolean.FALSE);
JRXlsExporter exporter = new JRXlsExporter();
exporter.setConfiguration(conf);
ExporterInput exporterInput = new SimpleExporterInput(jprint);
exporter.setExporterInput(exporterInput);
OutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput("D:\\BaiduMusic\\demo.xls");
exporter.setExporterOutput(exporterOutput);
exporter.exportReport();
return null;
}
//
//ireport实现导出excel
// ByteArrayOutputStream outPut=new ByteArrayOutputStream();
// FileOutputStream outputStream=null;
// File file=new File("D:\\BaiduMusic\\demo.xls");
//
// try {
//
// JRAbstractExporter exporter = new JRXlsExporter();
// //创建jasperPrint
// exporter.setParameter(JRExporterParameter.JASPER_PRINT,jprint);
// //生成输出流
// exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,outPut);
// //去除两行之前的空白
// exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE);
// //设置所有页只打印到一个Sheet中
// exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET,Boolean.FALSE);
// //设置Excel表格的背景颜色为默认的白色
// exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND,Boolean.FALSE);
// exporter.exportReport();
// outputStream=new FileOutputStream(file);
// outputStream.write(outPut.toByteArray());
// } catch (JRException e) {
// e.printStackTrace();
// }catch (Exception e) {
// e.printStackTrace();
// }finally{
// try {
// outPut.flush();
// outPut.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// response.sendRedirect("/actionDataJasper/demo.html");
ModelAndView mv = new ModelAndView();
mv.setViewName("/actionDataJasper/demo");
return mv;
}
}
public ModelAndView seatCheckInAndCheckOutQuery(HttpServletRequest request,SignIn sign, String format ,HttpServletResponse response) throws Exception{
JasperDesign jdesign = JRXmlLoader
.load("D:/callcenter2017uat/callcenter/WebRoot/WEB-INF/jasper/actionDataJasper/seatCheckInAndCheckOut.jrxml");
HashMap map = new HashMap();
if(null != sign.getSignInId() && !"".equals(sign.getSignInId())){
map.put("signInTime","1");
}
JasperReport jreport = JasperCompileManager.compileReport(jdesign);
List<JasperInfoTen> list = signService.findSeatCheckInAndOutCondtion(sign);
JRDataSource jrDataSource = new JRBeanCollectionDataSource(list);
JasperPrint jprint = JasperFillManager.fillReport(jreport, map,
jrDataSource);
if("html".equals(format)){
JasperExportManager.exportReportToHtmlFile(jprint,
"D:\\BaiduMusic\\demo.html");
}else{
SimpleXlsxReportConfiguration conf = new SimpleXlsxReportConfiguration();
conf.setOnePagePerSheet(Boolean.FALSE);
conf.setRemoveEmptySpaceBetweenRows(Boolean.FALSE);
conf.setWhitePageBackground(Boolean.FALSE);
JRXlsExporter exporter = new JRXlsExporter();
exporter.setConfiguration(conf);
ExporterInput exporterInput = new SimpleExporterInput(jprint);
exporter.setExporterInput(exporterInput);
OutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput("D:\\BaiduMusic\\demo.xls");
exporter.setExporterOutput(exporterOutput);
exporter.exportReport();
return null;
}
//
//ireport实现导出excel
// ByteArrayOutputStream outPut=new ByteArrayOutputStream();
// FileOutputStream outputStream=null;
// File file=new File("D:\\BaiduMusic\\demo.xls");
//
// try {
//
// JRAbstractExporter exporter = new JRXlsExporter();
// //创建jasperPrint
// exporter.setParameter(JRExporterParameter.JASPER_PRINT,jprint);
// //生成输出流
// exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,outPut);
// //去除两行之前的空白
// exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE);
// //设置所有页只打印到一个Sheet中
// exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET,Boolean.FALSE);
// //设置Excel表格的背景颜色为默认的白色
// exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND,Boolean.FALSE);
// exporter.exportReport();
// outputStream=new FileOutputStream(file);
// outputStream.write(outPut.toByteArray());
// } catch (JRException e) {
// e.printStackTrace();
// }catch (Exception e) {
// e.printStackTrace();
// }finally{
// try {
// outPut.flush();
// outPut.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// response.sendRedirect("/actionDataJasper/demo.html");
ModelAndView mv = new ModelAndView();
mv.setViewName("/actionDataJasper/demo");
return mv;
}
}