Просмотр исходного кода

修改bug:试验检测pdf中生成的受控号显示不完整

lvy 2 месяцев назад
Родитель
Сommit
d1ece765dc

+ 22 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -3107,8 +3107,29 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                         }
 
                         if (cellValue != null && !cellValue.isEmpty()) {
-                            if (cellValue.contains(oldContext)) {
+                            if (cellValue.equals(oldContext) && j + 1 < cellNum) {
+                                Cell nextCell = row.getCell(j + 1);
+                                String nextCellValue;
+                                if (nextCell.getCellType() == 0) {
+                                    double numValue = cell.getNumericCellValue();
+                                    nextCellValue = String.valueOf(numValue);
+                                } else {
+                                    nextCellValue = nextCell.getStringCellValue();
+                                }
+                                if (nextCellValue == null || nextCellValue.isEmpty()) {
+                                    nextCell.setCellValue(newContext.replace(oldContext, ""));
+                                    CellStyle cellStyle = cell.getCellStyle();
+                                    // 设置自动换行
+                                    cellStyle.setWrapText(true);
+                                    cell.setCellStyle(cellStyle);
+                                    return true;
+                                }
+                            } else if (cellValue.contains(oldContext)) {
                                 cell.setCellValue(newContext);
+                                CellStyle cellStyle = cell.getCellStyle();
+                                cellStyle.setWrapText(true);
+                                cell.setCellStyle(cellStyle);
+                                row.setHeight((short) (row.getHeight() * 1.5));
                                 return true;
                             }
                         }