diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/ExcelUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ExcelUtils.java new file mode 100644 index 00000000..7ba49257 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ExcelUtils.java @@ -0,0 +1,242 @@ +package com.ruoyi.common.utils; + +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.streaming.SXSSFWorkbook; + +public class ExcelUtils { + + /** + * 创建标题样式 + * @param wb + * @return + */ + public static CellStyle createTitleCellStyle(SXSSFWorkbook wb) { + CellStyle cellStyle = wb.createCellStyle(); + cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中 + cellStyle.setVerticalAlignment(VerticalAlignment.BOTTOM);//居于底部 + //cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); +// cellStyle.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex());//背景颜色 + + Font headerFont1 = wb.createFont(); // 创建字体样式 + headerFont1.setBold(true); //字体加粗 + headerFont1.setFontName("宋体"); // 设置字体类型 + headerFont1.setFontHeightInPoints((short) 15); // 设置字体大小 + cellStyle.setFont(headerFont1); // 为标题样式设置字体样式 + + return cellStyle; + } + + /** + * 创建表头样式 + * @param wb + * @return + */ + public static CellStyle createHeadCellStyle(SXSSFWorkbook wb) { + CellStyle cellStyle = wb.createCellStyle(); + cellStyle.setWrapText(true);// 设置自动换行 +// cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景颜色 + cellStyle.setAlignment(HorizontalAlignment.CENTER); //水平居中 + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); //垂直对齐 + //cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); +// cellStyle.setBottomBorderColor(IndexedColors.BLACK.index); + cellStyle.setBorderBottom(BorderStyle.THIN); //下边框 + cellStyle.setBorderLeft(BorderStyle.THIN); //左边框 + cellStyle.setBorderRight(BorderStyle.THIN); //右边框 + cellStyle.setBorderTop(BorderStyle.THIN); //上边框 + + Font headerFont = wb.createFont(); // 创建字体样式 +// headerFont.setBold(true); //字体加粗 + headerFont.setFontName("宋体"); // 设置字体类型 + headerFont.setFontHeightInPoints((short) 10); // 设置字体大小 + cellStyle.setFont(headerFont); // 为标题样式设置字体样式 + + return cellStyle; + } + + /** + * 创建内容样式 + * @param wb + * @return + */ + public static CellStyle createContentCellStyle(SXSSFWorkbook wb) { + CellStyle cellStyle = wb.createCellStyle(); + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直居中 + cellStyle.setAlignment(HorizontalAlignment.CENTER);// 水平居中 + cellStyle.setWrapText(true);// 设置自动换行 + cellStyle.setBorderBottom(BorderStyle.THIN); //下边框 + cellStyle.setBorderLeft(BorderStyle.THIN); //左边框 + cellStyle.setBorderRight(BorderStyle.THIN); //右边框 + cellStyle.setBorderTop(BorderStyle.THIN); //上边框 + + // 生成12号字体 + Font font = wb.createFont(); + font.setColor((short)8); + font.setFontHeightInPoints((short) 10); + cellStyle.setFont(font); + return cellStyle; + } + + /** + * 创建内容居右样式 + * @param wb + * @return + */ + public static CellStyle createContentRightCellStyle(SXSSFWorkbook wb) { + CellStyle cellStyle = wb.createCellStyle(); + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直居中 + cellStyle.setAlignment(HorizontalAlignment.RIGHT);// 水平居中 + cellStyle.setWrapText(true);// 设置自动换行 + cellStyle.setBorderBottom(BorderStyle.THIN); //下边框 + cellStyle.setBorderLeft(BorderStyle.THIN); //左边框 + cellStyle.setBorderRight(BorderStyle.THIN); //右边框 + cellStyle.setBorderTop(BorderStyle.THIN); //上边框 + + // 生成12号字体 + Font font = wb.createFont(); + font.setColor((short)8); + font.setFontHeightInPoints((short) 10); + cellStyle.setFont(font); + return cellStyle; + } + + /** + * 创建粗体居左内容样式 + * @param wb + * @return + */ + public static CellStyle createContentWeightCellStyle(SXSSFWorkbook wb) { + CellStyle cellStyle = wb.createCellStyle(); + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直居中 + cellStyle.setAlignment(HorizontalAlignment.LEFT);// 水平居中 + cellStyle.setWrapText(true);// 设置自动换行 + cellStyle.setBorderBottom(BorderStyle.THIN); //下边框 + cellStyle.setBorderLeft(BorderStyle.THIN); //左边框 + cellStyle.setBorderRight(BorderStyle.THIN); //右边框 + cellStyle.setBorderTop(BorderStyle.THIN); //上边框 + + // 生成12号字体 + Font font = wb.createFont(); + font.setColor((short)8); + font.setBold(true); //字体加粗 + font.setFontHeightInPoints((short) 10); + cellStyle.setFont(font); + return cellStyle; + } + + /** + * 创建粗体居右内容样式 + * @param wb + * @return + */ + public static CellStyle createContentWeightRightCellStyle(SXSSFWorkbook wb) { + CellStyle cellStyle = wb.createCellStyle(); + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直居中 + cellStyle.setAlignment(HorizontalAlignment.RIGHT);// 水平居中 + cellStyle.setWrapText(true);// 设置自动换行 + cellStyle.setBorderBottom(BorderStyle.THIN); //下边框 + cellStyle.setBorderLeft(BorderStyle.THIN); //左边框 + cellStyle.setBorderRight(BorderStyle.THIN); //右边框 + cellStyle.setBorderTop(BorderStyle.THIN); //上边框 + cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景颜色 + cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + + // 生成12号字体 + Font font = wb.createFont(); + font.setColor((short)8); + font.setBold(true); //字体加粗 + font.setFontHeightInPoints((short) 10); + cellStyle.setFont(font); + return cellStyle; + } + + /** + * 创建粗体居中带背景颜色内容样式 + * @param wb + * @return + */ + public static CellStyle createContentWeightCenterCellStyle(SXSSFWorkbook wb) { + CellStyle cellStyle = wb.createCellStyle(); + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直居中 + cellStyle.setAlignment(HorizontalAlignment.CENTER);// 水平居中 + cellStyle.setWrapText(true);// 设置自动换行 + cellStyle.setBorderBottom(BorderStyle.THIN); //下边框 + cellStyle.setBorderLeft(BorderStyle.THIN); //左边框 + cellStyle.setBorderRight(BorderStyle.THIN); //右边框 + cellStyle.setBorderTop(BorderStyle.THIN); //上边框 + cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景颜色 + cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + + // 生成12号字体 + Font font = wb.createFont(); + font.setColor((short)8); + font.setBold(true); //字体加粗 + font.setFontHeightInPoints((short) 10); + cellStyle.setFont(font); + return cellStyle; + } + + /** + * 创建粗体无边框居左内容样式 + * @param wb + * @return + */ + public static CellStyle createContentNoBorderCellStyle(SXSSFWorkbook wb) { + CellStyle cellStyle = wb.createCellStyle(); + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直居中 + cellStyle.setAlignment(HorizontalAlignment.LEFT);// 水平居中 + cellStyle.setWrapText(true);// 设置自动换行 + + // 生成12号字体 + Font font = wb.createFont(); + font.setColor((short)8); + font.setFontHeightInPoints((short) 10); + cellStyle.setFont(font); + return cellStyle; + } + + /** + * 创建内容样式 + * @param wb + * @return + */ + public static CellStyle myCreateContentCellStyle(SXSSFWorkbook wb) { + CellStyle cellStyle = wb.createCellStyle(); + cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直居中 + cellStyle.setAlignment(HorizontalAlignment.CENTER);// 水平居中 + cellStyle.setWrapText(true);// 设置自动换行 + cellStyle.setBorderBottom(BorderStyle.THIN); //下边框 + cellStyle.setBorderLeft(BorderStyle.THIN); //左边框 + cellStyle.setBorderRight(BorderStyle.THIN); //右边框 + cellStyle.setBorderTop(BorderStyle.THIN); //上边框 + cellStyle.setFillBackgroundColor(IndexedColors.YELLOW.getIndex()); + cellStyle.setFillForegroundColor(IndexedColors.YELLOW.getIndex());//背景颜色 + + // 生成12号字体 + Font font = wb.createFont(); + font.setColor((short)8); + font.setFontHeightInPoints((short) 10); + cellStyle.setFont(font); + return cellStyle; + } + + /** + * 创建标题样式 + * @param wb + * @return + */ + public static CellStyle myCreateTitleCellStyle(SXSSFWorkbook wb) { + CellStyle cellStyle = wb.createCellStyle(); + cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中 + cellStyle.setVerticalAlignment(VerticalAlignment.BOTTOM);//居于底部 + cellStyle.setFillForegroundColor(IndexedColors.YELLOW.getIndex());//背景颜色 + cellStyle.setFillBackgroundColor(IndexedColors.YELLOW.getIndex()); + + Font headerFont1 = wb.createFont(); // 创建字体样式 + headerFont1.setBold(true); //字体加粗 + headerFont1.setFontName("宋体"); // 设置字体类型 + headerFont1.setFontHeightInPoints((short) 15); // 设置字体大小 + cellStyle.setFont(headerFont1); // 为标题样式设置字体样式 + + return cellStyle; + } +} diff --git a/ruoyi-ui/src/api/statistics/statisticsProject/index.js b/ruoyi-ui/src/api/statistics/statisticsProject/index.js index 43b7aee4..3be4be66 100644 --- a/ruoyi-ui/src/api/statistics/statisticsProject/index.js +++ b/ruoyi-ui/src/api/statistics/statisticsProject/index.js @@ -7,4 +7,13 @@ export function selectStatisticsProjectList(query) { method: 'get', params: query }) +} + +// 导出项目数据汇总 +export function exportView(query) { + return request({ + url: '/statistics/project/exportView', + method: 'get', + params: query + }) } \ No newline at end of file diff --git a/ruoyi-ui/src/views/statistics/statisticsProject/index.vue b/ruoyi-ui/src/views/statistics/statisticsProject/index.vue index 083844ec..68675a2c 100644 --- a/ruoyi-ui/src/views/statistics/statisticsProject/index.vue +++ b/ruoyi-ui/src/views/statistics/statisticsProject/index.vue @@ -166,8 +166,11 @@