在Java中使用POI获取Excel单元格背景色不需要´;不匹配

在Java中使用POI获取Excel单元格背景色不需要´;不匹配,java,excel,colors,apache-poi,Java,Excel,Colors,Apache Poi,我正在将Excel表格转换为HTML。 我使用Java中的POI获取xls工作簿中单元格的颜色。 问题是颜色不匹配:在Excel中,我有242、220和219的RGB值,但当我使用POI获得它们时,我得到RGB(255153204) 你知道如何得到准确的颜色吗 HSSFCellStyle cs = (HSSFCellStyle) style; out.format(" /* fill pattern = %d */%n", cs.getFillPattern()); sty

我正在将Excel表格转换为HTML。 我使用Java中的POI获取xls工作簿中单元格的颜色。 问题是颜色不匹配:在Excel中,我有242、220和219的RGB值,但当我使用POI获得它们时,我得到RGB(255153204)

你知道如何得到准确的颜色吗

  HSSFCellStyle cs = (HSSFCellStyle) style;
    out.format("  /* fill pattern = %d */%n", cs.getFillPattern());
    styleColorback(out, "background-color", cs.getFillForegroundColorColor())

 private void styleColorback(Formatter out, String attr, HSSFColor color) {
   short[] rgb = color.getTriplet();
   out.format("  %s: #%02x%02x%02x; ", attr, rgb[0], rgb[1], rgb[2]);
 }

我认为不可能获得单元格的确切颜色,因为Excel 2003调色板仅包含56种颜色。 我发现获得准确颜色的唯一方法是,当您在Excel的选项中将Excel格式保存为.xls,然后在保存菜单中,我们可以更改调色板的颜色以获得所需的颜色