Examples of CTCell


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

     * @see Cell#CELL_TYPE_FORMULA
     * @see Cell#CELL_TYPE_NUMERIC
     * @see Cell#CELL_TYPE_STRING
     */
    public XSSFCell createCell(int columnIndex, int type) {
        CTCell ctCell;
        XSSFCell prev = _cells.get(columnIndex);
        if(prev != null){
            ctCell = prev.getCTCell();
            ctCell.set(CTCell.Factory.newInstance());
        } else {
            ctCell = _row.addNewC();
        }
        XSSFCell xcell = new XSSFCell(this, ctCell);
        xcell.setCellNum(columnIndex);
View Full Code Here

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

        if(_row.sizeOfCArray() != _cells.size()) isOrdered = false;
        else {
            int i = 0;
            CTCell[] xcell = _row.getCArray();
            for (XSSFCell cell : _cells.values()) {
                CTCell c1 = cell.getCTCell();
                CTCell c2 = xcell[i++];

                String r1 = c1.getR();
                String r2 = c2.getR();
                if (!(r1==null ? r2==null : r1.equals(r2))){
                    isOrdered = false;
                    break;
                }
            }
View Full Code Here

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

            }

            //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

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

        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);
        }
        if (f != null && f.getT() == STCellFormulaType.ARRAY && f.getRef() != null) {
            arrayFormulas.add(CellRangeAddress.valueOf(f.getRef()));
View Full Code Here

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

    /**
     * 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());
        if(_cell.isSetS()) blank.setS(_cell.getS());
        _cell.set(blank);
    }
View Full Code Here

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

     * @param index Position where to insert cell.
     * @param type TODO
     * @return The new cell.
     */
    protected XSSFCell addCell(int column, int index, int type) {
        CTCell ctcell = row.insertNewC(index);
        XSSFCell xcell = new XSSFCell(this, ctcell);
        xcell.setCellNum(column);
        if (type != Cell.CELL_TYPE_BLANK) {
          xcell.setCellType(type);
        }
View Full Code Here

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

       
        assertTrue( Double.isNaN( cell.getNumericCellValue() ));
    }
   
    public void testSetGetStringInline() throws Exception {
        CTCell rawCell = CTCell.Factory.newInstance();
        XSSFRow row = createParentObjects();
        XSSFCell cell = new XSSFCell(row, rawCell);
       
        // Default is shared string mode, so have to do this explicitly
        rawCell.setT(STCellType.INLINE_STR);
       
        assertEquals(STCellType.INT_INLINE_STR, rawCell.getT().intValue());
        assertEquals(Cell.CELL_TYPE_STRING, cell.getCellType());
        assertEquals("", cell.getRichStringCellValue().getString());
       
        cell.setCellValue(new XSSFRichTextString("Foo"));
        assertEquals(STCellType.INT_INLINE_STR, rawCell.getT().intValue());
        assertEquals(Cell.CELL_TYPE_STRING, cell.getCellType());
        assertEquals("Foo", cell.getRichStringCellValue().getString());
       
        // To number and back to string, stops being inline
        cell.setCellValue(1.4);
        cell.setCellValue(new XSSFRichTextString("Foo2"));
        assertEquals(STCellType.INT_S, rawCell.getT().intValue());
        assertEquals(Cell.CELL_TYPE_STRING, cell.getCellType());
        assertEquals("Foo2", cell.getRichStringCellValue().getString());
    }
View Full Code Here

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

        comment.setAuthor(TEST_C10_AUTHOR);
       
        // Set a comment for C10 cell
        cell.setCellComment(comment);
       
        CTCell ctCell = ctWorksheet.getSheetData().getRowArray(0).getCArray(0);
    assertNotNull(ctCell);
    assertEquals("C10", ctCell.getR());
    long authorId = ctComments.getCommentList().getCommentArray(0).getAuthorId();
    assertEquals(TEST_C10_AUTHOR, comments.getAuthor(authorId));
    }
View Full Code Here

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

    /**
     * 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());
        if(_cell.isSetS()) blank.setS(_cell.getS());
        _cell.set(blank);
    }
View Full Code Here

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

    }

    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
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.