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

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


        }
        return startHidden;
    }

    private int findColInfoIdx(int columnValue, int fromColInfoIdx) {
        CTCols cols = worksheet.getColsArray(0);

        if (columnValue < 0) {
            throw new IllegalArgumentException(
                    "column parameter out of range: " + columnValue);
        }
        if (fromColInfoIdx < 0) {
            throw new IllegalArgumentException(
                    "fromIdx parameter out of range: " + fromColInfoIdx);
        }

        for (int k = fromColInfoIdx; k < cols.sizeOfColArray(); k++) {
            CTCol ci = cols.getColArray(k);

            if (containsColumn(ci, columnValue)) {
                return k;
            }
View Full Code Here


     *
     * @param idx
     * @return a boolean represented if the column is collapsed
     */
    private boolean isColumnGroupCollapsed(int idx) {
        CTCols cols = worksheet.getColsArray(0);
        int endOfOutlineGroupIdx = findEndOfColumnOutlineGroup(idx);
        int nextColInfoIx = endOfOutlineGroupIdx + 1;
        if (nextColInfoIx >= cols.sizeOfColArray()) {
            return false;
        }
        CTCol nextColInfo = cols.getColArray(nextColInfoIx);

        CTCol col = cols.getColArray(endOfOutlineGroupIdx);
        if (!isAdjacentBefore(col, nextColInfo)) {
            return false;
        }

        return nextColInfo.getCollapsed();
View Full Code Here

        String cellRef = cellReference.formatAsString();
        getPane().setTopLeftCell(cellRef);
    }

    public void ungroupColumn(int fromColumn, int toColumn) {
        CTCols cols = worksheet.getColsArray(0);
        for (int index = fromColumn; index <= toColumn; index++) {
            CTCol col = columnHelper.getColumn(index, false);
            if (col != null) {
                short outlineLevel = col.getOutlineLevel();
                col.setOutlineLevel((short) (outlineLevel - 1));
View Full Code Here

    }

    protected void write(OutputStream out) throws IOException {

        if(worksheet.sizeOfColsArray() == 1) {
            CTCols col = worksheet.getColsArray(0);
            if(col.sizeOfColArray() == 0) {
                worksheet.setColsArray(null);
            }
        }

        // Now re-generate our CTHyperlinks, if needed
View Full Code Here

       pinkStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
       assertEquals(2, pinkStyle.getIndex());

       // Starts empty
       assertEquals(1, s.getCTWorksheet().sizeOfColsArray());
       CTCols cols = s.getCTWorksheet().getColsArray(0);
       assertEquals(0, cols.sizeOfColArray());
      
       // Add some rows and columns
       XSSFRow r1 = s.createRow(0);
       XSSFRow r2 = s.createRow(1);
       r1.createCell(0);
       r1.createCell(2);
       r2.createCell(0);
       r2.createCell(3);
      
       // Check no style is there
       assertEquals(1, s.getCTWorksheet().sizeOfColsArray());
       assertEquals(0, cols.sizeOfColArray());
      
       assertEquals(defaultStyle, s.getColumnStyle(0));
       assertEquals(defaultStyle, s.getColumnStyle(2));
       assertEquals(defaultStyle, s.getColumnStyle(3));
      
      
       // Apply the styles
       s.setDefaultColumnStyle(0, pinkStyle);
       s.setDefaultColumnStyle(3, blueStyle);
      
       // Check
       assertEquals(pinkStyle, s.getColumnStyle(0));
       assertEquals(defaultStyle, s.getColumnStyle(2));
       assertEquals(blueStyle, s.getColumnStyle(3));
      
       assertEquals(1, s.getCTWorksheet().sizeOfColsArray());
       assertEquals(2, cols.sizeOfColArray());
      
       assertEquals(1, cols.getColArray(0).getMin());
       assertEquals(1, cols.getColArray(0).getMax());
       assertEquals(pinkStyle.getIndex(), cols.getColArray(0).getStyle());
      
       assertEquals(4, cols.getColArray(1).getMin());
       assertEquals(4, cols.getColArray(1).getMax());
       assertEquals(blueStyle.getIndex(), cols.getColArray(1).getStyle());
      
      
       // Save, re-load and re-check
       wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
       s = wb.getSheetAt(0);
View Full Code Here

        sheet.groupColumn((short) 9, (short) 12);
       
        wb = XSSFTestDataSamples.writeOutAndReadBack(wb, "testNoColsWithoutWidthWhenGrouping");
        sheet = wb.getSheet("test");
       
        CTCols cols = sheet.getCTWorksheet().getColsArray(0);
        logger.log(POILogger.DEBUG, "test52186/cols:" + cols);
        for (CTCol col : cols.getColList()) {
      assertTrue("Col width attribute is unset: " + col.toString(), col.isSetWidth());
    }
    }
View Full Code Here

      
        sheet.groupColumn((short) 4, (short) 5);
       
        sheet.setColumnGroupCollapsed(4, true);
       
        CTCols cols = sheet.getCTWorksheet().getColsArray(0);
        logger.log(POILogger.DEBUG, "test52186_2/cols:" + cols);

        wb = XSSFTestDataSamples.writeOutAndReadBack(wb, "testNoColsWithoutWidthWhenGroupingAndCollapsing");
        sheet = wb.getSheet("test");
       
        for (int i = 4; i <= 5; i++) {
          assertEquals("Unexpected width of column "+ i, 5000, sheet.getColumnWidth(i));
        }
        cols = sheet.getCTWorksheet().getColsArray(0);
        for (CTCol col : cols.getColList()) {
      assertTrue("Col width attribute is unset: " + col.toString(), col.isSetWidth());
    }
    }
View Full Code Here

     */
    public void testMergingOverlappingCols_OVERLAPS_2_WRAPS() {
    XSSFWorkbook wb = new XSSFWorkbook();
    XSSFSheet sheet = wb.createSheet("test");

        CTCols cols = sheet.getCTWorksheet().getColsArray(0);
        CTCol col = cols.addNewCol();
        col.setMin(1 + 1);
        col.setMax(4 + 1);
        col.setWidth(20);
        col.setCustomWidth(true);

        sheet.groupColumn((short) 2, (short) 3);
       
        sheet.getCTWorksheet().getColsArray(0);
        logger.log(POILogger.DEBUG, "testMergingOverlappingCols_OVERLAPS_2_WRAPS/cols:" + cols);
       
        assertEquals(0, cols.getColArray(0).getOutlineLevel());
        assertEquals(2, cols.getColArray(0).getMin()); // 1 based
        assertEquals(2, cols.getColArray(0).getMax()); // 1 based
        assertEquals(true, cols.getColArray(0).getCustomWidth());

        assertEquals(1, cols.getColArray(1).getOutlineLevel());
        assertEquals(3, cols.getColArray(1).getMin()); // 1 based
        assertEquals(4, cols.getColArray(1).getMax()); // 1 based       
        assertEquals(true, cols.getColArray(1).getCustomWidth());

        assertEquals(0, cols.getColArray(2).getOutlineLevel());
        assertEquals(5, cols.getColArray(2).getMin()); // 1 based
        assertEquals(5, cols.getColArray(2).getMax()); // 1 based
        assertEquals(true, cols.getColArray(2).getCustomWidth());
       
        assertEquals(3, cols.sizeOfColArray());

        wb = XSSFTestDataSamples.writeOutAndReadBack(wb, "testMergingOverlappingCols_OVERLAPS_2_WRAPS");
        sheet = wb.getSheet("test");
       
        for (int i = 1; i <= 4; i++) {
View Full Code Here

     */
    public void testMergingOverlappingCols_OVERLAPS_1_WRAPS() {
    XSSFWorkbook wb = new XSSFWorkbook();
    XSSFSheet sheet = wb.createSheet("test");

        CTCols cols = sheet.getCTWorksheet().getColsArray(0);
        CTCol col = cols.addNewCol();
        col.setMin(2 + 1);
        col.setMax(4 + 1);
        col.setWidth(20);
        col.setCustomWidth(true);

        sheet.groupColumn((short) 1, (short) 5);
       
        cols = sheet.getCTWorksheet().getColsArray(0);
        logger.log(POILogger.DEBUG, "testMergingOverlappingCols_OVERLAPS_1_WRAPS/cols:" + cols);
       
        assertEquals(1, cols.getColArray(0).getOutlineLevel());
        assertEquals(2, cols.getColArray(0).getMin()); // 1 based
        assertEquals(2, cols.getColArray(0).getMax()); // 1 based
        assertEquals(false, cols.getColArray(0).getCustomWidth());

        assertEquals(1, cols.getColArray(1).getOutlineLevel());
        assertEquals(3, cols.getColArray(1).getMin()); // 1 based
        assertEquals(5, cols.getColArray(1).getMax()); // 1 based       
        assertEquals(true, cols.getColArray(1).getCustomWidth());

        assertEquals(1, cols.getColArray(2).getOutlineLevel());
        assertEquals(6, cols.getColArray(2).getMin()); // 1 based
        assertEquals(6, cols.getColArray(2).getMax()); // 1 based
        assertEquals(false, cols.getColArray(2).getCustomWidth());
       
        assertEquals(3, cols.sizeOfColArray());
       
        wb = XSSFTestDataSamples.writeOutAndReadBack(wb, "testMergingOverlappingCols_OVERLAPS_1_WRAPS");
        sheet = wb.getSheet("test");
       
        for (int i = 2; i <= 4; i++) {
View Full Code Here

     */
    public void testMergingOverlappingCols_OVERLAPS_1_MINOR() {
    XSSFWorkbook wb = new XSSFWorkbook();
    XSSFSheet sheet = wb.createSheet("test");

        CTCols cols = sheet.getCTWorksheet().getColsArray(0);
        CTCol col = cols.addNewCol();
        col.setMin(2 + 1);
        col.setMax(4 + 1);
        col.setWidth(20);
        col.setCustomWidth(true);

        sheet.groupColumn((short) 3, (short) 5);
       
        cols = sheet.getCTWorksheet().getColsArray(0);
        logger.log(POILogger.DEBUG, "testMergingOverlappingCols_OVERLAPS_1_MINOR/cols:" + cols);

        assertEquals(0, cols.getColArray(0).getOutlineLevel());
        assertEquals(3, cols.getColArray(0).getMin()); // 1 based
        assertEquals(3, cols.getColArray(0).getMax()); // 1 based
        assertEquals(true, cols.getColArray(0).getCustomWidth());

        assertEquals(1, cols.getColArray(1).getOutlineLevel());
        assertEquals(4, cols.getColArray(1).getMin()); // 1 based
        assertEquals(5, cols.getColArray(1).getMax()); // 1 based       
        assertEquals(true, cols.getColArray(1).getCustomWidth());

        assertEquals(1, cols.getColArray(2).getOutlineLevel());
        assertEquals(6, cols.getColArray(2).getMin()); // 1 based
        assertEquals(6, cols.getColArray(2).getMax()); // 1 based
        assertEquals(false, cols.getColArray(2).getCustomWidth());
       
        assertEquals(3, cols.sizeOfColArray());
       
        wb = XSSFTestDataSamples.writeOutAndReadBack(wb, "testMergingOverlappingCols_OVERLAPS_1_MINOR");
        sheet = wb.getSheet("test");
       
        for (int i = 2; i <= 4; i++) {
View Full Code Here

TOP

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

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.