Pārlūkot izejas kodu

1.7.1-机构导出

Aslee 2 gadi atpakaļ
vecāks
revīzija
d52b361bcb

+ 16 - 16
src/main/java/com/caimei/service/auth/impl/AuthServiceImpl.java

@@ -729,30 +729,30 @@ public class AuthServiceImpl implements AuthService {
 
     private ResponseJson exportData(List<AuthFormVo> authPartyList, OutputStream outputStream) {
         try {
-            HSSFWorkbook workbook = new HSSFWorkbook();
+            XSSFWorkbook workbook = new XSSFWorkbook();
             // 创建机构工作表
-            HSSFSheet authPartySheet = workbook.createSheet("授权机构");
+            XSSFSheet authPartySheet = workbook.createSheet("授权机构");
             // sheet样式定义
-            HSSFCellStyle topCellStyle = this.getTopCellStyle(workbook);
-            HSSFCellStyle customCellStyle = this.getCustomCellStyle(workbook);
+//            HSSFCellStyle topCellStyle = this.getTopCellStyle(workbook);
+//            HSSFCellStyle customCellStyle = this.getCustomCellStyle(workbook);
             // 创建列头行
-            HSSFRow productTopRow = authPartySheet.createRow(0);
+            XSSFRow authTopRow = authPartySheet.createRow(0);
             // 添加列头单元格(5个固定列+参数列表)
             String[] rowName = {"机构名称(必填)", "所在地区(必填)", "详细地址(必填)", "经纬度(必填)",
                     "联系电话(必填)", "认证编号(选填)", "认证日期(选填)", "员工人数(必填)", "店铺备注(选填)"};
             for (int i = 0; i < rowName.length; i++) {
-                HSSFCell productTopRowCell = productTopRow.createCell(i);
-                productTopRowCell.setCellType(CellType.valueOf("STRING"));
-                HSSFRichTextString columnText = new HSSFRichTextString(rowName[i]);
-                productTopRowCell.setCellValue(columnText);
-                productTopRowCell.setCellStyle(topCellStyle);
+                XSSFCell authTopRowCell = authTopRow.createCell(i);
+                authTopRowCell.setCellType(CellType.valueOf("STRING"));
+                XSSFRichTextString columnText = new XSSFRichTextString(rowName[i]);
+                authTopRowCell.setCellValue(columnText);
+//                productTopRowCell.setCellStyle(topCellStyle);
             }
             // 行索引
             AtomicInteger authPartyRowNum = new AtomicInteger(1);
 
             authPartyList.forEach(authParty -> {
                 // 创建商品行
-                HSSFRow authRow = authPartySheet.createRow(authPartyRowNum.get());
+                XSSFRow authRow = authPartySheet.createRow(authPartyRowNum.get());
                 // 组装商品数据
                 List<String> authData = new ArrayList<>();
                 authData.add(authParty.getAuthParty());
@@ -767,14 +767,14 @@ public class AuthServiceImpl implements AuthService {
                 authData.add(authParty.getEmpNum().toString());
                 authData.add(authParty.getRemarks());
                 for (int j = 0; j < authData.size(); j++) {
-                    HSSFCell authCell = authRow.createCell(j);
-                    authCell.setCellStyle(customCellStyle);
+                    XSSFCell authCell = authRow.createCell(j);
+//                    authCell.setCellStyle(customCellStyle);
                     if (j == 7) {
                         authCell.setCellType(CellType.NUMERIC);
                         authCell.setCellValue(Integer.parseInt(authData.get(j)));
                     } else {
                         authCell.setCellType(CellType.valueOf("STRING"));
-                        HSSFRichTextString authCellValue = new HSSFRichTextString(authData.get(j));
+                        XSSFRichTextString authCellValue = new XSSFRichTextString(authData.get(j));
                         authCell.setCellValue(authCellValue);
                     }
                 }
@@ -784,7 +784,7 @@ public class AuthServiceImpl implements AuthService {
             for (int colNum = 0; colNum < rowName.length; colNum++) {
                 int productColumnWidth = authPartySheet.getColumnWidth(colNum) / 256;
                 for (int rowNum = 0; rowNum < authPartySheet.getLastRowNum(); rowNum++) {
-                    HSSFRow currentRow;
+                    XSSFRow currentRow;
                     // 当前行未被使用过
                     if (authPartySheet.getRow(rowNum) == null) {
                         currentRow = authPartySheet.createRow(rowNum);
@@ -792,7 +792,7 @@ public class AuthServiceImpl implements AuthService {
                         currentRow = authPartySheet.getRow(rowNum);
                     }
                     if (currentRow.getCell(colNum) != null) {
-                        HSSFCell currentCell = currentRow.getCell(colNum);
+                        XSSFCell currentCell = currentRow.getCell(colNum);
                         if (currentCell.getCellTypeEnum().equals(CellType.valueOf("STRING"))) {
                             int length = currentCell.getStringCellValue()
                                     .getBytes().length;