Examples of CTCol


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

        // Look out outline details of end
        int endLevel = 0;
        boolean endHidden = false;
        int endOfOutlineGroupIdx = findEndOfColumnOutlineGroup(idx);
        if (endOfOutlineGroupIdx < cols.sizeOfColArray()) {
            CTCol nextInfo = cols.getColArray(endOfOutlineGroupIdx + 1);
            if (isAdjacentBefore(cols.getColArray(endOfOutlineGroupIdx),
                    nextInfo)) {
                endLevel = nextInfo.getOutlineLevel();
                endHidden = nextInfo.getHidden();
            }
        }
        // Look out outline details of start
        int startLevel = 0;
        boolean startHidden = false;
        int startOfOutlineGroupIdx = findStartOfColumnOutlineGroup(idx);
        if (startOfOutlineGroupIdx > 0) {
            CTCol prevInfo = cols.getColArray(startOfOutlineGroupIdx - 1);

            if (isAdjacentBefore(prevInfo, cols
                    .getColArray(startOfOutlineGroupIdx))) {
                startLevel = prevInfo.getOutlineLevel();
                startHidden = prevInfo.getHidden();
            }

        }
        if (endLevel > startLevel) {
            return endHidden;
View Full Code Here

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

            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;
            }

            if (ci.getMin() > fromColInfoIdx) {
                break;
            }

        }
        return -1;
View Full Code Here

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

        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

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

    }

    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));
                index = (int) col.getMax();

                if (col.getOutlineLevel() <= 0) {
                    int colIndex = columnHelper.getIndexOfColumn(cols, col);
                    worksheet.getColsArray(0).removeCol(colIndex);
                }
            }
        }
View Full Code Here

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

     *
     * @param columnIndex - the column to set (0-based)
     * @return width - the width in units of 1/256th of a character width
     */
    public int getColumnWidth(int columnIndex) {
        CTCol col = columnHelper.getColumn(columnIndex, false);
        double width = col == null || !col.isSetWidth() ? getDefaultColumnWidth() : col.getWidth();
        return (int)(width*256);
    }
View Full Code Here

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

    public void groupColumn(int fromColumn, int toColumn) {
        groupColumn1Based(fromColumn+1, toColumn+1);
    }
    private void groupColumn1Based(int fromColumn, int toColumn) {
        CTCols ctCols=worksheet.getColsArray(0);
        CTCol ctCol=CTCol.Factory.newInstance();
        ctCol.setMin(fromColumn);
        ctCol.setMax(toColumn);
        this.columnHelper.addCleanColIntoCols(ctCols, ctCol);
        for(int index=fromColumn;index<=toColumn;index++){
            CTCol col=columnHelper.getColumn1Based(index, false);
            //col must exist
            short outlineLevel=col.getOutlineLevel();
            col.setOutlineLevel((short)(outlineLevel+1));
            index=(int)col.getMax();
        }
        worksheet.setColsArray(0,ctCols);
        setSheetFormatPrOutlineLevelCol();
    }
