|
@@ -0,0 +1,441 @@
|
|
|
+package com.nokia.tsl_data.service;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.nio.file.Paths;
|
|
|
+import java.text.DateFormat;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Locale;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import org.apache.poi.ss.usermodel.BorderStyle;
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
+import org.apache.poi.ss.usermodel.FillPatternType;
|
|
|
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.apache.poi.ss.usermodel.VerticalAlignment;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFColor;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFDataFormat;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFFont;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import com.nokia.tsl_data.dao.SysDataDictionaryRepository;
|
|
|
+import com.nokia.tsl_data.entity.pojo.XSSFWorkbookWrapper;
|
|
|
+import com.nokia.tsl_data.properties.TslDataProperties;
|
|
|
+import com.nokia.tsl_data.util.excel.PoiUtil;
|
|
|
+
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class ReportServiceV3 {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TslDataProperties tslDataProperties;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysDataDictionaryRepository sysDataDictionaryRepository;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ManagementDetailService managementDetailService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TslDataService tslDataService;
|
|
|
+
|
|
|
+ private static final DateFormat DAY_FORMAT = new SimpleDateFormat("yyyyMMdd");
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成报表
|
|
|
+ */
|
|
|
+ public void generateReport(String day) {
|
|
|
+ // 1. 检查文件路径
|
|
|
+ String fileName = tslDataProperties.getOutputFileNamePrefix() + day + ".xlsx";
|
|
|
+ File file = Paths.get(tslDataProperties.getOutputPath(), "V3", day).toFile();
|
|
|
+ if (!file.exists()) {
|
|
|
+ boolean mkdirs = file.mkdirs();
|
|
|
+ System.out.println(mkdirs);
|
|
|
+ }
|
|
|
+ // 2. 创建workbook并写入各个sheet
|
|
|
+ XSSFWorkbookWrapper workbookWrapper = getWorkbook();
|
|
|
+ // 2.1 写入sheet 管理端-移网感知类
|
|
|
+ managementDetailService.checkStatDayCount(day);
|
|
|
+ writeSheet1(workbookWrapper, day);
|
|
|
+ // 2.2 写入 服请情况
|
|
|
+ // 2.3 写入 重复投诉 超时工单情况
|
|
|
+ // 2.4 写入三率
|
|
|
+ tslDataService.checkStatDayCount(day);
|
|
|
+ writeSheet4_6(workbookWrapper, day);
|
|
|
+ // 3. 写入到本地文件
|
|
|
+ try (OutputStream outputStream = new FileOutputStream(
|
|
|
+ Paths.get(file.getAbsolutePath(), fileName).toFile())) {
|
|
|
+ workbookWrapper.getWorkbook().write(outputStream);
|
|
|
+ workbookWrapper.getWorkbook().close();
|
|
|
+ // 销毁 workbookWrapper 实例
|
|
|
+ workbookWrapper = null;
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("写入失败。。。" + e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 客户端-投诉问题解决满意度
|
|
|
+ * 客户端-投诉问题解决率
|
|
|
+ * 客户端-投诉问题响应率
|
|
|
+ */
|
|
|
+ private void writeSheet4_6(XSSFWorkbookWrapper workbookWrapper, String day) {
|
|
|
+ List<List<List<Object>>> sheet4_6Data = tslDataService.getSheet4_6Data(day);
|
|
|
+ // 计算时间常数
|
|
|
+ Calendar calendar = Calendar.getInstance(Locale.CHINA);
|
|
|
+ try {
|
|
|
+ calendar.setTime(DAY_FORMAT.parse(day));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ log.error("时间字符串解析失败--{}", day);
|
|
|
+ }
|
|
|
+ int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
+ Sheet sheet4 = workbookWrapper.getWorkbook().createSheet("客户端-投诉问题解决满意度");
|
|
|
+ Sheet sheet5 = workbookWrapper.getWorkbook().createSheet("客户端-投诉问题解决率");
|
|
|
+ Sheet sheet6 = workbookWrapper.getWorkbook().createSheet("客户端-投诉问题响应率");
|
|
|
+ Row row;
|
|
|
+ Cell cell;
|
|
|
+
|
|
|
+ // 客户端-投诉问题解决满意度 第一行
|
|
|
+ row = sheet4.createRow(0);
|
|
|
+ cell = row.createCell(0);
|
|
|
+ cell.setCellValue(String.format("投诉问题解决满意率(1-%s)", dayOfMonth));
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle3());
|
|
|
+ // 合并单元格 A1 - D1
|
|
|
+ PoiUtil.addMergedRegion(sheet4, 0, 0, 0, 3);
|
|
|
+ // 客户端-投诉问题解决满意度 第二行
|
|
|
+ row = sheet4.createRow(1);
|
|
|
+ cell = row.createCell(0);
|
|
|
+ cell.setCellValue("地市");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle3());
|
|
|
+ cell = row.createCell(1);
|
|
|
+ cell.setCellValue("满意率");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle3());
|
|
|
+ cell = row.createCell(2);
|
|
|
+ cell.setCellValue("达标值");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle3());
|
|
|
+ cell = row.createCell(3);
|
|
|
+ cell.setCellValue("与达标值差距");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle3());
|
|
|
+ int rowNum = 2;
|
|
|
+ for (List<Object> list : sheet4_6Data.get(0)) {
|
|
|
+ row = sheet4.createRow(rowNum++);
|
|
|
+ // 地市
|
|
|
+ cell = row.createCell(0);
|
|
|
+ cell.setCellValue(list.get(0).toString());
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle1());
|
|
|
+ // 投诉问题解决满意率
|
|
|
+ cell = row.createCell(1);
|
|
|
+ cell.setCellValue(((double) list.get(1)));
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle2());
|
|
|
+ // 达标值
|
|
|
+ cell = row.createCell(2);
|
|
|
+ cell.setCellValue((double) list.get(2));
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle2());
|
|
|
+ // 与达标值差距
|
|
|
+ cell = row.createCell(3);
|
|
|
+ cell.setCellValue(((double) list.get(3)));
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle2());
|
|
|
+ }
|
|
|
+ // 设置条件格式D3-D14
|
|
|
+ PoiUtil.setConditionalFormattingRedToGreen(sheet4, 2, 13, 3, 3);
|
|
|
+ // 设置列宽 2048 1304 2048 2304
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
+ sheet4.setColumnWidth(i, 2848);
|
|
|
+ }
|
|
|
+ // 设置行高 15.0 15.0...
|
|
|
+ for (int i = 0; i < 15; i++) {
|
|
|
+ sheet4.getRow(i).setHeightInPoints(15.0F);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 客户端-投诉问题解决率
|
|
|
+ row = sheet5.createRow(0);
|
|
|
+ cell = row.createCell(0);
|
|
|
+ cell.setCellValue(String.format("投诉问题解决率(1-%s)", dayOfMonth));
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle3());
|
|
|
+ // 合并单元格 A1 - D1
|
|
|
+ PoiUtil.addMergedRegion(sheet5, 0, 0, 0, 3);
|
|
|
+ // 客户端-投诉问题解决率 第二行
|
|
|
+ row = sheet5.createRow(1);
|
|
|
+ cell = row.createCell(0);
|
|
|
+ cell.setCellValue("地市");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle3());
|
|
|
+ cell = row.createCell(1);
|
|
|
+ cell.setCellValue("解决率");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle3());
|
|
|
+ cell = row.createCell(2);
|
|
|
+ cell.setCellValue("达标值");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle3());
|
|
|
+ cell = row.createCell(3);
|
|
|
+ cell.setCellValue("与达标值差距");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle3());
|
|
|
+ rowNum = 2;
|
|
|
+ for (List<Object> list : sheet4_6Data.get(1)) {
|
|
|
+ row = sheet5.createRow(rowNum++);
|
|
|
+ // 地市
|
|
|
+ cell = row.createCell(0);
|
|
|
+ cell.setCellValue(list.get(0).toString());
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle1());
|
|
|
+ // 投诉问题解决率
|
|
|
+ cell = row.createCell(1);
|
|
|
+ cell.setCellValue(((double) list.get(1)));
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle2());
|
|
|
+ // 达标值
|
|
|
+ cell = row.createCell(2);
|
|
|
+ cell.setCellValue((double) list.get(2));
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle2());
|
|
|
+ // 与达标值差距
|
|
|
+ cell = row.createCell(3);
|
|
|
+ cell.setCellValue(((double) list.get(3)));
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle2());
|
|
|
+ }
|
|
|
+ // 设置条件格式D3-D14
|
|
|
+ PoiUtil.setConditionalFormattingRedToGreen(sheet5, 2, 13, 3, 3);
|
|
|
+ // 设置列宽 2048 1304 2048 2304
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
+ sheet5.setColumnWidth(i, 2848);
|
|
|
+ }
|
|
|
+ // 设置行高 15.0 15.0...
|
|
|
+ for (int i = 0; i < 15; i++) {
|
|
|
+ sheet5.getRow(i).setHeightInPoints(15.0F);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 客户端-投诉问题响应率
|
|
|
+ row = sheet6.createRow(0);
|
|
|
+ cell = row.createCell(0);
|
|
|
+ cell.setCellValue(String.format("投诉问题响应率(1-%s)", dayOfMonth));
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle3());
|
|
|
+ // 合并单元格 A1 - D1
|
|
|
+ PoiUtil.addMergedRegion(sheet6, 0, 0, 0, 3);
|
|
|
+ // 客户端-投诉问题响应率 第二行
|
|
|
+ row = sheet6.createRow(1);
|
|
|
+ cell = row.createCell(0);
|
|
|
+ cell.setCellValue("地市");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle3());
|
|
|
+ cell = row.createCell(1);
|
|
|
+ cell.setCellValue("响应率");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle3());
|
|
|
+ cell = row.createCell(2);
|
|
|
+ cell.setCellValue("达标值");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle3());
|
|
|
+ cell = row.createCell(3);
|
|
|
+ cell.setCellValue("与达标值差距");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle3());
|
|
|
+ rowNum = 2;
|
|
|
+ for (List<Object> list : sheet4_6Data.get(2)) {
|
|
|
+ row = sheet6.createRow(rowNum++);
|
|
|
+ // 地市
|
|
|
+ cell = row.createCell(0);
|
|
|
+ cell.setCellValue(list.get(0).toString());
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle1());
|
|
|
+ // 投诉问题解决率
|
|
|
+ cell = row.createCell(1);
|
|
|
+ cell.setCellValue(((double) list.get(1)));
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle2());
|
|
|
+ // 达标值
|
|
|
+ cell = row.createCell(2);
|
|
|
+ cell.setCellValue((double) list.get(2));
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle2());
|
|
|
+ // 与达标值差距
|
|
|
+ cell = row.createCell(3);
|
|
|
+ cell.setCellValue(((double) list.get(3)));
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle2());
|
|
|
+ }
|
|
|
+ // 设置条件格式D3-D14
|
|
|
+ PoiUtil.setConditionalFormattingRedToGreen(sheet6, 2, 13, 3, 3);
|
|
|
+ // 设置列宽 2048 1304 2048 2304
|
|
|
+ for (int i = 0; i < 4; i++) {
|
|
|
+ sheet6.setColumnWidth(i, 2848);
|
|
|
+ }
|
|
|
+ // 设置行高 15.0 15.0...
|
|
|
+ for (int i = 0; i < 15; i++) {
|
|
|
+ sheet6.getRow(i).setHeightInPoints(15.0F);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 管理端-移网感知类 2024年适配需求
|
|
|
+ */
|
|
|
+ private void writeSheet1(XSSFWorkbookWrapper workbookWrapper, String day) {
|
|
|
+ String sheetName = "管理端-移网感知类";
|
|
|
+ // 获取数据
|
|
|
+ Map<String, List<Object>> seet1Data = managementDetailService.getSheet1DataV3(day);
|
|
|
+ // 计算天数
|
|
|
+ LocalDate date = LocalDate.parse(day, DateTimeFormatter.ofPattern("yyyyMMdd"));
|
|
|
+ int dayOfMonth = date.getDayOfMonth();
|
|
|
+ Sheet sheet = workbookWrapper.getWorkbook().createSheet(sheetName);
|
|
|
+ Row row;
|
|
|
+ Cell cell;
|
|
|
+ // 第一行 标题栏
|
|
|
+ cell = sheet.createRow(0).createCell(0);
|
|
|
+ cell.setCellValue(day.substring(0, 4) + "年客服投诉清单各地市投诉率情况(" + sheetName + ")");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle4());
|
|
|
+ PoiUtil.addMergedRegion(sheet, 0, 0, 0, dayOfMonth + 7);
|
|
|
+
|
|
|
+ // 第二行 列名
|
|
|
+ row = sheet.createRow(1);
|
|
|
+ cell = row.createCell(0);
|
|
|
+ cell.setCellValue("地市");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle1());
|
|
|
+ for (int i = 1; i <= dayOfMonth; i++) {
|
|
|
+ cell = row.createCell(i);
|
|
|
+ cell.setCellValue(i + "日");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle1());
|
|
|
+ }
|
|
|
+ cell = row.createCell(dayOfMonth + 1);
|
|
|
+ cell.setCellValue("投诉总量");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle1());
|
|
|
+ cell = row.createCell(dayOfMonth + 2);
|
|
|
+ cell.setCellValue("用户数");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle1());
|
|
|
+ cell = row.createCell(dayOfMonth + 3);
|
|
|
+ cell.setCellValue("目前万投率");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle1());
|
|
|
+ cell = row.createCell(dayOfMonth + 4);
|
|
|
+ cell.setCellValue("本月预测");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle1());
|
|
|
+ cell = row.createCell(dayOfMonth + 5);
|
|
|
+ cell.setCellValue("目标值");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle1());
|
|
|
+ cell = row.createCell(dayOfMonth + 6);
|
|
|
+ cell.setCellValue("与目标差距");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle1());
|
|
|
+ cell = row.createCell(dayOfMonth + 7);
|
|
|
+ cell.setCellValue("地市");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle1());
|
|
|
+
|
|
|
+ int rowNum = 2;
|
|
|
+ int cellNum = 0;
|
|
|
+ // 写入各地市数据
|
|
|
+ for (String area : sysDataDictionaryRepository.findAllCityName()) {
|
|
|
+ row = sheet.createRow(rowNum++);
|
|
|
+ // 写入A列的地市
|
|
|
+ cell = row.createCell(cellNum++);
|
|
|
+ cell.setCellValue(area);
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle1());
|
|
|
+ for (Object obj : seet1Data.get(area)) {
|
|
|
+ cell = row.createCell(cellNum++);
|
|
|
+ cell.setCellValue(Double.parseDouble(obj.toString()));
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle1());
|
|
|
+ }
|
|
|
+ // 写入最后一列的地市
|
|
|
+ cell = row.createCell(cellNum);
|
|
|
+ cell.setCellValue(area);
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle1());
|
|
|
+ // cellNum复位
|
|
|
+ cellNum = 0;
|
|
|
+ }
|
|
|
+ // 写入全省数据
|
|
|
+ row = sheet.createRow(rowNum);
|
|
|
+ // 写入A列的地市
|
|
|
+ cell = row.createCell(cellNum++);
|
|
|
+ cell.setCellValue("全省");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle1());
|
|
|
+ for (Object obj : seet1Data.get("全省")) {
|
|
|
+ cell = row.createCell(cellNum++);
|
|
|
+ cell.setCellValue(Double.parseDouble(obj.toString()));
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle1());
|
|
|
+ }
|
|
|
+ // 写入最后一列的地市
|
|
|
+ cell = row.createCell(cellNum);
|
|
|
+ cell.setCellValue("全省");
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle1());
|
|
|
+
|
|
|
+ // 3-15行(2-14)dayOfMonth+2 - dayOfMonth+6是浮点数,设置为显示小数点后2位
|
|
|
+ for (int i = 2; i <= 14; i++) {
|
|
|
+ row = sheet.getRow(i);
|
|
|
+ for (int j = dayOfMonth + 2; j <= dayOfMonth + 6; j++) {
|
|
|
+ cell = row.getCell(j);
|
|
|
+ cell.setCellStyle(workbookWrapper.getCellStyle5());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加条件格式B15-V15
|
|
|
+ PoiUtil.setConditionalFormattingGreenToRed(sheet, rowNum, rowNum, 1, dayOfMonth);
|
|
|
+ // 添加条件格式(dayOfMonth+3)(3-14)
|
|
|
+ PoiUtil.setConditionalFormattingGreenToRed(sheet, 2, 13, dayOfMonth + 3, dayOfMonth + 3);
|
|
|
+ // 添加条件格式Z3-Z14
|
|
|
+ PoiUtil.setConditionalFormattingGreenToRed(sheet, 2, 13, dayOfMonth + 4, dayOfMonth + 4);
|
|
|
+ // 添加条件格式AB3-AB14
|
|
|
+ PoiUtil.setConditionalFormattingGreenToRed(sheet, 2, 13, dayOfMonth + 6, dayOfMonth + 6);
|
|
|
+
|
|
|
+ // 设置sheet的列宽
|
|
|
+ sheet.setColumnWidth(0, 1600);
|
|
|
+ for (int i = 1; i <= dayOfMonth; i++) {
|
|
|
+ sheet.setColumnWidth(i, 1100);
|
|
|
+ }
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 1, 1700);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 2, 2100);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 3, 2100);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 4, 2100);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 5, 1700);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 6, 2100);
|
|
|
+ sheet.setColumnWidth(dayOfMonth + 7, 1600);
|
|
|
+
|
|
|
+ // 设置行高 15
|
|
|
+ for (int i = 0; i < rowNum; i++) {
|
|
|
+ sheet.getRow(i).setHeightInPoints(15F);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取一个 XSSFWorkbook 并初始化几个需要的格式
|
|
|
+ */
|
|
|
+ private XSSFWorkbookWrapper getWorkbook() {
|
|
|
+ XSSFWorkbook workbook = new XSSFWorkbook();
|
|
|
+ XSSFWorkbookWrapper workbookWrapper = new XSSFWorkbookWrapper();
|
|
|
+ XSSFDataFormat dataFormat = workbook.createDataFormat();
|
|
|
+ workbookWrapper.setWorkbook(workbook);
|
|
|
+ // 基本模式 微软雅黑 10号字 带全边框 水平居中
|
|
|
+ XSSFCellStyle baseStyle = workbook.createCellStyle();
|
|
|
+ XSSFFont font = workbook.createFont();
|
|
|
+ font.setFontName("微软雅黑");
|
|
|
+ font.setFontHeightInPoints((short) 10);
|
|
|
+ baseStyle.setFont(font);
|
|
|
+ baseStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
+ baseStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+ baseStyle.setBorderBottom(BorderStyle.THIN);
|
|
|
+ baseStyle.setBorderTop(BorderStyle.THIN);
|
|
|
+ baseStyle.setBorderLeft(BorderStyle.THIN);
|
|
|
+ baseStyle.setBorderRight(BorderStyle.THIN);
|
|
|
+ // cellStyle1 基本模式 微软雅黑 10号字 带全边框 水平居中
|
|
|
+ workbookWrapper.setCellStyle1(baseStyle);
|
|
|
+ workbookWrapper.setCellStyle2(baseStyle.copy());
|
|
|
+ workbookWrapper.setCellStyle3(baseStyle.copy());
|
|
|
+ workbookWrapper.setCellStyle4(baseStyle.copy());
|
|
|
+ // 2位小数
|
|
|
+ workbookWrapper.setCellStyle5(baseStyle.copy());
|
|
|
+ // cellStyle2 百分比 2位小数
|
|
|
+ workbookWrapper.getCellStyle2().setDataFormat(dataFormat.getFormat("0.00%"));
|
|
|
+ // cellStyle3 背景色 FFAEAAAA
|
|
|
+ XSSFColor color = new XSSFColor();
|
|
|
+ color.setARGBHex("FFAEAAAA");
|
|
|
+ workbookWrapper.getCellStyle3().setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
|
+ workbookWrapper.getCellStyle3().setFillForegroundColor(color);
|
|
|
+ // cellStyle4 背景色 FFAEAAAA 加粗
|
|
|
+ XSSFFont font2 = workbook.createFont();
|
|
|
+ font2.setFontName("微软雅黑");
|
|
|
+ font2.setBold(true);
|
|
|
+ font2.setFontHeightInPoints((short) 10);
|
|
|
+ workbookWrapper.getCellStyle4().setFont(font2);
|
|
|
+ workbookWrapper.getCellStyle4().setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
|
+ workbookWrapper.getCellStyle4().setFillForegroundColor(color);
|
|
|
+ // cellStyle5 2位小数
|
|
|
+ workbookWrapper.getCellStyle5().setDataFormat(dataFormat.getFormat("0.00"));
|
|
|
+ return workbookWrapper;
|
|
|
+ }
|
|
|
+}
|