Package org.zkoss.poi.ss.usermodel

Examples of org.zkoss.poi.ss.usermodel.Row


  }
 
  public static Set<Ref> setRowsHidden(Worksheet sheet, int tRow, int bRow, boolean hidden) {
    if (hidden) {
      for(int r = tRow; r <= bRow; ++r) {
        final Row row = BookHelper.getOrCreateRow(sheet, r);
        row.setZeroHeight(true);
      }
    } else {
      for(int r = tRow; r <= bRow; ++r) {
        final Row row = sheet.getRow(r);
        if (row != null) {
          row.setZeroHeight(false);
        }
      }
    }
    final Book book = (Book) sheet.getWorkbook();
    final RefSheet refSheet = BookHelper.getRefSheet(book, sheet);
View Full Code Here


    }
  }

  private void updateRowHeight(Worksheet sheet, int row) {
    final int height = Utils.getRowHeightInPx(sheet, row);
    final Row rowobj = sheet.getRow(row);
    final boolean newHidden = rowobj == null ? false : rowobj.getZeroHeight();
    HeaderPositionHelper posHelper = getRowPositionHelper(sheet);
    HeaderPositionInfo info = posHelper.getInfo(row);
    if ((info == null && (height != posHelper.getDefaultSize() || newHidden)) || (info != null && (info.size != height || info.hidden != newHidden))) {
      int id = info == null ? _custRowId.next() : info.id;
      posHelper.setInfoValues(row, height, id, newHidden);
View Full Code Here

    //locate the model book and sheet of the refSheet
    final Book book = BookHelper.getBook(_sheet, refSheet);
    if (book != null) {
      final Worksheet sheet = book.getWorksheet(refSheet.getSheetName());
      if (sheet != null) {
        final Row row = sheet.getRow(rowIndex);
        if (row != null) {
          return row.getCell(colIndex);
        }
      }
    }
    return null;
  }
View Full Code Here

  private Cell getOrCreateCell(int rowIndex, int colIndex, RefSheet refSheet, int cellType) {
    //locate the model book and sheet of the refSheet
    final Book book = BookHelper.getBook(_sheet, refSheet);
    final String sheetname = refSheet.getSheetName();
    final Worksheet sheet = getOrCreateSheet(book, sheetname);
    final Row row = getOrCreateRow(sheet, rowIndex);
    return getOrCreateCell(row, colIndex, cellType);
  }
View Full Code Here

    }
    return sheet;
  }
 
  private Row getOrCreateRow(Worksheet sheet, int rowIndex) {
    Row row = sheet.getRow(rowIndex);
    if (row == null) {
      row = sheet.createRow(rowIndex);
    }
    return row;
  }
