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

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


     * @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));

        _cellXf.setFillId(idx);
        _cellXf.setApplyFill(true);
View Full Code Here


    /**
     * ensure that the array of CTRow written to CTSheetData is ordered by row index
     */
    private void ensureRowOrdering(){
        CTSheetData sheetData = worksheet.getSheetData();
        // check if row indexes in CTSheetData match the internal model:
        // rows in the internal model (_rows) are always ordered while
        // CTRow beans held by CTSheetData may be not, for example, user can
        // insert rows in random order, shift rows after insertion, etc.
        boolean isOrdered = true;
        if(sheetData.sizeOfRowArray() != _rows.size()) isOrdered = false;
        else {
            int i = 0;
            for (XSSFRow row : _rows.values()) {
                CTRow c1 = row.getCTRow();
                CTRow c2 = sheetData.getRowArray(i++);
                if (c1.getR() != c2.getR()){
                    isOrdered = false;
                    break;
                }
            }
        }
       
        if(!isOrdered){
            CTRow[] cArray = new CTRow[_rows.size()];
            int i = 0;
            for(XSSFRow row : _rows.values()){
                cArray[i++] = row.getCTRow();
            }
            sheetData.setRowArray(cArray);
        }
    }
View Full Code Here

                ctHls[i] = hyperlink.getCTHyperlink();
            }
            worksheet.getHyperlinks().setHyperlinkArray(ctHls);
        }

        CTSheetData sheetData = worksheet.getSheetData();
        ArrayList<CTRow> rArray = new ArrayList<CTRow>(rows.size());
        for(XSSFRow row : rows.values()){
            row.onDocumentWrite();
            rArray.add(row.getCTRow());
        }
        sheetData.setRowArray(rArray.toArray(new CTRow[rArray.size()]));

        XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
        xmlOptions.setSaveSyntheticDocumentElement(new QName(CTWorksheet.type.getName().getNamespaceURI(), "worksheet"));
        Map map = new HashMap();
        map.put(STRelationshipId.type.getName().getNamespaceURI(), "r");
