diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HseSafetyWeeklyReportServiceImpl.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HseSafetyWeeklyReportServiceImpl.java index 1b24de87..963912de 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HseSafetyWeeklyReportServiceImpl.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/safety/service/impl/HseSafetyWeeklyReportServiceImpl.java @@ -12,7 +12,7 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.xssf.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.dromara.common.core.constant.HttpStatus; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.ObjectUtils; @@ -471,7 +471,7 @@ public class HseSafetyWeeklyReportServiceImpl extends ServiceImpl30, I1<=60)"); - PatternFormatting fill2 = rule2.createPatternFormatting(); - fill2.setFillBackgroundColor(IndexedColors.ORANGE.getIndex()); - fill2.setFillPattern(PatternFormatting.SOLID_FOREGROUND); - - // 规则3: 61-100% - 深红色 - ConditionalFormattingRule rule3 = conditionalFormatting.createConditionalFormattingRule( - "AND(ISNUMBER(I1), I1>60)"); - PatternFormatting fill3 = rule3.createPatternFormatting(); - fill3.setFillBackgroundColor(IndexedColors.RED.getIndex()); - fill3.setFillPattern(PatternFormatting.SOLID_FOREGROUND); - - // 应用规则到两个区域 - ConditionalFormattingRule[] rules = new ConditionalFormattingRule[]{rule1, rule2, rule3}; - - // 施工进度统计表 - CellRangeAddress[] progressRanges = new CellRangeAddress[] { - new CellRangeAddress(11, 17, 8, 8) - }; - conditionalFormatting.addConditionalFormatting(progressRanges, rules); - - // 设备材料表格 - CellRangeAddress[] materialRanges = new CellRangeAddress[] { - new CellRangeAddress(19, 22, 8, 8) - }; - conditionalFormatting.addConditionalFormatting(materialRanges, rules); - - } catch (Exception e) { - System.err.println("创建简单条件格式化失败: " + e.getMessage()); - } - } - - /** - * 创建数值格式样式 - */ - private CellStyle createNumberCellStyle(Workbook workbook) { - CellStyle style = workbook.createCellStyle(); - Font font = workbook.createFont(); - font.setFontName("宋体"); - font.setFontHeightInPoints((short)10); - style.setFont(font); - style.setAlignment(HorizontalAlignment.CENTER); - style.setVerticalAlignment(VerticalAlignment.CENTER); - style.setBorderTop(BorderStyle.THIN); - style.setBorderBottom(BorderStyle.THIN); - style.setBorderLeft(BorderStyle.THIN); - style.setBorderRight(BorderStyle.THIN); - - // 设置数值格式为百分比 - DataFormat format = workbook.createDataFormat(); - style.setDataFormat(format.getFormat("0.0%")); - - return style; - } - }