View Full Code Here

       
        //ZSS-22: Shall not allow Copy and Paste operation in a protected spreadsheet
        final Worksheet sheet = BookHelper.getSheet(_sheet, refSheet);
        if (sheet.getProtect()) {
          for (int r = top; r <= bottom; ++r) {
            final Row row = sheet.getRow(r);
            if (row != null) {
              for (int c = left; c <= right; ++c) {
                final Cell cell = row.getCell(c);
                if (cell != null) {
                  final CellStyle cs = cell.getCellStyle();
                  if (cs != null && cs.getLocked()) {
                    //as long as one is protected and locked, return true
                    return true;
View Full Code Here

    int t = sheet.getFirstRowNum();
    int b = sheet.getLastRowNum();
    //top row
    int minr = -1;
    for(int r = t; r <= b && minr < 0; ++r) {
      final Row rowobj = sheet.getRow(r);
      if (rowobj != null) {
        int ll = rowobj.getFirstCellNum();
        if (ll < 0) { //empty row
          continue;
        }
        int rr = rowobj.getLastCellNum() - 1;
        for(int c = ll; c <= rr; ++c) {
          final Cell cell = rowobj.getCell(c);
          if (!BookHelper.isBlankCell(cell)) { //first no blank row
            minr = r;
            break;
          }
        }
      }
    }
    //bottom row
    int maxr = -1;
    for(int r = b; r >= minr && maxr < 0; --r) {
      final Row rowobj = sheet.getRow(r);
      if (rowobj != null) {
        int ll = rowobj.getFirstCellNum();
        if (ll < 0) { //empty row
          continue;
        }
        int rr = rowobj.getLastCellNum() - 1;
        for(int c = ll; c <= rr; ++c) {
          final Cell cell = rowobj.getCell(c);
          if (!BookHelper.isBlankCell(cell)) { //first no blank row
            maxr = r;
            break;
          }
        }
      }
    }
    //left col
    int minc = Integer.MAX_VALUE;
    for(int r = minr; r <= maxr; ++r) {
      final Row rowobj = sheet.getRow(r);
      if (rowobj != null) {
        int ll = rowobj.getFirstCellNum();
        if (ll < 0) { //empty row
          continue;
        }
        int rr = rowobj.getLastCellNum() - 1;
        for(int c = ll; c < minc && c <= rr; ++c) {
          final Cell cell = rowobj.getCell(c);
          if (!BookHelper.isBlankCell(cell)) { //first no blank row
            minc = c;
            break;
          }
        }
      }
    }
    //right col
    int maxc = -1;
    for(int r = minr; r <= maxr; ++r) {
      final Row rowobj = sheet.getRow(r);
      if (rowobj != null) {
        int ll = rowobj.getFirstCellNum();
        if (ll < 0) { //empty row
          continue;
        }
        int rr = rowobj.getLastCellNum() - 1;
        for(int c = rr; c > maxc && c >= ll; --c) {
          final Cell cell = rowobj.getCell(c);
          if (!BookHelper.isBlankCell(cell)) { //first no blank row
            maxc = c;
            break;
          }
        }
View Full Code Here

  private CellRangeAddress getRowCurrentRegion(Worksheet sheet, int topRow, int btmRow) {
    int minc = 0;
    int maxc = 0;
    int minr = topRow;
    int maxr = btmRow;
    final Row roworg = sheet.getRow(topRow);
    for (int c = minc; c <= roworg.getLastCellNum(); c++) {
      boolean foundMax = false;
      for (int r = minr + 1; r <= sheet.getLastRowNum(); r++) {
        int[] cellMinMax = getCellMinMax(sheet, r, c);
        if (cellMinMax == null && r >= btmRow) {
          break;
View Full Code Here

  private CellRangeAddress getCurrentRegion(Worksheet sheet, int row, int col) {
    int minc = col;
    int maxc = col;
    int minr = Integer.MAX_VALUE;
    int maxr = -1;
    final Row roworg = sheet.getRow(row);
    final int[] ltrb = getRowMinMax(sheet, roworg, minc, maxc);
    if (ltrb != null) {
      minc = ltrb[0];
      minr = ltrb[1];
      maxc = ltrb[2];
      maxr = ltrb[3];
    }
   
    int ru = row > 0 ? row - 1 : row;
    int rd = row + 1;
   
    boolean stopu = ru == row;
    boolean stopd = false;
    do {
      //for row above
      if (!stopu) {
        final Row rowu = sheet.getRow(ru);
        final int[] ltrbu = getRowMinMax(sheet, rowu, minc, maxc);
        if (ltrbu != null) {
          if (minc != ltrbu[0] || maxc != ltrbu[2]) {  //minc or maxc changed!
            stopd = false;
            minc = ltrbu[0];
            maxc = ltrbu[2];
          }
          if (minr > ltrbu[1]) {
            minr = ltrbu[1];
          }
          if (ru > 0) {
            --ru;
          } else {
            stopu = true; //no more row above!
          }
        } else { //blank row
          stopu = true;
        }
      }

      //for row below
      if (!stopd) {
        final Row rowd = sheet.getRow(rd);
        final int[] ltrbd = getRowMinMax(sheet, rowd, minc, maxc);
        if (ltrbd != null) {
          if (minc != ltrbd[0] || maxc != ltrbd[2]) { //minc and maxc changed
            stopu = false;
            minc = ltrbd[0];
View Full Code Here

      final int row2 = afrng.getLastRow();
      final int col1 = afrng.getFirstColumn();
      final int col2 = afrng.getLastColumn();
      final Set<Ref> all = new HashSet<Ref>();
      for (int r = row; r <= row2; ++r) {
        final Row rowobj = _sheet.getRow(r);
        if (rowobj != null && rowobj.getZeroHeight()) { //a hidden row
          final int left = rowobj.getFirstCellNum();
          final int right = rowobj.getLastCellNum() - 1;
          final RangeImpl rng = (RangeImpl) new RangeImpl(r, left, r, right, _sheet, _sheet);
          all.addAll(rng.getRefs());
          rng.getRows().setHidden(false); //unhide
        }
      }
View Full Code Here

TOP

Related Classes of org.zkoss.poi.ss.usermodel.Row

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.