CwReportExcleUtils.java 类 1 package com.bigdata.campus.report.utils; 2 3 import java.util.List; 4 import java.util.Map; 5 6 import org.apache.poi.hssf.usermodel.HSSFWorkbook; 7 import org.apache.poi.ss.usermodel.Cell; 8 import org.apache.poi.ss.usermodel.CellStyle; 9 import org.apache.poi.ss.usermodel.DataFormat; 10 import org.apache.poi.ss.usermodel.Font; 11 import org.apache.poi.ss.usermodel.IndexedColors; 12 import org.apache.poi.ss.usermodel.Row; 13 import org.apache.poi.ss.usermodel.Sheet; 14 import org.apache.poi.ss.usermodel.Workbook; 15 import org.apache.poi.ss.util.CellRangeAddress; 16 17 public class CwReportExcleUtils { 18 /** 19 * Excel的导出(自定义表头) 20 * @describe list 为数据 keys 为需要显示在excel中的参数对应的值,因为是用map存的,放的都是对应的key 21 * headRange 合并表头的参数 如new String[] { "0,0,0,2", "0,0,0,2", "3,3,4,4","3,3,5,5" }; 起始行, 终止行, 起始列, 终止列 22 * headRowParam 合并表头的参数(数量与headRowNum对应) 23 * intRow存放那些行不需要添加背景填充和数据行格式一样如果不需要则置为空list 24 * @param list 25 * @param keys 26 * @param columnNames 27 * @param headRowNum 28 * @param headRange 29 * @param rowParam 30 * @return 31 */ 32 public static Workbook createCustomWorkBook( 33 List
export方法
/** * headRowNum 有多少个headRowParam 就必须要有多少组 {"1,2,3,4"} // 1起始行, 2终止行, 3起始列, 4终止列 * @param response * @param fileName * @param list * @param keys * @param headRange {"1,2,3,4"} // 1起始行, 2终止行, 3起始列, 4终止列 * @param headRowNum * @param headRowParam * @throws IOException */ private void export(HttpServletResponse response, String fileName, List
exportClassStudentsFee 类
/** * 导出班级缴费学生缴费明细统计数据 * @param response * @param redirectAttributes * @param cwreport */ public Workbook exportClassStudentsFee(HttpServletResponse response, RedirectAttributes redirectAttributes,CWReport cwreport, Boolean isBatch) { Workbook workbook = null; try { String fileName="班级学生缴费明细报表"+DateUtils.getDate("yyyy年MM月dd日 HH时mm分ss秒"); //填充projects数据制作模板 List classStuDetailslist = classStuDetailsExport(cwreport);//查询整体数据 CWReport classStuCount =sumClassStuDetails(cwreport);//查询数据求和总计 List
createExcelclassStuDetails 方法
private List