View Full Code Here

    @Test
    public void createRow() {
        XSSFWorkbook workbook = new XSSFWorkbook();
        XSSFSheet sheet = workbook.createSheet();
        CTWorksheet wsh = sheet.getCTWorksheet();
        CTSheetData sheetData = wsh.getSheetData();
        assertEquals(0, sheetData.sizeOfRowArray());

        XSSFRow row1 = sheet.createRow(2);
        row1.createCell(2);
        row1.createCell(1);

        XSSFRow row2 = sheet.createRow(1);
        row2.createCell(2);
        row2.createCell(1);
        row2.createCell(0);

        XSSFRow row3 = sheet.createRow(0);
        row3.createCell(3);
        row3.createCell(0);
        row3.createCell(2);
        row3.createCell(5);


        List<CTRow> xrow = sheetData.getRowList();
        assertEquals(3, xrow.size());

        //rows are sorted: {0, 1, 2}
        assertEquals(4, xrow.get(0).sizeOfCArray());
        assertEquals(1, xrow.get(0).getR());
        assertTrue(xrow.get(0).equals(row3.getCTRow()));

        assertEquals(3, xrow.get(1).sizeOfCArray());
        assertEquals(2, xrow.get(1).getR());
        assertTrue(xrow.get(1).equals(row2.getCTRow()));

        assertEquals(2, xrow.get(2).sizeOfCArray());
        assertEquals(3, xrow.get(2).getR());
        assertTrue(xrow.get(2).equals(row1.getCTRow()));

        List<CTCell> xcell = xrow.get(0).getCList();
        assertEquals("D1", xcell.get(0).getR());
        assertEquals("A1", xcell.get(1).getR());
        assertEquals("C1", xcell.get(2).getR());
        assertEquals("F1", xcell.get(3).getR());

        //re-creating a row does NOT add extra data to the parent
        row2 = sheet.createRow(1);
        assertEquals(3, sheetData.sizeOfRowArray());
        //existing cells are invalidated
        assertEquals(0, sheetData.getRowArray(1).sizeOfCArray());
        assertEquals(0, row2.getPhysicalNumberOfCells());

        workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
        sheet = workbook.getSheetAt(0);
        wsh = sheet.getCTWorksheet();
        xrow = sheetData.getRowList();
        assertEquals(3, xrow.size());

        //rows are sorted: {0, 1, 2}
        assertEquals(4, xrow.get(0).sizeOfCArray());
        assertEquals(1, xrow.get(0).getR());
View Full Code Here

    @Test
    public void createRow() {
        XSSFWorkbook workbook = new XSSFWorkbook();
        XSSFSheet sheet = workbook.createSheet();
        CTWorksheet wsh = sheet.getCTWorksheet();
        CTSheetData sheetData = wsh.getSheetData();
        assertEquals(0, sheetData.sizeOfRowArray());

        XSSFRow row1 = sheet.createRow(2);
        row1.createCell(2);
        row1.createCell(1);

        XSSFRow row2 = sheet.createRow(1);
        row2.createCell(2);
        row2.createCell(1);
        row2.createCell(0);

        XSSFRow row3 = sheet.createRow(0);
        row3.createCell(3);
        row3.createCell(0);
        row3.createCell(2);
        row3.createCell(5);


        List<CTRow> xrow = sheetData.getRowList();
        assertEquals(3, xrow.size());

        //rows are sorted: {0, 1, 2}
        assertEquals(4, xrow.get(0).sizeOfCArray());
        assertEquals(1, xrow.get(0).getR());
        assertTrue(xrow.get(0).equals(row3.getCTRow()));

        assertEquals(3, xrow.get(1).sizeOfCArray());
        assertEquals(2, xrow.get(1).getR());
        assertTrue(xrow.get(1).equals(row2.getCTRow()));

        assertEquals(2, xrow.get(2).sizeOfCArray());
        assertEquals(3, xrow.get(2).getR());
        assertTrue(xrow.get(2).equals(row1.getCTRow()));

        List<CTCell> xcell = xrow.get(0).getCList();
        assertEquals("D1", xcell.get(0).getR());
        assertEquals("A1", xcell.get(1).getR());
        assertEquals("C1", xcell.get(2).getR());
        assertEquals("F1", xcell.get(3).getR());

        //re-creating a row does NOT add extra data to the parent
        row2 = sheet.createRow(1);
        assertEquals(3, sheetData.sizeOfRowArray());
        //existing cells are invalidated
        assertEquals(0, sheetData.getRowArray(1).sizeOfCArray());
        assertEquals(0, row2.getPhysicalNumberOfCells());

        workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
        sheet = workbook.getSheetAt(0);
        wsh = sheet.getCTWorksheet();
        xrow = sheetData.getRowList();
        assertEquals(3, xrow.size());

        //rows are sorted: {0, 1, 2}
        assertEquals(4, xrow.get(0).sizeOfCArray());
        assertEquals(1, xrow.get(0).getR());
View Full Code Here

                ctHls[i] = hyperlink.getCTHyperlink();
            }
            worksheet.getHyperlinks().setHyperlinkArray(ctHls);
        }

        CTSheetData sheetData = worksheet.getSheetData();
        ArrayList<CTRow> rArray = new ArrayList<CTRow>(rows.size());
        for(XSSFRow row : rows.values()){
            row.onDocumentWrite();
            rArray.add(row.getCTRow());
        }
        sheetData.setRowArray(rArray.toArray(new CTRow[rArray.size()]));

        XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
        xmlOptions.setSaveSyntheticDocumentElement(new QName(CTWorksheet.type.getName().getNamespaceURI(), "worksheet"));
        Map map = new HashMap();
        map.put(STRelationshipId.type.getName().getNamespaceURI(), "r");
View Full Code Here

    /**
     * ensure that the array of CTRow written to CTSheetData is ordered by row index
     */
    private void ensureRowOrdering(){
        CTSheetData sheetData = worksheet.getSheetData();
        // check if row indexes in CTSheetData match the internal model:
        // rows in the internal model (_rows) are always ordered while
        // CTRow beans held by CTSheetData may be not, for example, user can
        // insert rows in random order, shift rows after insertion, etc.
        boolean isOrdered = true;
        if(sheetData.sizeOfRowArray() != _rows.size()) isOrdered = false;
        else {
            int i = 0;
            CTRow[] xrow = sheetData.getRowArray();
            for (XSSFRow row : _rows.values()) {
                CTRow c1 = row.getCTRow();
                CTRow c2 = xrow[i++];
                if (c1.getR() != c2.getR()){
                    isOrdered = false;
                    break;
                }
            }
        }
       
        if(!isOrdered){
            CTRow[] cArray = new CTRow[_rows.size()];
            int i = 0;
            for(XSSFRow row : _rows.values()){
                cArray[i++] = row.getCTRow();
            }
            sheetData.setRowArray(cArray);
        }
    }
