永发信息网

POI中怎么使用自定义字体颜色

答案:1  悬赏:0  手机版
解决时间 2021-04-06 20:26
  • 提问者网友:容嬷嬷拿针来
  • 2021-04-06 08:42
POI中怎么使用自定义字体颜色
最佳答案
  • 五星知识达人网友:孤老序
  • 2021-04-06 10:06
String str = "#3366FF";
//处理把它转换成十六进制并放入一个数
int[] color=new int[3];
color[0]=Integer.parseInt(str.substring(1, 3), 16);
color[1]=Integer.parseInt(str.substring(3, 5), 16);
color[2]=Integer.parseInt(str.substring(5, 7), 16);
//自定义颜色
HSSFPalette palette = workbook.getCustomPalette();
palette.setColorAtIndex(HSSFColor.BLACK.index,(byte)color[0], (byte)color[1], (byte)color[2]);
//将自定义的颜色引入进来
HSSFFont font=workbook.createFont();
font.setColor(HSSFColor.BLACK.index);
HSSFCellStyle cellStyle=workbook.createCellStyle();
cellStyle.setFont(font);
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