protected XSSFColor extractColor(XSSFCell cell, XSSFColor... acceptableColors) { XSSFCellStyle cellStyle = cell.getCellStyle(); FillPatternType fillPattern = cellStyle.getFillPatternEnum(); if (fillPattern == null || fillPattern == FillPatternType.NO_FILL) { return null; } if (fillPattern != FillPatternType.SOLID_FOREGROUND) { throw new IllegalStateException(currentPosition() + ": The fill pattern (" + fillPattern + ") should be either " + FillPatternType.NO_FILL + " or " + FillPatternType.SOLID_FOREGROUND + "."); } XSSFColor color = cellStyle.getFillForegroundColorColor(); for (XSSFColor acceptableColor : acceptableColors) { if (acceptableColor.equals(color)) { return acceptableColor; } } throw new IllegalStateException(currentPosition() + ": The fill color (" + color + ") is not one of the acceptableColors (" + Arrays.toString(acceptableColors) + ")."); } }
protected XSSFColor extractColor(XSSFCell cell, XSSFColor... acceptableColors) { XSSFCellStyle cellStyle = cell.getCellStyle(); FillPatternType fillPattern = cellStyle.getFillPatternEnum(); if (fillPattern == null || fillPattern == FillPatternType.NO_FILL) { return null; } if (fillPattern != FillPatternType.SOLID_FOREGROUND) { throw new IllegalStateException(currentPosition() + ": The fill pattern (" + fillPattern + ") should be either " + FillPatternType.NO_FILL + " or " + FillPatternType.SOLID_FOREGROUND + "."); } XSSFColor color = cellStyle.getFillForegroundColorColor(); for (XSSFColor acceptableColor : acceptableColors) { if (acceptableColor.equals(color)) { return acceptableColor; } } throw new IllegalStateException(currentPosition() + ": The fill color (" + color + ") is not one of the acceptableColors (" + Arrays.toString(acceptableColors) + ")."); } }
if (style.getFillPatternEnum() == FillPatternType.SOLID_FOREGROUND) { XSSFColor fillForegroundXSSFColor = style .getFillForegroundXSSFColor();
if (style.getFillPatternEnum() == FillPatternType.SOLID_FOREGROUND) { final XSSFColor fillForegroundXSSFColor = style.getFillForegroundXSSFColor(); final String argb = fillForegroundXSSFColor.getARGBHex();
if (style.getFillPatternEnum() == FillPatternType.SOLID_FOREGROUND) { final XSSFColor fillForegroundXSSFColor = style.getFillForegroundXSSFColor(); final String argb = fillForegroundXSSFColor.getARGBHex();
style.setForecolor("0,0,0"); FillPatternType pattern=cellStyle.getFillPatternEnum(); if(pattern!=null && pattern.equals(FillPatternType.SOLID_FOREGROUND)){ XSSFColor bgcolor=cellStyle.getFillForegroundColorColor();