Raod 4 vuotta sitten
vanhempi
sitoutus
053807da69

+ 73 - 0
report-core/src/main/java/com/anjiplus/template/gaea/business/enums/ExcelCenterStyleEnum.java

@@ -0,0 +1,73 @@
+package com.anjiplus.template.gaea.business.enums;
+
+/**
+ * @author zhouhang
+ * @description EXCEL居中方式
+ * @date 2021/4/26
+ */
+public enum ExcelCenterStyleEnum {
+    /**
+     * 左对齐
+     */
+    LEFT((short) 1, 1, "左对齐"),
+    /**
+     * 右对齐
+     */
+    RIGHT((short) 3, 2, "右对齐"),
+    /**
+     * 居中
+     */
+    CENTER((short) 2, 0, "居中"),
+    ;
+
+    /**
+     * excel居中code
+     */
+    private final short excelCode;
+
+    /**
+     * 在线文档居中code
+     */
+    private final Integer onlineExcelCode;
+
+    /**
+     * 名称
+     */
+    private final String name;
+
+
+    public Integer getOnlineExcelCode() {
+        return onlineExcelCode;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public short getExcelCode() {
+        return excelCode;
+    }
+
+    ExcelCenterStyleEnum(short excelCode, Integer onlineExcelCode, String name) {
+        this.excelCode = excelCode;
+        this.onlineExcelCode = onlineExcelCode;
+        this.name = name;
+    }
+
+    /**
+     * @param code excel居中样式code
+     * @return Enum_ExcelCenterStyle
+     * @description 根据excel居中样式获取在线文档居中样式
+     * @author zhouhang
+     * @date 2021/4/26
+     */
+    public static ExcelCenterStyleEnum getExcelCenterStyleByExcelCenterCode(short code) {
+        for (ExcelCenterStyleEnum value : ExcelCenterStyleEnum.values()) {
+            if (code == value.getExcelCode()) {
+                return value;
+            }
+        }
+        return CENTER;
+    }
+
+}

+ 1 - 0
report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/controller/dto/GridRecordDataModel.java

@@ -8,6 +8,7 @@ import java.util.List;
 
 /**
  * 存储对象类
+ *
  * @author Administrator
  */
 @Data

+ 27 - 9
report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/controller/dto/ReportExcelDto.java

@@ -13,31 +13,49 @@ import java.io.Serializable;
  */
 @Data
 public class ReportExcelDto extends GaeaBaseDTO implements Serializable {
-    /** 报表名称 */
+    /**
+     * 报表名称
+     */
     private String reportName;
 
-    /** 报表编码 */
+    /**
+     * 报表编码
+     */
     private String reportCode;
 
-    /**数据集编码,以|分割*/
+    /**
+     * 数据集编码,以|分割
+     */
     private String setCodes;
 
-    /** 分组 */
+    /**
+     * 分组
+     */
     private String reportGroup;
 
-    /** 数据集查询参数 */
+    /**
+     * 数据集查询参数
+     */
     private String setParam;
 
-    /** 报表json字符串 */
+    /**
+     * 报表json字符串
+     */
     private String jsonStr;
 
-    /** 报表类型 */
+    /**
+     * 报表类型
+     */
     private String reportType;
 
-    /** 数据总计 */
+    /**
+     * 数据总计
+     */
     private long total;
 
-    /**导出类型*/
+    /**
+     * 导出类型
+     */
     private String exportType;
 
 }

+ 1 - 1
report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/controller/param/ReportExcelParam.java

@@ -12,7 +12,7 @@ import java.io.Serializable;
  * @date 2021/4/13 15:12
  */
 @Data
-public class ReportExcelParam extends PageParam implements Serializable{
+public class ReportExcelParam extends PageParam implements Serializable {
 
 
 }

+ 1 - 1
report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/dao/entity/ReportExcel.java

@@ -9,7 +9,7 @@ import lombok.Data;
  * @author chenkening
  * @date 2021/4/13 15:11
  */
-@TableName(value="gaea_report_excel")
+@TableName(value = "gaea_report_excel")
 @Data
 public class ReportExcel extends GaeaBaseEntity {
 

+ 6 - 7
report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/service/impl/ReportExcelServiceImpl.java

@@ -18,7 +18,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 /**
@@ -48,11 +47,11 @@ public class ReportExcelServiceImpl implements ReportExcelService {
     @Override
     public ReportExcelDto detailByReportCode(String reportCode) {
         QueryWrapper<ReportExcel> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("report_code" , reportCode);
+        queryWrapper.eq("report_code", reportCode);
         ReportExcel reportExcel = reportExcelMapper.selectOne(queryWrapper);
-        if(reportExcel != null){
+        if (reportExcel != null) {
             ReportExcelDto dto = new ReportExcelDto();
-            BeanUtils.copyProperties(reportExcel , dto);
+            BeanUtils.copyProperties(reportExcel, dto);
             return dto;
         }
         return null;
@@ -84,13 +83,13 @@ public class ReportExcelServiceImpl implements ReportExcelService {
         // 根据id查询 报表详情
         ReportExcel reportExcel = selectOne("report_code", reportExcelDto.getReportCode());
         QueryWrapper<Report> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("report_code" , reportExcelDto.getReportCode());
+        queryWrapper.eq("report_code", reportExcelDto.getReportCode());
         Report report = reportMapper.selectOne(queryWrapper);
         GaeaAssert.notNull(reportExcel, ResponseCode.RULE_CONTENT_NOT_EXIST, "reportExcel");
         String setParam = reportExcelDto.getSetParam();
 
-        GaeaBeanUtils.copyAndFormatter(reportExcel , reportExcelDto);
-        if(StringUtils.isNotBlank(setParam)){
+        GaeaBeanUtils.copyAndFormatter(reportExcel, reportExcelDto);
+        if (StringUtils.isNotBlank(setParam)) {
             reportExcelDto.setSetParam(setParam);
         }
         reportExcelDto.setReportName(report.getReportName());

+ 28 - 28
report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/util/ColorUtil.java

@@ -1,7 +1,6 @@
 package com.anjiplus.template.gaea.business.modules.reportexcel.util;
 
 
-
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFPalette;
@@ -15,6 +14,7 @@ import org.apache.poi.xssf.usermodel.XSSFColor;
 
 /**
  * 来自:https://github.com/mengshukeji/LuckysheetServer
+ *
  * @author Administrator
  */
 @Slf4j
@@ -22,22 +22,22 @@ public class ColorUtil {
 
     private static final String S = "0123456789ABCDEF";
 
-    public static Short getColorByStr(String colorStr){
+    public static Short getColorByStr(String colorStr) {
         HSSFWorkbook workbook = new HSSFWorkbook();
         HSSFPalette palette = workbook.getCustomPalette();
 
-        if(colorStr.toLowerCase().startsWith("rgb")){
-            colorStr=colorStr.toLowerCase().replace("rgb(","").replace(")","");
-            String[] colors=colorStr.split(",");
-            if(colors.length==3){
-                try{
-                    int red = Integer.parseInt(colors[0].trim(),16);
-                    int green = Integer.parseInt(colors[1].trim(),16);
-                    int blue = Integer.parseInt(colors[2].trim(),16);
+        if (colorStr.toLowerCase().startsWith("rgb")) {
+            colorStr = colorStr.toLowerCase().replace("rgb(", "").replace(")", "");
+            String[] colors = colorStr.split(",");
+            if (colors.length == 3) {
+                try {
+                    int red = Integer.parseInt(colors[0].trim(), 16);
+                    int green = Integer.parseInt(colors[1].trim(), 16);
+                    int blue = Integer.parseInt(colors[2].trim(), 16);
 
-                    HSSFColor hssfColor=palette.findSimilarColor(red,green,blue);
+                    HSSFColor hssfColor = palette.findSimilarColor(red, green, blue);
                     return hssfColor.getIndex();
-                }catch (Exception ex){
+                } catch (Exception ex) {
                     log.error(ex.toString());
                     return null;
                 }
@@ -45,27 +45,27 @@ public class ColorUtil {
             return null;
         }
 
-        if(colorStr.equals("#000")){
-            colorStr="#000000";
+        if (colorStr.equals("#000")) {
+            colorStr = "#000000";
         }
-        if(colorStr!=null && colorStr.length()>=6){
-            try{
-                if(colorStr.length()==8){
-                    colorStr=colorStr.substring(2);
+        if (colorStr != null && colorStr.length() >= 6) {
+            try {
+                if (colorStr.length() == 8) {
+                    colorStr = colorStr.substring(2);
                 }
-                if(colorStr.length()==7){
-                    colorStr=colorStr.substring(1);
+                if (colorStr.length() == 7) {
+                    colorStr = colorStr.substring(1);
                 }
-                String str2 = colorStr.substring(0,2);
-                String str3 = colorStr.substring(2,4);
-                String str4 = colorStr.substring(4,6);
-                int red = Integer.parseInt(str2,16);
-                int green = Integer.parseInt(str3,16);
-                int blue = Integer.parseInt(str4,16);
+                String str2 = colorStr.substring(0, 2);
+                String str3 = colorStr.substring(2, 4);
+                String str4 = colorStr.substring(4, 6);
+                int red = Integer.parseInt(str2, 16);
+                int green = Integer.parseInt(str3, 16);
+                int blue = Integer.parseInt(str4, 16);
 
-                HSSFColor hssfColor=palette.findSimilarColor(red,green,blue);
+                HSSFColor hssfColor = palette.findSimilarColor(red, green, blue);
                 return hssfColor.getIndex();
-            }catch (Exception ex){
+            } catch (Exception ex) {
                 log.error(ex.toString());
                 return null;
             }

+ 17 - 32
report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/util/XlsSheetUtil.java

@@ -346,7 +346,7 @@ public class XlsSheetUtil {
 
                         if ("border-outside".equals(borderType)) {
                             //外圈边框
-                            if (row_ == rowList.getInteger(0) ) {
+                            if (row_ == rowList.getInteger(0)) {
                                 style.setBorderTop(BorderStyle.valueOf(style_)); //顶部边框
                                 style.setTopBorderColor(color);//顶部边框颜色
                             }
@@ -365,49 +365,34 @@ public class XlsSheetUtil {
 
                         }
 
-                        if ("border-inside".equals(borderType)) {
-                            //所有内边框
-                            if (row_ >= rowList.getInteger(0) && row_ < rowList.getInteger(rowList.size() - 1)) {
-                                style.setBorderRight(BorderStyle.valueOf(style_)); //右边框
-                                style.setRightBorderColor(color);//右边框颜色
-                                style.setBorderBottom(BorderStyle.valueOf(style_)); //底部边框
-                                style.setBottomBorderColor(color);//底部边框颜色 }
-                            }
-
-                            if (col_ >= columnList.getInteger(0) && col_ < columnList.getInteger(columnList.size() - 1)) {
-                                style.setBorderRight(BorderStyle.valueOf(style_)); //右边框
-                                style.setRightBorderColor(color);//右边框颜色
-                                style.setBorderBottom(BorderStyle.valueOf(style_)); //底部边框
-                                style.setBottomBorderColor(color);//底部边框颜色 }
-                            }
-
-                        }
-
-                        if ("border-horizontal".equals(borderType)) {
+                        if ("border-horizontal".equals(borderType) || "border-inside".equals(borderType)) {
                             //内部横线
-                            if (row_ >= rowList.getInteger(0) && row_ < rowList.getInteger(rowList.size() - 1)) {
-                                style.setBorderBottom(BorderStyle.valueOf(style_)); //底部边框
-                                style.setBottomBorderColor(color);//底部边框颜色 }
-                            }
-                            if (col_ >= columnList.getInteger(0) && col_ < columnList.getInteger(columnList.size() - 1)) {
+                            if (row_ >= rowList.getInteger(0)
+                                    && row_ < rowList.getInteger(rowList.size() - 1)
+                                    && col_ >= columnList.getInteger(0)
+                                    && col_ <= columnList.getInteger(columnList.size() - 1)) {
                                 style.setBorderBottom(BorderStyle.valueOf(style_)); //底部边框
                                 style.setBottomBorderColor(color);//底部边框颜色 }
                             }
                         }
 
-                        if ("border-vertical".equals(borderType)) {
+                        if ("border-vertical".equals(borderType) || "border-inside".equals(borderType)) {
                             //内部竖线
-                            if (row_ >= rowList.getInteger(0) && row_ < rowList.getInteger(rowList.size() - 1)) {
-                                style.setBorderRight(BorderStyle.valueOf(style_)); //右边框
-                                style.setRightBorderColor(color);//右边框颜色
-                            }
-                            if (col_ >= columnList.getInteger(0) && col_ < columnList.getInteger(columnList.size() - 1)) {
+                            if (row_ >= rowList.getInteger(0)
+                                    && row_ <= rowList.getInteger(rowList.size() - 1)
+                                    && col_ >= columnList.getInteger(0)
+                                    && col_ < columnList.getInteger(columnList.size() - 1)) {
                                 style.setBorderRight(BorderStyle.valueOf(style_)); //右边框
                                 style.setRightBorderColor(color);//右边框颜色
                             }
                         }
 
-
+                        if ("border-none".equals(borderType)) {
+                            style.setBorderLeft(BorderStyle.NONE); //左边框
+                            style.setBorderRight(BorderStyle.NONE); //左边框
+                            style.setBorderTop(BorderStyle.NONE); //左边框
+                            style.setBorderBottom(BorderStyle.NONE); //左边框
+                        }
 
                     }
                 }

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 21 - 0
report-core/src/test/java/com/anjiplus/template/gaea/business/modules/reportexcel/util/XlsSheetUtilTest.java


Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä