title: How to use colors not in IndexedColors for Apache POI XSSF Excel?
body: <p>I am looking at an excel sheet that I am wanting to duplicate and the only issue I am having is with colors. The colors I am looking to duplicate are <code>Blue, Accent 5, Lighter 40%</code> and <code>Light Green</code> from the <code>Standard Colors</code> section. I am looking at the <a href="https://poi.apache.org/components/spreadsheet/quick-guide.html#CustomColors" rel="nofollow noreferrer">docs</a> for using custom colors in an XSSF Workbook and it states that the way to do it is like this:</p>
  
  <pre><code>XSSFWorkbook wb = new XSSFWorkbook();
  XSSFSheet sheet = wb.createSheet();
  XSSFRow row = sheet.createRow(0);
  XSSFCell cell = row.createCell(0);
  cell.setCellValue("custom XSSF colors");
  
  XSSFCellStyle style1 = wb.createCellStyle();
  style1.setFillForegroundColor(new XSSFColor(new java.awt.Color(128, 0, 128), new DefaultIndexedColorMap()));
  style1.setFillPattern(FillPatternType.SOLID_FOREGROUND);
  </code></pre>
  
  <p>When I try to use <code>style1.setFillForegroundColor(new XSSFColor(new java.awt.Color(128, 0, 128), new DefaultIndexedColorMap()));</code> I get an error, since the only parameter that <code>.setFillForegroundColor()</code> only takes one parameter, and that is a <code>short</code> and not an <code>XSSFColor</code>.</p>
  
  <p>Has anyone had any luck with this? I have been searching for hours and can't find anything that isn't 8 years old or doesn't work.</p>