对应颜色数值https://www.cnblogs.com/yanjie-java/p/8329631.html
HSSFRow attentionRow = sheet.createRow(0); attentionRow.setHeightInPoints((short)30); HSSFCell attentionCell = attentionRow.createCell(0); attentionCell.setCellStyle(attentionStyle); HSSFRichTextString richString = new HSSFRichTextString(title); Font font1 = attentionStyle.getFont(workbook); attentionStyle.setFont(font1); //第一段 Font font2 = generateHSSFFont(workbook,"宋体",false,18); font2.setColor(Font.COLOR_RED); richString.applyFont(0, title.indexOf("项目体")+3, font2); //第二段 Font font3 = generateHSSFFont(workbook,"宋体",false,18); font3.setColor(HSSFColor.SKY_BLUE.index); richString.applyFont( title.indexOf("项目体")+3, title.indexOf("用电"), font3); //第三段 Font font4 = generateHSSFFont(workbook,"宋体",false,18); font4.setColor(HSSFColor.BLACK.index); richString.applyFont( title.indexOf("用电"), title.indexOf("用电")+2, font4); //第四段 Font font5 = generateHSSFFont(workbook,"宋体",false,18); font5.setColor(HSSFColor.GOLD.index); richString.applyFont( title.indexOf("用电")+2, title.length(), font5); attentionCell.setCellValue(richString); attentionCell.setCellValue(richString);