poi设置单元格内不同字体的样式
代码如下:
cell0To3.setCellValue("变更内容:"+changeContent);
String title = cell0To3.getStringCellValue();
Font black = wb.getFontAt(cell0To3.getCellStyle().getFontIndex());
XSSFRichTextString richString = new XSSFRichTextString("变更内容:"+changeContent);
//通过索引指定哪些文字需要什么颜色
richString.applyFont(5, title.length(), black); //字体显示哪部分字符设置新的字体样式Font
cell0To3.setCellValue(richString);

浙公网安备 33010602011771号