Bug 62492 - XSSFFontFormatting.setFontColor IndexOutOfBoundsException
Summary: XSSFFontFormatting.setFontColor IndexOutOfBoundsException
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.17-FINAL
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2018-06-26 23:40 UTC by martin19942010
Modified: 2018-06-27 01:46 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description martin19942010 2018-06-26 23:40:55 UTC
I am trying to set the font of a conditional formatting However when I run

FontFormatting font1 = rule1.createFontFormatting();
font1.setFontColor(new XSSFColor(new java.awt.Color(198, 239, 206)));

I get an IndexOutOfBoundsException Shown below.

Exception in thread "main" java.lang.IndexOutOfBoundsException 
at org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontImpl.setColorArray(Unknown Source)
at org.apache.poi.xssf.usermodel.XSSFFontFormatting.setFontColor(XSSFFontFormatting.java:125)

The code that breaks is 
    public void setFontColor(Color color) {
        XSSFColor xcolor = XSSFColor.toXSSFColor(color);
        if (xcolor == null) {
        } else {
            _font.setColorArray(0, xcolor.getCTColor());

This stack overflow post is the only place I can find the issue mentioned, however I dont beleive they ever submitted a bug report
Comment 1 Greg Woolsey 2018-06-27 01:46:52 UTC
I can't find a bug associated with it, but this was fixed in POI trunk revision 1815086 [1] on Nov. 13, 2017.  It is in the current nightly builds, but there has not been a new release since then.  You could try a nightly build (suggestion recently was use one from a week or so ago).  The nightlies are for an upcoming 4.0 release, and have quite a few breaking API changes, mostly around converting int constant values to proper Enums.  Or you could apply the indicated change as a patch to a local build of 3.17.

[1] http://mail-archives.apache.org/mod_mbox/poi-commits/201711.mbox/%3C20171113114604.5B5253A01A6@svn01-us-west.apache.org%3E