|
@@ -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;
|
|
|
}
|
|
|
}
|