50,528
社区成员
发帖
与我相关
我的任务
分享
List<String> list = dealRemark(textValue);
int[] rgb = new int[3];
String hexColor = list.get(0);
if (hexColor != null) {
rgb = dealHexColorToRGB(hexColor);
}
// 自定义颜色开始
HSSFPalette palette = workbook.getCustomPalette();
System.out.println("RGB["+(byte)rgb[0]+","+(byte)rgb[1]+","+(byte)rgb[2]+"]");
System.out.println("HSSFColor.BLACK.index 第一 :"+HSSFColor.BLACK.index);
palette.setColorAtIndex(HSSFColor.BLACK.index,(byte)rgb[0], (byte)rgb[1], (byte)rgb[2]);
// 自定义颜色结束
HSSFRichTextString richString = new HSSFRichTextString(
list.get(1));
HSSFFont font4 = workbook.createFont();
System.out.println("HSSFColor.BLACK.index 第二 :"+HSSFColor.BLACK.index);
font4.setColor(HSSFColor.BLACK.index);
richString.applyFont(font4);
HSSFCellStyle cellStyle=workbook.createCellStyle();
cellStyle.setFont(font4);
cell.setCellValue(richString);