Package org.zkoss.poi.ss.usermodel

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


      final Worksheet sheet = BookHelper.getSheet(_sheet, refSheet);
      final Workbook book = sheet.getWorkbook();
     
      for(int row = tRow; row <= bRow; ++row) {
        for (int col = lCol; col <= rCol; ++col) {
          final Cell cell = BookHelper.getCell(sheet, row, col);
          final CellStyle style = cell != null ? cell.getCellStyle() : null;
          final String oldFormat = style != null ? style.getDataFormatString() : null;
          if (oldFormat == null || "General".equals(oldFormat)) {
            CellStyle newCellStyle = book.createCellStyle();
            if (style != null) {
              newCellStyle.cloneStyleFrom(style);
View Full Code Here


    }
    return row;
  }
 
  private Cell getOrCreateCell(Row row, int colIndex, int type) {
    Cell cell = row.getCell(colIndex);
    if (cell == null) {
      cell = row.createCell(colIndex, type);
    }
    return cell;
  }
View Full Code Here

        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

      for(int rr = rowRepeat; rr > 0; --rr) {
        for(int srcRow = tRow; srcRow <= bRow; ++srcRow, ++dstRow) {
          int dstCol= dstRef.getLeftCol();
          for (int cr = colRepeat; cr > 0; --cr) {
            for (int srcCol = lCol; srcCol <= rCol; ++srcCol, ++dstCol) {
              final Cell cell = BookHelper.getCell(srcSheet, srcRow, srcCol);
              if (cell != null) {
                if (!skipBlanks || cell.getCellType() != Cell.CELL_TYPE_BLANK) {
                  final ChangeInfo changeInfo0 = BookHelper.copyCell(cell, dstSheet, dstRow, dstCol, pasteType, pasteOp, transpose);
                  BookHelper.assignChangeInfo(toEval, affected, mergeChanges, changeInfo0);
                }
              } else if (!skipBlanks) {
                final Set<Ref>[] refs = BookHelper.removeCell(dstSheet, dstRow, dstCol);
                BookHelper.assignRefs(toEval, affected, refs);
              }
            }
          }
        }
      }
    } else { //row -> column, column -> row
      int dstCol = dstRef.getLeftCol();
      for(int rr = rowRepeat; rr > 0; --rr) {
        for(int srcRow = tRow; srcRow <= bRow; ++srcRow, ++dstCol) {
          int dstRow = dstRef.getTopRow();
          for (int cr = colRepeat; cr > 0; --cr) {
            for (int srcCol = lCol; srcCol <= rCol; ++srcCol, ++dstRow) {
              final Cell cell = BookHelper.getCell(srcSheet, srcRow, srcCol);
              if (cell != null) {
                if (!skipBlanks || cell.getCellType() != Cell.CELL_TYPE_BLANK) {
                  final ChangeInfo changeInfo0 = BookHelper.copyCell(cell, dstSheet, dstRow, dstCol, pasteType, pasteOp, transpose);
                  BookHelper.assignChangeInfo(toEval, affected, mergeChanges, changeInfo0);
                }
              } else if (!skipBlanks) {
                final Set<Ref>[] refs = BookHelper.removeCell(dstSheet, dstRow, dstCol);
View Full Code Here

      Ref ref = _refs != null && !_refs.isEmpty() ? _refs.iterator().next() : null;
      if (ref != null) {
        final int tRow = ref.getTopRow();
        final int lCol = ref.getLeftCol();
        final RefSheet refSheet = ref.getOwnerSheet();
        final Cell cell = getCell(tRow, lCol, refSheet);
        if (cell != null) {
          return getValue0(cell);
        }
      }
      return null;
View Full Code Here

        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

    final CellRangeAddress rng = BookHelper.getMergeRegion(sheet, row, col);
    final int t = rng.getFirstRow();
    final int l = rng.getFirstColumn();
    final int b = rng.getLastRow();
    final int r = rng.getLastColumn();
    final Cell cell = BookHelper.getCell(sheet, t, l);
    return (!BookHelper.isBlankCell(cell)) ?
      new int[] {l, t, r, b} : null;
  }
View Full Code Here

    }
    return true;
  }
 
  private boolean shallHide(FilterColumn fc, int row, int col) {
    final Cell cell = BookHelper.getCell(_sheet, row, col + fc.getColId());
    final boolean blank = BookHelper.isBlankCell(cell);
    final String val =  blank ? "=" : BookHelper.getCellText(cell); //"=" means blank!
    final Set critera1 = fc.getCriteria1();
    return critera1 != null && !critera1.isEmpty() && !critera1.contains(val);
  }
View Full Code Here

      final int row2 = affectedArea.getLastRow();
      final Set cr1 = fc.getCriteria1();
 
      final Set<Ref> all = new HashSet<Ref>();
      for (int r = row; r <= row2; ++r) {
        final Cell cell = BookHelper.getCell(_sheet, r, col);
        final String val = BookHelper.isBlankCell(cell) ? "=" : BookHelper.getCellText(cell); //"=" means blank!
        if (cr1 != null && !cr1.isEmpty() && !cr1.contains(val)) { //to be hidden
          final Row rowobj = _sheet.getRow(r);
          if (rowobj == null || !rowobj.getZeroHeight()) { //a non-hidden row
            new RangeImpl(r, col, _sheet, _sheet).getRows().setHidden(true);
View Full Code Here

//            if (srcStyle != null) {
//              row.setRowStyle((HSSFCellStyle)copyFromStyleExceptBorder(srcStyle));//style
//            }
            if (srcCells != null) {
              for (Entry<Integer, Cell> cellEntry : srcCells.entrySet()) {
                final Cell srcCell = cellEntry.getValue();
                final CellStyle cellStyle = srcCell.getCellStyle();
                final int c = cellEntry.getKey().intValue();
                Cell cell = row.getCell(c);
                if (cell == null) {
                  cell = row.createCell(c);
                }
                cell.setCellStyle(BookHelper.copyFromStyleExceptBorder(getBook(), cellStyle));
              }
            }
          }
        }
       
View Full Code Here

TOP

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

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.