DynamicReports 简略运用ITeye - 凯时娱乐

DynamicReports 简略运用ITeye

2019年04月03日10时13分51秒 | 作者: 又亦 | 标签: 付款,序号,金额 | 浏览: 2159

效果图


public void export(@Valid PaymentChartQuery dto, HttpServletRequest request, HttpServletResponse response){
 List ColumnBuilder colms=new ArrayList ();
 colms.add(col.reportRowNumberColumn("序号").setHorizontalTextAlignment(HorizontalTextAlignment.CENTER));
 colms.add(col.column("出售单号","fsSellNo",type.stringType()));
 colms.add(col.column("日期","fsSellDate",type.stringType()));
 colms.add(col.column("结账时刻","fsCheckEndTime",type.stringType()));
 colms.add(col.column("付款金额","fdReceMoney",type.bigDecimalType()));
 colms.add(col.column("付款方法","fsPaymentName",type.stringType()));
 colms.add(col.column("班别","fsShiftName",type.stringType()));
 colms.add(col.column("账单号","fsCheckBillNo",type.stringType()));
 colms.add(col.column("收银员","fsCashier",type.stringType()));
 colms.add(col.column("补白","fsNote",type.stringType()));
 String filename= "付款明细表";
 try {
 filename = new String(filename.getBytes(), "iso8859-1");//处理中文 文件名问题
 response.setContentType("application/vnd.ms-excel;charset=UTF-8");
 response.setHeader("Content-disposition", "attachment;filename="+filename+".xls");
 //outstream
 OutputStream outputStream = response.getOutputStream();
 JasperXlsExporterBuilder xlsExporter = export.xlsExporter(outputStream).addSheetName("付款明细表")
 .setDetectCellType(true).setIgnorePageMargins(true).setWhitePageBackground(false)
 .setRemoveEmptySpaceBetweenColumns(true);
 dto.setPrint(true);
 Map String,Object map=paymentChartService.queryPaymentChart(dto);
 List PaymentChartDTO list=(List)map.get(ResultCode.DATA);
 List PaymentChartTotalDTO total= (List)map.get(ResultCode.TOTAL);
 SubreportBuilder subreport1 = cmp.subreport(createTotal(total)).setFixedWidth(700);
 JasperReportBuilder report=report();
 report.setTemplate(Templates.reportTemplate)
 .ignorePageWidth()
 .title(cmp.horizontalList(subreport1),cmp.verticalGap(20))
 .columns(colms.toArray(new ColumnBuilder[colms.size()]))
 .setHighlightDetailEvenRows(true) //偶数行高亮显现
 .highlightDetailEvenRows()
 .setDataSource(list)
 .toXls(xlsExporter);
 outputStream.flush();
 outputStream.close();
 }catch (IOException e) {
 e.printStackTrace();
 }catch (DRException e) {
 e.printStackTrace();
 * 算计
 * @param list
 * @return
 private JasperReportBuilder createTotal(List PaymentChartTotalDTO list){
 JasperReportBuilder report = report();
 PaymentChartTotalDTO total= list.remove(0); //总计:
 List ColumnBuilder colms=new ArrayList ();
 TextColumnBuilder String fsPaymentName_col=col.column("付款方法","fsPaymentName",type.stringType()).setWidth(100);
 TextColumnBuilder BigDecimal fdReceMoney_col=col.column("金额","fdReceMoney",type.bigDecimalType()).setWidth(100);
 colms.add(col.reportRowNumberColumn("序号").setHorizontalTextAlignment(HorizontalTextAlignment.CENTER));
 colms.add(fsPaymentName_col);
 colms.add(fdReceMoney_col);
 colms.add(col.percentageColumn("份额 %", fdReceMoney_col));
 //饼图
 PieChartBuilder pie_payment = cht.pieChart()
 .setTitle("payment chart")
 .setTitleFont(stl.fontArialBold())
 .setKey(fsPaymentName_col).setShowLegend(false)
 .series(cht.serie(fdReceMoney_col));
 //列表
 report.setTemplate(Templates.reportTemplate_2)
 .columns(colms.toArray(new ColumnBuilder[colms.size()]))
 .subtotalsAtSummary(sbt.text("算计:",fsPaymentName_col),sbt.sum(fdReceMoney_col))
 .setDataSource(list);
 SubreportBuilder subreport1 = cmp.subreport(report);
 JasperReportBuilder report1=report();
 report1.setTemplate(Templates.reportTemplate_2)
 .summary(cmp.horizontalList(pie_payment,subreport1))
 .setDataSource(list);
 return report1;
版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表凯时娱乐立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章

阅读排行

  • 1

    DynamicReports 简略运用ITeye

    付款,序号,金额
  • 2
  • 3

    怎么中止线程ITeye

    中止,线程,办法
  • 4
  • 5

    [C#]Console类的详细用法ITeye

    控制台,字符串,输出
  • 6

    ehcache基本原理ITeye

    缓存,磁盘,是否
  • 7
  • 8
  • 9

    KMPITeye

    匹配,长串,短串
  • 10

    ruby编码问题小结ITeye

    办法,第章,编程