title: Access to the color palette in an XSSFWorkbook
body: <p>When using POI, cells and fonts in excel documents contain color information which does not always return an rgb value and it often only offers an index value. The indexed value must be looked up against something to get a color. In an HSSFWorkbook (xls) there is a method to available to get the palette:</p>
  
  <pre><code>InputStream in = new FileInputStream("sheet.xls");
  HSSFWorkbook wb = new HSSFWorkbook(in);
  wb.getCustomPalette();
  </code></pre>
  
  <p>When accessing an XSSFWorkbook (xlsx) there is no such method and in fact I can find no palette information anywhere in the related classes. I am able to get the index value from XSSFont and Cell, but the only way to get so much as a color "name" is to match it against the IndexedColors enum. This returns me to the same original problem; I still have no rgb value to use.</p>
  
  <pre><code>InputStream in = new FileInputStream("sheet.xlsx");
  XSSFWorkbook wb = new XSSFWorkbook (in);
  wb.getCustomPalette(); &lt;-- fail!
  </code></pre>
  
  <p>I am getting the XSSFColor by way of the CellStyle, like so:</p>
  
  <pre><code>CellStyle style = cell.getCellStyle();
  XSSFColor color = style.getFillBackgroundColorColor();
  </code></pre>
  
  <p>To get a color name via IndexedColors:</p>
  
  <pre><code>for (IndexedColors c : IndexedColors.values()) { if (c.index == indexColor){ System.out.println("Color: " + c.name()); } }
  </code></pre>
  
  <p>Similar questions: <a href="https://stackoverflow.com/questions/1499739/how-do-i-get-the-java-apache-poi-hssf-background-color-for-a-given-cell?rq=1">How do I get the (Java Apache POI HSSF) Background Color for a given cell?</a></p>
  
  <p>Reference: <a href="http://poi.apache.org/spreadsheet/quick-guide.html#CustomColors" rel="noreferrer">http://poi.apache.org/spreadsheet/quick-guide.html#CustomColors</a></p>
  
  <p><b>Update 1:</b> I've found something that works, finally. This method of XSSFColor returns the ARGB hex code and with it I can determine the RGB values (obviously). I hope this helps save x number of hours for someone with the same issue.</p>
  
  <pre><code>((XSSFColor) color).getARGBHex())
  </code></pre>
  
  <p><b>Update 2:</b> Much to my dismay, I've found that some Cells don't return background XSSFColor containing ARGBHex data. Looking for a work-around for this.</p>