View Full Code Here

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

      }
    }

    private void collapseColumn(int columnNumber) {
      CTCols cols = worksheet.getColsArray(0);
      CTCol col = columnHelper.getColumn(columnNumber, false);
      int colInfoIx = columnHelper.getIndexOfColumn(cols, col);
      if (colInfoIx == -1) {
        return;
      }
      // Find the start of the group.
      int groupStartColInfoIx = findStartOfColumnOutlineGroup(colInfoIx);

      CTCol columnInfo = cols.getColArray(groupStartColInfoIx);

      // Hide all the columns until the end of the group
      int lastColMax = setGroupHidden(groupStartColInfoIx, columnInfo
          .getOutlineLevel(), true);

      // write collapse field
      setColumn((int) (lastColMax + 1), null, 0, null, null, Boolean.TRUE);
View Full Code Here

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

    }

    private void setColumn(int targetColumnIx, Short xfIndex, Integer style,
        Integer level, Boolean hidden, Boolean collapsed) {
      CTCols cols = worksheet.getColsArray(0);
      CTCol ci = null;
      int k = 0;
      for (k = 0; k < cols.sizeOfColArray(); k++) {
        CTCol tci = cols.getColArray(k);
        if (tci.getMin() >= targetColumnIx
            && tci.getMax() <= targetColumnIx) {
          ci = tci;
          break;
        }
        if (tci.getMin() > targetColumnIx) {
          // call column infos after k are for later columns
          break; // exit now so k will be the correct insert pos
        }
      }

      if (ci == null) {
        // okay so there ISN'T a column info record that covers this column
        // so lets create one!
        CTCol nci = CTCol.Factory.newInstance();
        nci.setMin(targetColumnIx);
        nci.setMax(targetColumnIx);
        unsetCollapsed(collapsed, nci);
        this.columnHelper.addCleanColIntoCols(cols, nci);
        return;
      }

      boolean styleChanged = style != null
      && ci.getStyle() != style.intValue();
      boolean levelChanged = level != null
      && ci.getOutlineLevel() != level.intValue();
      boolean hiddenChanged = hidden != null
      && ci.getHidden() != hidden.booleanValue();
      boolean collapsedChanged = collapsed != null
      && ci.getCollapsed() != collapsed.booleanValue();
      boolean columnChanged = levelChanged || hiddenChanged
      || collapsedChanged || styleChanged;
      if (!columnChanged) {
        // do nothing...nothing changed.
        return;
      }

      if (ci.getMin() == targetColumnIx && ci.getMax() == targetColumnIx) {
        // ColumnInfo ci for a single column, the target column
        unsetCollapsed(collapsed, ci);
        return;
      }

      if (ci.getMin() == targetColumnIx || ci.getMax() == targetColumnIx) {
        // The target column is at either end of the multi-column ColumnInfo
        // ci
        // we'll just divide the info and create a new one
        if (ci.getMin() == targetColumnIx) {
          ci.setMin(targetColumnIx + 1);
        } else {
          ci.setMax(targetColumnIx - 1);
          k++; // adjust insert pos to insert after
        }
        CTCol nci = columnHelper.cloneCol(cols, ci);
        nci.setMin(targetColumnIx);
        unsetCollapsed(collapsed, nci);
        this.columnHelper.addCleanColIntoCols(cols, nci);

      } else {
        // split to 3 records
        CTCol ciStart = ci;
        CTCol ciMid = columnHelper.cloneCol(cols, ci);
        CTCol ciEnd = columnHelper.cloneCol(cols, ci);
        int lastcolumn = (int) ci.getMax();

        ciStart.setMax(targetColumnIx - 1);

        ciMid.setMin(targetColumnIx);
        ciMid.setMax(targetColumnIx);
        unsetCollapsed(collapsed, ciMid);
        this.columnHelper.addCleanColIntoCols(cols, ciMid);

        ciEnd.setMin(targetColumnIx + 1);
        ciEnd.setMax(lastcolumn);
        this.columnHelper.addCleanColIntoCols(cols, ciEnd);
      }
    }
View Full Code Here

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

     * @return the column index of the last column in the outline group
     */
    private int setGroupHidden(int pIdx, int level, boolean hidden) {
      CTCols cols = worksheet.getColsArray(0);
      int idx = pIdx;
      CTCol columnInfo = cols.getColArray(idx);
      while (idx < cols.sizeOfColArray()) {
        columnInfo.setHidden(hidden);
        if (idx + 1 < cols.sizeOfColArray()) {
          CTCol nextColumnInfo = cols.getColArray(idx + 1);

          if (!isAdjacentBefore(columnInfo, nextColumnInfo)) {
            break;
          }

          if (nextColumnInfo.getOutlineLevel() < level) {
            break;
          }
          columnInfo = nextColumnInfo;
        }
        idx++;
View Full Code Here

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

    }

    private int findStartOfColumnOutlineGroup(int pIdx) {
      // Find the start of the group.
      CTCols cols = worksheet.getColsArray(0);
      CTCol columnInfo = cols.getColArray(pIdx);
      int level = columnInfo.getOutlineLevel();
      int idx = pIdx;
      while (idx != 0) {
        CTCol prevColumnInfo = cols.getColArray(idx - 1);
        if (!isAdjacentBefore(prevColumnInfo, columnInfo)) {
          break;
        }
        if (prevColumnInfo.getOutlineLevel() < level) {
          break;
        }
        idx--;
        columnInfo = prevColumnInfo;
      }
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.