Package org.apache.poi.xssf.usermodel

Examples of org.apache.poi.xssf.usermodel.XSSFColor


        int cnt = 0;
        for (XmlObject obj : colorScheme.selectPath("./*")) {
            if (obj instanceof org.openxmlformats.schemas.drawingml.x2006.main.CTColor) {
                if (cnt == idx) {
                    ctColor = (org.openxmlformats.schemas.drawingml.x2006.main.CTColor) obj;
                    return new XSSFColor(ctColor.getSrgbClr().getVal());
                }
                cnt++;
            }
        }
        return null;
View Full Code Here


                    } else if (ctColor.getSysClr() != null) {
                       // Colour is a tint of white or black
                       rgb = ctColor.getSysClr().getLastClr();
                    }

                    return new XSSFColor(rgb);
                }
                cnt++;
            }
        }
        return null;
View Full Code Here

          // No theme set, nothing to do
          return;
       }
      
       // Get the theme colour
       XSSFColor themeColor = getThemeColor(color.getTheme());
       // Set the raw colour, not the adjusted one
       color.setRgb(themeColor.getCTColor().getRgb());
      
       // All done
    }
View Full Code Here

                    } else if (ctColor.getSysClr() != null) {
                       // Colour is a tint of white or black
                       rgb = ctColor.getSysClr().getLastClr();
                    }

                    return new XSSFColor(rgb);
                }
                cnt++;
            }
        }
        return null;
View Full Code Here

          // No theme set, nothing to do
          return;
       }
      
       // Get the theme colour
       XSSFColor themeColor = getThemeColor(color.getTheme());
       // Set the raw colour, not the adjusted one
       // Do a raw set, no adjusting at the XSSFColor layer either
       color.getCTColor().setRgb(themeColor.getCTColor().getRgb());
      
       // All done
    }
View Full Code Here

    public XSSFColor getFillBackgroundColor() {
        CTPatternFill ptrn = _fill.getPatternFill();
        if (ptrn == null) return null;

        CTColor ctColor = ptrn.getBgColor();
        return ctColor == null ? null : new XSSFColor(ctColor);
    }
View Full Code Here

    public XSSFColor getFillForegroundColor() {
        CTPatternFill ptrn = _fill.getPatternFill();
        if (ptrn == null) return null;

        CTColor ctColor = ptrn.getFgColor();
        return ctColor == null ? null : new XSSFColor(ctColor);
    }
View Full Code Here

     */
    public XSSFColor getBorderColor(BorderSide side) {
        CTBorderPr borderPr = getBorder(side);
       
        if(borderPr != null && borderPr.isSetColor()) {
            XSSFColor clr = new XSSFColor(borderPr.getColor());
            if(_theme != null) {
               _theme.inheritFromThemeAsRequired(clr);
            }
            return clr;
        } else {
View Full Code Here

    public void testColorFromTheme() {
        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("styles.xlsx");
        XSSFCell cellWithThemeColor = wb.getSheetAt(0).getRow(10).getCell(0);
        //color RGB will be extracted from theme
        XSSFColor foregroundColor = cellWithThemeColor.getCellStyle().getFillForegroundXSSFColor();
        byte[] rgb = foregroundColor.getRgb();
        byte[] rgbWithTint = foregroundColor.getRgbWithTint();
        assertEquals(rgb[0],-18);
        assertEquals(rgb[1],-20);
        assertEquals(rgb[2],-31);
        assertEquals(rgbWithTint[0],-12);
        assertEquals(rgbWithTint[1],-13);
View Full Code Here

        };
        boolean createFile = false;
        int i=0;
        for (Row row : workbook.getSheetAt(0)) {
            XSSFFont font = ((XSSFRow)row).getCell(0).getCellStyle().getFont();
            XSSFColor color = font.getXSSFColor();
            assertEquals("Failed color theme "+i, rgbExpected[i], Hex.encodeHexString(color.getRgb()));
            long themeIdx = font.getCTFont().getColorArray(0).getTheme();
            assertEquals("Failed color theme "+i, i, themeIdx);
            if (createFile) {
                XSSFCellStyle cs = (XSSFCellStyle)row.getSheet().getWorkbook().createCellStyle();
                cs.setFillForegroundColor(color);
View Full Code Here

TOP

Related Classes of org.apache.poi.xssf.usermodel.XSSFColor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.