Java POI 设置字体下划线
1.通过代码设置
private XSSFRichTextString UnderLineIndex(String content, Font font) {
font.setUnderline((byte)1);
XSSFRichTextString richString = new XSSFRichTextString(content);
richString.applyFont(6, content.length(), font);
font.setUnderline((byte)0);
return richString;
}
2. 通过excel模板,直接字符串替换
private void fillCellValue(XSSFCell cell) {
String stringCellValue = cell.getStringCellValue().replace("${recuritName}", "余波");
cell.setCellValue( stringCellValue );
}
Java POI 输出方框打勾
1.代码设置
private RichTextString fillTextRight(String content, Font font){
RichTextString richTextString = new XSSFRichTextString("("\\\u25A1"");
font.setFontName("Wingdings 2");
richTextString.applyFont(, font);
return richTextString;
}
2.直接字符串输出
cell.setStringCellValue("□");
cell.setStringCellValue("?");
Java POI 设置字体下划线
private RichTextString blodText(String content, Font font, int start, int end ) {
RichTextString richTextString = new XSSFRichTextString(content);
font.setFontName("宋体");
font.setBold(true);
short fontHeight = font.getFontHeightInPoints();
font.setFontHeightInPoints((short) 10);
richTextString.applyFont(start, end , font);
font.setFontHeightInPoints(fontHeight);
font.setBold(false);
return richTextString;
}
|