Package org.zkoss.poi.ss.usermodel

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


  public static void setBackgroundColor(Worksheet sheet, Rect rect, String color) {
    final Book book  = (Book) sheet.getWorkbook();
    final Color bsColor = BookHelper.HTMLToColor(book, color);
    for (int row = rect.getTop(); row <= rect.getBottom(); row++)
      for (int col = rect.getLeft(); col <= rect.getRight(); col++) {
        Cell cell = Utils.getOrCreateCell(sheet, row, col);
        CellStyle cs = cell.getCellStyle();
        final Color srcColor = cs.getFillForegroundColorColor();
        if (Objects.equals(srcColor, bsColor)) {
          continue;
        }
        CellStyle newCellStyle = book.createCellStyle();
View Full Code Here


   * @param colIndex the column index of the cell
   * @return or create if not exist the {@link Cell} per the given sheet, row index, and column index.
   */
  public static Cell getOrCreateCell(Worksheet sheet,int rowIndex, int colIndex){
    Row row = getOrCreateRow(sheet, rowIndex);
    Cell cell = row.getCell(colIndex);
    if (cell == null) {
      cell = row.createCell(colIndex);
    }
    return cell;
  }
View Full Code Here

    final Range rng = getRange(sheet, 0, startCol, book.getSpreadsheetVersion().getLastRowIndex(), endCol);
    rng.delete(Range.SHIFT_DEFAULT);
  }

  public static void setCellValue(Worksheet sheet, int rowIndex, int colIndex, String value) {
    final Cell cell = getOrCreateCell(sheet, rowIndex, colIndex);
    cell.setCellValue(value);
  }
View Full Code Here

  public static void setCellValue(Worksheet sheet, int rowIndex, int colIndex, String value) {
    final Cell cell = getOrCreateCell(sheet, rowIndex, colIndex);
    cell.setCellValue(value);
  }
  public static void setCellValue(Worksheet sheet, int rowIndex, int colIndex, double value) {
    final Cell cell = getOrCreateCell(sheet, rowIndex, colIndex);
    cell.setCellValue(value);
  }
View Full Code Here

  public static void setCellValue(Worksheet sheet, int rowIndex, int colIndex, double value) {
    final Cell cell = getOrCreateCell(sheet, rowIndex, colIndex);
    cell.setCellValue(value);
  }
  public static void setCellValue(Worksheet sheet, int rowIndex, int colIndex, boolean value) {
    final Cell cell = getOrCreateCell(sheet, rowIndex, colIndex);
    cell.setCellValue(value);
  }
View Full Code Here

  public static void setCellValue(Worksheet sheet, int rowIndex, int colIndex, boolean value) {
    final Cell cell = getOrCreateCell(sheet, rowIndex, colIndex);
    cell.setCellValue(value);
  }
  public static void setCellValue(Worksheet sheet, int rowIndex, int colIndex, Date value) {
    final Cell cell = getOrCreateCell(sheet, rowIndex, colIndex);
    cell.setCellValue(value);
  }
View Full Code Here

  public static void setCellValue(Worksheet sheet, int rowIndex, int colIndex, Date value) {
    final Cell cell = getOrCreateCell(sheet, rowIndex, colIndex);
    cell.setCellValue(value);
  }
  public static void setCellValue(Worksheet sheet, int rowIndex, int colIndex, int value) {
    final Cell cell = getOrCreateCell(sheet, rowIndex, colIndex);
    cell.setCellValue(value);
  }
View Full Code Here

   * @param row the row index
   * @param col the column index
   * @param value the user input text
   */
  public static void setEditText(Worksheet sheet, int row, int col, String value) {
    final Cell cell = getOrCreateCell(sheet, row, col);
    setEditText(cell, value);
  }
View Full Code Here

    destination.cloneStyleFrom(cell.getCellStyle());
    return destination;
  }
 
  public static void setFontColor(Worksheet sheet, int row, int col, String color){
    final Cell cell = Utils.getOrCreateCell(sheet,row,col);
    final Book book = (Book) sheet.getWorkbook();
    final short fontIdx = cell.getCellStyle().getFontIndex();
    final Font font = book.getFontAt(fontIdx);
    final Color orgColor = BookHelper.getFontColor(book, font);
    final Color newColor = BookHelper.HTMLToColor(book, color);
    if (orgColor == newColor || orgColor != null && orgColor.equals(newColor)) {
      return;
    }
    final short boldWeight = font.getBoldweight();
    final short fontHeight = font.getFontHeight();
    final String name = font.getFontName();
    final boolean italic = font.getItalic();
    final boolean strikeout = font.getStrikeout();
    final short typeOffset = font.getTypeOffset();
    final byte underline = font.getUnderline();
    final Font newFont = BookHelper.getOrCreateFont(book, boldWeight, newColor, fontHeight, name, italic, strikeout, typeOffset, underline);
    final CellStyle style = cloneCellStyle(cell);
    style.setFont(newFont);
    cell.setCellStyle(style);
  }
View Full Code Here

    style.setFont(newFont);
    cell.setCellStyle(style);
  }
 
  public static void setFillColor(Worksheet sheet, int row, int col, String color){
    final Cell cell = Utils.getOrCreateCell(sheet,row,col);
    final Book book = (Book) sheet.getWorkbook();
    final Color orgColor = cell.getCellStyle().getFillForegroundColorColor();
    final Color newColor = BookHelper.HTMLToColor(book, color);
    if (orgColor == newColor || orgColor != null  && orgColor.equals(newColor)) { //no change, skip
      return;
    }
    final CellStyle style = cloneCellStyle(cell);
    BookHelper.setFillForegroundColor(style, newColor);
    cell.setCellStyle(style);
  }
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.