View Full Code Here

    /**
     * ensure that the array of CTRow written to CTSheetData is ordered by row index
     */
    private void ensureRowOrdering(){
        CTSheetData sheetData = worksheet.getSheetData();
        // check if row indexes in CTSheetData match the internal model:
        // rows in the internal model (_rows) are always ordered while
        // CTRow beans held by CTSheetData may be not, for example, user can
        // insert rows in random order, shift rows after insertion, etc.
        boolean isOrdered = true;
        if(sheetData.sizeOfRowArray() != _rows.size()) isOrdered = false;
        else {
            int i = 0;
            for (XSSFRow row : _rows.values()) {
                CTRow c1 = row.getCTRow();
                CTRow c2 = sheetData.getRowArray(i++);
                if (c1.getR() != c2.getR()){
                    isOrdered = false;
                    break;
                }
            }
        }
       
        if(!isOrdered){
            CTRow[] cArray = new CTRow[_rows.size()];
            int i = 0;
            for(XSSFRow row : _rows.values()){
                cArray[i++] = row.getCTRow();
            }
            sheetData.setRowArray(cArray);
        }
    }
View Full Code Here

    @SuppressWarnings("deprecation")
    public void createRow() {
        XSSFWorkbook workbook = new XSSFWorkbook();
        XSSFSheet sheet = workbook.createSheet();
        CTWorksheet wsh = sheet.getCTWorksheet();
        CTSheetData sheetData = wsh.getSheetData();
        assertEquals(0, sheetData.sizeOfRowArray());

        XSSFRow row1 = sheet.createRow(2);
        row1.createCell(2);
        row1.createCell(1);

        XSSFRow row2 = sheet.createRow(1);
        row2.createCell(2);
        row2.createCell(1);
        row2.createCell(0);

        XSSFRow row3 = sheet.createRow(0);
        row3.createCell(3);
        row3.createCell(0);
        row3.createCell(2);
        row3.createCell(5);


        CTRow[] xrow = sheetData.getRowArray();
        assertEquals(3, xrow.length);

        //rows are sorted: {0, 1, 2}
        assertEquals(4, xrow[0].sizeOfCArray());
        assertEquals(1, xrow[0].getR());
        assertTrue(xrow[0].equals(row3.getCTRow()));

        assertEquals(3, xrow[1].sizeOfCArray());
        assertEquals(2, xrow[1].getR());
        assertTrue(xrow[1].equals(row2.getCTRow()));

        assertEquals(2, xrow[2].sizeOfCArray());
        assertEquals(3, xrow[2].getR());
        assertTrue(xrow[2].equals(row1.getCTRow()));

        CTCell[] xcell = xrow[0].getCArray();
        assertEquals("D1", xcell[0].getR());
        assertEquals("A1", xcell[1].getR());
        assertEquals("C1", xcell[2].getR());
        assertEquals("F1", xcell[3].getR());

        //re-creating a row does NOT add extra data to the parent
        row2 = sheet.createRow(1);
        assertEquals(3, sheetData.sizeOfRowArray());
        //existing cells are invalidated
        assertEquals(0, sheetData.getRowArray(1).sizeOfCArray());
        assertEquals(0, row2.getPhysicalNumberOfCells());

        workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
        sheet = workbook.getSheetAt(0);
        wsh = sheet.getCTWorksheet();
        xrow = sheetData.getRowArray();
        assertEquals(3, xrow.length);

        //rows are sorted: {0, 1, 2}
        assertEquals(4, xrow[0].sizeOfCArray());
        assertEquals(1, xrow[0].getR());
View Full Code Here

     *
     * @return a new instance
     */
    private static CTWorksheet newSheet(){
        CTWorksheet worksheet = CTWorksheet.Factory.newInstance();
        CTSheetFormatPr ctFormat = worksheet.addNewSheetFormatPr();
        ctFormat.setDefaultRowHeight(15.0);

        CTSheetView ctView = worksheet.addNewSheetViews().addNewSheetView();
        ctView.setWorkbookViewId(0);

        worksheet.addNewDimension().setRef("A1");
View Full Code Here

TOP

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

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.