private short getMaxOutlineLevelRows(){ int outlineLevel = 0; for (XSSFRow xrow : _rows.values()) { outlineLevel = Math.max(outlineLevel, xrow.getCTRow().getOutlineLevel()); } return (short) outlineLevel; }
private int writeHidden(XSSFRow xRow, int rowIndex, boolean hidden) { short level = xRow.getCTRow().getOutlineLevel(); for (Iterator<Row> it = rowIterator(); it.hasNext();) { xRow = (XSSFRow) it.next(); // skip rows before the start of this group if(xRow.getRowNum() < rowIndex) { continue; } if (xRow.getCTRow().getOutlineLevel() >= level) { xRow.getCTRow().setHidden(hidden); rowIndex++; } } return rowIndex; }
/** * @param rowIndex the zero based row index to find from */ private int findStartOfRowOutlineGroup(int rowIndex) { // Find the start of the group. short level = getRow(rowIndex).getCTRow().getOutlineLevel(); int currentRow = rowIndex; while (getRow(currentRow) != null) { if (getRow(currentRow).getCTRow().getOutlineLevel() < level) { return currentRow + 1; } currentRow--; } return currentRow; }
/** * @param row the zero based row index to find from */ public int findEndOfRowOutlineGroup(int row) { short level = getRow(row).getCTRow().getOutlineLevel(); int currentRow; final int lastRowNum = getLastRowNum(); for (currentRow = row; currentRow < lastRowNum; currentRow++) { if (getRow(currentRow) == null || getRow(currentRow).getCTRow().getOutlineLevel() < level) { break; } } return currentRow; }
/** * @param row the zero based row index to find from */ private boolean isRowGroupCollapsed(int row) { int collapseRow = findEndOfRowOutlineGroup(row) + 1; if (getRow(collapseRow) == null) { return false; } return getRow(collapseRow).getCTRow().getCollapsed(); }
endHidden = false; } else { endLevel = getRow(endOfOutlineGroupIdx).getCTRow().getOutlineLevel(); endHidden = getRow(endOfOutlineGroupIdx).getCTRow().getHidden(); startHidden = false; } else { startLevel = getRow(startOfOutlineGroupIdx).getCTRow() .getOutlineLevel(); startHidden = getRow(startOfOutlineGroupIdx).getCTRow() .getHidden();
/** * @param rowIndex the zero based row index to collapse */ private void collapseRow(int rowIndex) { XSSFRow row = getRow(rowIndex); if (row != null) { int startRow = findStartOfRowOutlineGroup(rowIndex); // Hide all the columns until the end of the group int lastRow = writeHidden(row, startRow, true); if (getRow(lastRow) != null) { getRow(lastRow).getCTRow().setCollapsed(true); } else { XSSFRow newRow = createRow(lastRow); newRow.getCTRow().setCollapsed(true); } } }
if (!row.getCTRow().isSetHidden()) { return; short level = row.getCTRow().getOutlineLevel(); if (!isRowGroupHiddenByParent(rowNumber)) { for (int i = startIdx; i < endIdx; i++) { if (level == getRow(i).getCTRow().getOutlineLevel()) { getRow(i).getCTRow().unsetHidden(); } else if (!isRowGroupCollapsed(i)) { getRow(i).getCTRow().unsetHidden(); CTRow ctRow = getRow(endIdx).getCTRow();
ctRow = prev.getCTRow(); ctRow.set(CTRow.Factory.newInstance()); } else {
/** * Tie a range of cell together so that they can be collapsed or expanded * * @param fromRow start row (0-based) * @param toRow end row (0-based) */ @Override public void groupRow(int fromRow, int toRow) { for (int i = fromRow; i <= toRow; i++) { XSSFRow xrow = getRow(i); if (xrow == null) { xrow = createRow(i); } CTRow ctrow = xrow.getCTRow(); short outlineLevel = ctrow.getOutlineLevel(); ctrow.setOutlineLevel((short) (outlineLevel + 1)); } setSheetFormatPrOutlineLevelRow(); }
/** * Ungroup a range of rows that were previously groupped * * @param fromRow start row (0-based) * @param toRow end row (0-based) */ @Override public void ungroupRow(int fromRow, int toRow) { for (int i = fromRow; i <= toRow; i++) { XSSFRow xrow = getRow(i); if (xrow != null) { CTRow ctRow = xrow.getCTRow(); int outlineLevel = ctRow.getOutlineLevel(); ctRow.setOutlineLevel((short) (outlineLevel - 1)); //remove a row only if the row has no cell and if the outline level is 0 if (outlineLevel == 1 && xrow.getFirstCellNum() == -1) { removeRow(xrow); } } } setSheetFormatPrOutlineLevelRow(); }
DataFormatter formatter = new DataFormatter(); if (row != null && row.getCTRow().validate()) { int cellnum = firstHeaderColumn; CTTableColumns ctTableColumns = getCTTable().getTableColumns();
private short getMaxOutlineLevelRows(){ int outlineLevel = 0; for (XSSFRow xrow : _rows.values()) { outlineLevel = Math.max(outlineLevel, xrow.getCTRow().getOutlineLevel()); } return (short) outlineLevel; }
private int writeHidden(XSSFRow xRow, int rowIndex, boolean hidden) { int level = xRow.getCTRow().getOutlineLevel(); for (Iterator<Row> it = rowIterator(); it.hasNext();) { xRow = (XSSFRow) it.next(); if (xRow.getCTRow().getOutlineLevel() >= level) { xRow.getCTRow().setHidden(hidden); rowIndex++; } } return rowIndex; }
private int writeHidden(XSSFRow xRow, int rowIndex, boolean hidden) { short level = xRow.getCTRow().getOutlineLevel(); for (Iterator<Row> it = rowIterator(); it.hasNext();) { xRow = (XSSFRow) it.next(); // skip rows before the start of this group if(xRow.getRowNum() < rowIndex) { continue; } if (xRow.getCTRow().getOutlineLevel() >= level) { xRow.getCTRow().setHidden(hidden); rowIndex++; } } return rowIndex; }
/** * @param rowIndex the zero based row index to find from */ private int findStartOfRowOutlineGroup(int rowIndex) { // Find the start of the group. short level = getRow(rowIndex).getCTRow().getOutlineLevel(); int currentRow = rowIndex; while (getRow(currentRow) != null) { if (getRow(currentRow).getCTRow().getOutlineLevel() < level) { return currentRow + 1; } currentRow--; } return currentRow; }
/** * @param rowIndex the zero based row index to find from */ private int findStartOfRowOutlineGroup(int rowIndex) { // Find the start of the group. int level = getRow(rowIndex).getCTRow().getOutlineLevel(); int currentRow = rowIndex; while (getRow(currentRow) != null) { if (getRow(currentRow).getCTRow().getOutlineLevel() < level) return currentRow + 1; currentRow--; } return currentRow; }
/** * @param row the zero based row index to find from */ private boolean isRowGroupCollapsed(int row) { int collapseRow = findEndOfRowOutlineGroup(row) + 1; if (getRow(collapseRow) == null) { return false; } return getRow(collapseRow).getCTRow().getCollapsed(); }
/** * @param row the zero based row index to find from */ private boolean isRowGroupCollapsed(int row) { int collapseRow = findEndOfRowOutlineGroup(row) + 1; if (getRow(collapseRow) == null) { return false; } return getRow(collapseRow).getCTRow().getCollapsed(); }