Package org.openxmlformats.schemas.spreadsheetml.x2006.main

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


    CTFill[] ctFill = createDefaultFills();
    fills.add(new XSSFCellFill(ctFill[0]));
    fills.add(new XSSFCellFill(ctFill[1]));

    CTBorder ctBorder = createDefaultBorder();
    borders.add(new XSSFCellBorder(ctBorder));

    CTXf styleXf = createDefaultXf();
    styleXfs.add(styleXf);
    CTXf xf = createDefaultXf();
View Full Code Here


    ctXf.setFillId(0);
    ctXf.setBorderId(0);
    return ctXf;
  }
  private static CTBorder createDefaultBorder() {
    CTBorder ctBorder = CTBorder.Factory.newInstance();
    ctBorder.addNewBottom();
    ctBorder.addNewTop();
    ctBorder.addNewLeft();
    ctBorder.addNewRight();
    ctBorder.addNewDiagonal();
    return ctBorder;
  }
View Full Code Here

                for (CTFill fill : ctfills.getFillArray()) {
                    fills.add(new XSSFCellFill(fill));
                }
            }

            CTBorders ctborders = styleSheet.getBorders();
            if(ctborders != null) {
                for (CTBorder border : ctborders.getBorderArray()) {
                    borders.add(new XSSFCellBorder(border));
                }
            }

            CTCellXfs cellXfs = styleSheet.getCellXfs();
View Full Code Here

    for(XSSFCellFill f : fills) ctf[idx++] = f.getCTFill();
    ctFills.setFillArray(ctf);
    styleSheet.setFills(ctFills);

    // Borders
    CTBorders ctBorders = CTBorders.Factory.newInstance();
    ctBorders.setCount(borders.size());
    CTBorder[] ctb = new CTBorder[borders.size()];
    idx = 0;
    for(XSSFCellBorder b : borders) ctb[idx++] = b.getCTBorder();
    ctBorders.setBorderArray(ctb);
    styleSheet.setBorders(ctBorders);

    // Xfs
    if(xfs.size() > 0) {
      CTCellXfs ctXfs = CTCellXfs.Factory.newInstance();
View Full Code Here

        return sharedFormulas.get(sid);
    }

    void onReadCell(XSSFCell cell){
        //collect cells holding shared formulas
        CTCell ct = cell.getCTCell();
        CTCellFormula f = ct.getF();
        if (f != null && f.getT() == STCellFormulaType.SHARED && f.isSetRef() && f.getStringValue() != null) {
            // save a detached  copy to avoid XmlValueDisconnectedException,
            // this may happen when the master cell of a shared formula is changed
            sharedFormulas.put((int)f.getSi(), (CTCellFormula)f.copy());
        }
View Full Code Here

     * @see Cell#CELL_TYPE_FORMULA
     * @see Cell#CELL_TYPE_NUMERIC
     * @see Cell#CELL_TYPE_STRING
     */
    public XSSFCell createCell(int columnIndex, int type) {
        CTCell ctcell = CTCell.Factory.newInstance();
        XSSFCell xcell = new XSSFCell(this, ctcell);
        xcell.setCellNum(columnIndex);
        if (type != Cell.CELL_TYPE_BLANK) {
          xcell.setCellType(type);
        }
View Full Code Here

            XSSFCell cell = (XSSFCell)c;

            //remove the reference in the calculation chain
            if(calcChain != null) calcChain.removeItem(sheetId, cell.getReference());

            CTCell ctCell = cell.getCTCell();
            String r = new CellReference(rownum, cell.getColumnIndex()).formatAsString();
            ctCell.setR(r);
        }
        setRowNum(rownum);
    }
View Full Code Here

    /**
     * Blanks this cell. Blank cells have no formula or value but may have styling.
     * This method erases all the data previously associated with this cell.
     */
    private void setBlank(){
        CTCell blank = CTCell.Factory.newInstance();
        blank.setR(cell.getR());
        blank.setS(cell.getS());
        cell.set(blank);
    }
View Full Code Here

        return sharedFormulas.get(sid);
    }

    void onReadCell(XSSFCell cell){
        //collect cells holding shared formulas
        CTCell ct = cell.getCTCell();
        CTCellFormula f = ct.getF();
        if(f != null && f.getT() == STCellFormulaType.SHARED && f.isSetRef() && f.getStringValue() != null){
            sharedFormulas.put((int)f.getSi(), cell);
        }
    }
View Full Code Here

    }

    public void testFormulaString() {
        XSSFWorkbook wb = new XSSFWorkbook();
        XSSFCell cell = wb.createSheet().createRow(0).createCell(0);
        CTCell ctCell = cell.getCTCell(); //low-level bean holding cell's xml

        cell.setCellFormula("A2");
        assertEquals(XSSFCell.CELL_TYPE_FORMULA, cell.getCellType());
        //the value is not set and cell's type='N' which means blank
        assertEquals(STCellType.N, ctCell.getT());

        //set cached formula value
        cell.setCellValue("t='str'");
        //we are still of 'formula' type
        assertEquals(XSSFCell.CELL_TYPE_FORMULA, cell.getCellType());
        //cached formula value is set and cell's type='STR'
        assertEquals(STCellType.STR, ctCell.getT());
        assertEquals("t='str'", cell.getStringCellValue());

        //now remove the formula, the cached formula result remains
        cell.setCellFormula(null);
        assertEquals(XSSFCell.CELL_TYPE_STRING, cell.getCellType());
        assertEquals(STCellType.STR, ctCell.getT());
        //the line below failed prior to fix of Bug #47889
        assertEquals("t='str'", cell.getStringCellValue());

        //revert to a blank cell
        cell.setCellValue((String)null);
        assertEquals(XSSFCell.CELL_TYPE_BLANK, cell.getCellType());
        assertEquals(STCellType.N, ctCell.getT());
        assertEquals("", cell.getStringCellValue());
    }
View Full Code Here

TOP

Related Classes of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell

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.