|
@@ -2282,7 +2282,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
} else {
|
|
} else {
|
|
Row row = sheet.getRow(y1 - 1);
|
|
Row row = sheet.getRow(y1 - 1);
|
|
if (row != null) {
|
|
if (row != null) {
|
|
- Cell cell = row.getCell(x1 - 1);
|
|
|
|
|
|
+ Cell cell = row.getCell(x1 - 1, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
|
if (cell != null || ObjectUtils.isNotEmpty(cell)) {
|
|
if (cell != null || ObjectUtils.isNotEmpty(cell)) {
|
|
short fontIndex = cell.getCellStyle().getFontIndex();
|
|
short fontIndex = cell.getCellStyle().getFontIndex();
|
|
Font fontAt = workbook.getFontAt(fontIndex);
|
|
Font fontAt = workbook.getFontAt(fontIndex);
|
|
@@ -2312,14 +2312,21 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
Row row = sheet.getRow(y1 - 1);
|
|
Row row = sheet.getRow(y1 - 1);
|
|
if (row != null) {
|
|
if (row != null) {
|
|
- Cell cell = row.getCell(x1 - 1);
|
|
|
|
|
|
+ Cell cell = row.getCell(x1 - 1, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
|
if (cell != null || ObjectUtils.isNotEmpty(cell)) {
|
|
if (cell != null || ObjectUtils.isNotEmpty(cell)) {
|
|
// 获取单元格的现有值
|
|
// 获取单元格的现有值
|
|
String existingValue = cell.getStringCellValue();
|
|
String existingValue = cell.getStringCellValue();
|
|
// 获取单元格的现有富文本字符串
|
|
// 获取单元格的现有富文本字符串
|
|
RichTextString existingRichTextString = cell.getRichStringCellValue();
|
|
RichTextString existingRichTextString = cell.getRichStringCellValue();
|
|
|
|
+ String s = null;
|
|
|
|
+ if(StringUtils.isEmpty(existingValue)){
|
|
|
|
+ s = dqid;
|
|
|
|
+ }else{
|
|
|
|
+ s = existingValue + "*" + dqid;
|
|
|
|
+ }
|
|
|
|
+
|
|
// 创建一个新的副文本字符串,原有值+电签ID
|
|
// 创建一个新的副文本字符串,原有值+电签ID
|
|
- RichTextString richTextString = workbook.getCreationHelper().createRichTextString(existingValue + " *" + dqid);
|
|
|
|
|
|
+ RichTextString richTextString = workbook.getCreationHelper().createRichTextString(s);
|
|
// 复制原有部分的字体格式
|
|
// 复制原有部分的字体格式
|
|
if (existingRichTextString instanceof XSSFRichTextString) {
|
|
if (existingRichTextString instanceof XSSFRichTextString) {
|
|
XSSFRichTextString xssfRichTextString = (XSSFRichTextString) existingRichTextString;
|
|
XSSFRichTextString xssfRichTextString = (XSSFRichTextString) existingRichTextString;
|
|
@@ -2350,7 +2357,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
newFont.setColor(IndexedColors.WHITE.getIndex());
|
|
newFont.setColor(IndexedColors.WHITE.getIndex());
|
|
newFont.setFontHeightInPoints(Short.valueOf("1")); // 可根据需要调整字体大小
|
|
newFont.setFontHeightInPoints(Short.valueOf("1")); // 可根据需要调整字体大小
|
|
//从原有值之后,电签ID开始设置成新的格式。
|
|
//从原有值之后,电签ID开始设置成新的格式。
|
|
- richTextString.applyFont(existingValue.length(), existingValue.length() + dqid.length(), newFont);
|
|
|
|
|
|
+ richTextString.applyFont(existingValue.length(), s.length(), newFont);
|
|
// 将副文本字符串设置到单元格
|
|
// 将副文本字符串设置到单元格
|
|
cell.setCellValue(richTextString);
|
|
cell.setCellValue(richTextString);
|
|
}
|
|
}
|