Workbook workbook = new XSSFWorkbook(); Sheet sheet = workbook.createSheet("Sheet1");
// 在单元格中设置值
Row row = sheet.createRow(0);
Cell cell = row.createCell(0); // 创建RichTextString对象
RichTextString richTextString = new XSSFRichTextString("*桩号");
// 创建字体对象
Font starFont = workbook.createFont(); starFont.setColor(Font.COLOR_RED);
// 将"*"设置为红色
richTextString.applyFont(0, 1, starFont);
// 设置单元格值为RichTextString对象 cell.setCellValue(richTextString);