Examples of CTFill


Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill


public class TestXSSFCellFill extends TestCase {
 
  public void testGetFillBackgroundColor() {
    CTFill ctFill = CTFill.Factory.newInstance();
    XSSFCellFill cellFill = new XSSFCellFill(ctFill);
    CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
    CTColor bgColor = ctPatternFill.addNewBgColor();
    assertNotNull(cellFill.getFillBackgroundColor());
    bgColor.setIndexed(2);
    assertEquals(2, cellFill.getFillBackgroundColor().getIndexed());
  }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill

    bgColor.setIndexed(2);
    assertEquals(2, cellFill.getFillBackgroundColor().getIndexed());
  }
 
  public void testGetFillForegroundColor() {
    CTFill ctFill = CTFill.Factory.newInstance();
    XSSFCellFill cellFill = new XSSFCellFill(ctFill);
    CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
    CTColor fgColor = ctPatternFill.addNewFgColor();
    assertNotNull(cellFill.getFillForegroundColor());
    fgColor.setIndexed(8);
    assertEquals(8, cellFill.getFillForegroundColor().getIndexed());
  }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill

    fgColor.setIndexed(8);
    assertEquals(8, cellFill.getFillForegroundColor().getIndexed());
  }
 
  public void testGetPatternType() {
    CTFill ctFill = CTFill.Factory.newInstance();
    XSSFCellFill cellFill = new XSSFCellFill(ctFill);
    CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
    ctPatternFill.setPatternType(STPatternType.DARK_DOWN);
    assertEquals(8, cellFill.getPatternType().intValue());
  }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill

  }
  private void initialize() {
    CTFont ctFont = createDefaultFont();
      fonts.add(ctFont);
     
      CTFill ctFill = createDefaultFill();
      fills.add(ctFill);
     
      CTBorder ctBorder = createDefaultBorder();
      borders.add(ctBorder);
     
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill

      ctBorder.addNewRight();
      ctBorder.addNewDiagonal();
    return ctBorder;
  }
  private CTFill createDefaultFill() {
    CTFill ctFill = CTFill.Factory.newInstance();
      ctFill.addNewPatternFill().setPatternType(STPatternType.NONE);
    return ctFill;
  }
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill

     * for the color to be shown in the cell.
     *
     * @param color - the color to use
     */
    public void setFillBackgroundColor(XSSFColor color) {
        CTFill ct = getCTFill();
        CTPatternFill ptrn = ct.getPatternFill();
        if(color == null) {
            if(ptrn != null) ptrn.unsetBgColor();
        } else {
            if(ptrn == null) ptrn = ct.addNewPatternFill();
            ptrn.setBgColor(color.getCTColor());
        }

        int idx = _stylesSource.putFill(new XSSFCellFill(ct));

View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill

    * <i>Note: Ensure Foreground color is set prior to background color.</i>
    * @param color the color to use
    * @see #setFillBackgroundColor(org.apache.poi.xssf.usermodel.XSSFColor) )
    */
    public void setFillForegroundColor(XSSFColor color) {
        CTFill ct = getCTFill();

        CTPatternFill ptrn = ct.getPatternFill();
        if(color == null) {
            if(ptrn != null) ptrn.unsetFgColor();
        } else {
            if(ptrn == null) ptrn = ct.addNewPatternFill();
            ptrn.setFgColor(color.getCTColor());
        }

        int idx = _stylesSource.putFill(new XSSFCellFill(ct));

View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill

    /**
     * Get a <b>copy</b> of the currently used CTFill, if none is used, return a new instance.
     */
    private CTFill getCTFill(){
        CTFill ct;
        if(_cellXf.getApplyFill()) {
            int fillIndex = (int)_cellXf.getFillId();
            XSSFCellFill cf = _stylesSource.getFillAt(fillIndex);

            ct = (CTFill)cf.getCTFill().copy();
View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill

     * @see #setFillBackgroundColor(short)
     * @see #setFillForegroundColor(short)
     * @param fp  fill pattern (set to {@link org.apache.poi.ss.usermodel.CellStyle#SOLID_FOREGROUND} to fill w/foreground color)
     */
   public void setFillPattern(short fp) {
        CTFill ct = getCTFill();
        CTPatternFill ptrn = ct.isSetPatternFill() ? ct.getPatternFill() : ct.addNewPatternFill();
        if(fp == NO_FILL && ptrn.isSetPatternType()) ptrn.unsetPatternType();
        else ptrn.setPatternType(STPatternType.Enum.forInt(fp + 1));

        int idx = _stylesSource.putFill(new XSSFCellFill(ct));

View Full Code Here

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill

        //id of the created border
        int fillId = (int)cellStyle.getCoreXf().getFillId();
        assertTrue(fillId > 0);
        //check changes in the underlying xml bean
        CTFill ctFill = stylesTable.getFillAt(fillId).getCTFill();
        assertEquals(IndexedColors.RED.getIndex(), ctFill.getPatternFill().getBgColor().getIndexed());

        //setting XSSFColor
        num = stylesTable.getFills().size();
        clr = new XSSFColor(java.awt.Color.CYAN);
        cellStyle.setFillBackgroundColor(clr);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.