|
@@ -742,12 +742,22 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
|
|
|
CreationHelper helper = workbook.getCreationHelper();
|
|
|
RichTextString richText = helper.createRichTextString(displayText);
|
|
|
|
|
|
+ // 🔴🔴🔴 新增:获取原单元格的字体样式 🔴🔴🔴
|
|
|
+ CellStyle originalStyle = cell.getCellStyle();
|
|
|
+ Font originalFont = workbook.getFontAt(originalStyle.getFontIndex());
|
|
|
+
|
|
|
// 创建白色字体(用于"占位"两字)
|
|
|
Font whiteFont = workbook.createFont();
|
|
|
- whiteFont.setColor(IndexedColors.WHITE.getIndex());
|
|
|
+ // 🟢🟢🟢 修改:继承原字体属性 🟢🟢🟢
|
|
|
+ whiteFont.setFontName(originalFont.getFontName()); // 继承字体名称
|
|
|
+ whiteFont.setFontHeightInPoints(originalFont.getFontHeightInPoints()); // 继承字号
|
|
|
+ whiteFont.setColor(IndexedColors.WHITE.getIndex()); // 只修改颜色
|
|
|
|
|
|
// 创建默认黑色字体(用于实际文本)
|
|
|
Font defaultFont = workbook.createFont();
|
|
|
+ // 🟢🟢🟢 修改:继承原字体属性 🟢🟢🟢
|
|
|
+ defaultFont.setFontName(originalFont.getFontName());
|
|
|
+ defaultFont.setFontHeightInPoints(originalFont.getFontHeightInPoints());
|
|
|
defaultFont.setColor(IndexedColors.BLACK.getIndex());
|
|
|
|
|
|
// 🔴 修复:正确设置索引范围
|
|
@@ -756,7 +766,7 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
|
|
|
|
|
|
// 剩余字符:黑色(从索引2开始)
|
|
|
if (displayText.length() > 2) {
|
|
|
- richText.applyFont(3, displayText.length() - 1, defaultFont);
|
|
|
+ richText.applyFont(2, displayText.length() , defaultFont);
|
|
|
}
|
|
|
|
|
|
// 3. 设置单元格值
|