Package org.zkoss.poi.ss.usermodel

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


    style.setAlignment(align);
    cell.setCellStyle(style);
  }
 
  public static void setTextVAlign(Worksheet sheet,int row,int col, short valign){
    final Cell cell = Utils.getOrCreateCell(sheet,row,col);
    final short orgValign = cell.getCellStyle().getVerticalAlignment();
    if (valign == orgValign) { //no change, skip
      return;
    }
    final CellStyle style = cloneCellStyle(cell);
    style.setAlignment(valign);
    cell.setCellStyle(style);
  }
View Full Code Here


        //String color = BookHelper.indexToRGB(_book, style.getBottomBorderColor());
        String color = BookHelper.colorToHTML(_book, style.getBottomBorderColorColor());
        hitBottom = appendBorderStyle(sb, "bottom", bb, color);
      }
    }
    Cell next = null;
    if (!hitBottom) {
      next = Utils.getCell(_sheet, _row + 1, _col);
      /*if(next == null){ // don't search into merge ranges
        //check is _row+1,_col in merge range
        MergedRect rect = _mmHelper.getMergeRange(_row+1, _col);
        if(rect !=null){
          next = _sheet.getCell(rect.getTop(),rect.getLeft());
        }
      }*/
      if (next != null) {
        CellStyle style = next.getCellStyle();
        if (style != null){
          int bb = style.getBorderTop();// get top border of
          //String color = BookHelper.indexToRGB(_book, style.getTopBorderColor());
          String color = BookHelper.colorToHTML(_book, style.getTopBorderColorColor());
          // set next row top border as cell's bottom border;
          hitBottom = appendBorderStyle(sb, "bottom", bb, color);
        }
      }
    }
   
    //border depends on next cell's background color
    if(!hitBottom && next !=null){
      CellStyle style = next.getCellStyle();
      if (style != null){
        //String bgColor = BookHelper.indexToRGB(_book, style.getFillForegroundColor());
        //ZSS-34 cell background color does not show in excel
        String bgColor = style.getFillPattern() != CellStyle.NO_FILL ?
            BookHelper.colorToHTML(_book, style.getFillForegroundColorColor()) : null;
View Full Code Here

    boolean hitRight = false;
    MergedRect rect=null;
    boolean hitMerge = false;
    //find right border of target cell
    if (_cell != null) {
      Cell right = _cell;
      rect = _mmHelper.getMergeRange(_row, _col);
      if(rect!=null){
        hitMerge = true;
        right = Utils.getCell(_sheet, _row, rect.getRight());
      }
      if (right != null) {
        CellStyle style = right.getCellStyle();
        if (style != null){
          int bb = style.getBorderRight();
          //String color = BookHelper.indexToRGB(_book, style.getRightBorderColor());
          String color = BookHelper.colorToHTML(_book, style.getRightBorderColorColor());
          hitRight = appendBorderStyle(sb, "right", bb, color);
        }
      }
    }

    Cell next = null;
    //if no border for target cell,then check is this cell in a merge range
    //if(true) then try to get next cell after this merge range
    //else get next cell of this cell
    if(!hitRight){
      int c = hitMerge?rect.getRight()+1:_col+1;
      next = Utils.getCell(_sheet, _row, c);
      //find the right cell of merge range.
      if(next!=null){
        CellStyle style = next.getCellStyle();
        if (style != null){
          int bb = style.getBorderLeft();//get left here
          //String color = BookHelper.indexToRGB(_book, style.getLeftBorderColor());
          //ZSS-34 cell background color does not show in excel
          String color = style.getFillPattern() != CellStyle.NO_FILL ?
              BookHelper.colorToHTML(_book, style.getLeftBorderColorColor()) : null;
            hitRight = appendBorderStyle(sb, "right", bb, color);
        }
      }
    }

    //border depends on next cell's background color
    if(!hitRight && next !=null){
      CellStyle style = next.getCellStyle();
      if (style != null){
        //String bgColor = BookHelper.indexToRGB(_book, style.getFillForegroundColor());
        //ZSS-34 cell background color does not show in excel
        String bgColor = style.getFillPattern() != CellStyle.NO_FILL ?
            BookHelper.colorToHTML(_book, style.getFillForegroundColorColor()) : null;
View Full Code Here

    assertEquals(2, row1.getCell(1).getNumericCellValue(), 0.0000000000000001)//B1: 2
    assertEquals(3, row2.getCell(0).getNumericCellValue(), 0.0000000000000001); //A2: 3
    assertEquals(4, row2.getCell(1).getNumericCellValue(), 0.0000000000000001); //B2: 4
   
    //C3: =A1+7
    Cell cellC3 = row3.getCell(2);
    CellValue valueC3 = _evaluator.evaluate(cellC3);
    assertEquals(8, valueC3.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueC3.getCellType());
    testToFormulaString(cellC3, "A1+7");
   
    //Copy cell (C3 -> D4)
    BookHelper.copyCell(cellC3, sheet1, 3, 3, Range.PASTE_ALL, Range.PASTEOP_NONE, false);
    _evaluator.notifySetFormula(cellC3);

    //A1,A2,A2,B2 stay as is
    assertEquals(1, row1.getCell(0).getNumericCellValue(), 0.0000000000000001); //A1: 1
    assertEquals(2, row1.getCell(1).getNumericCellValue(), 0.0000000000000001)//B1: 2
    assertEquals(3, row2.getCell(0).getNumericCellValue(), 0.0000000000000001); //A2: 3
    assertEquals(4, row2.getCell(1).getNumericCellValue(), 0.0000000000000001); //B2: 4
   
    //C3 stay as is
    valueC3 = _evaluator.evaluate(cellC3);
    assertEquals(8, valueC3.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueC3.getCellType());
    testToFormulaString(cellC3, "A1+7");
   
    //D4: =B2+7
    Row row4 = sheet1.getRow(3);
    Cell cellD4 = row4.getCell(3);
    CellValue valueD4 = _evaluator.evaluate(cellD4);
    assertEquals(11, valueD4.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueD4.getCellType());
    testToFormulaString(cellD4, "B2+7");
  }
View Full Code Here

    assertEquals(2, row1.getCell(1).getNumericCellValue(), 0.0000000000000001)//B1: 2
    assertEquals(3, row2.getCell(0).getNumericCellValue(), 0.0000000000000001); //A2: 3
    assertEquals(4, row2.getCell(1).getNumericCellValue(), 0.0000000000000001); //B2: 4
   
    //C3: =A1+7
    Cell cellC3 = row3.getCell(2);
    CellValue valueC3 = _evaluator.evaluate(cellC3);
    assertEquals(8, valueC3.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueC3.getCellType());
    testToFormulaString(cellC3, "A1+7");
   
    //Copy cell (C3 -> C2)
    BookHelper.copyCell(cellC3, sheet1, 1, 2, Range.PASTE_ALL, Range.PASTEOP_NONE, false);
    _evaluator.notifySetFormula(cellC3);

    //A1,A2,A2,B2 stay as is
    assertEquals(1, row1.getCell(0).getNumericCellValue(), 0.0000000000000001); //A1: 1
    assertEquals(2, row1.getCell(1).getNumericCellValue(), 0.0000000000000001)//B1: 2
    assertEquals(3, row2.getCell(0).getNumericCellValue(), 0.0000000000000001); //A2: 3
    assertEquals(4, row2.getCell(1).getNumericCellValue(), 0.0000000000000001); //B2: 4
   
    //C3 stay as is
    valueC3 = _evaluator.evaluate(cellC3);
    assertEquals(8, valueC3.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueC3.getCellType());
    testToFormulaString(cellC3, "A1+7");
   
    //C2: #REF!
    Cell cellC2 = row2.getCell(2);
    CellValue valueC2 = _evaluator.evaluate(cellC2);
    assertEquals(ErrorConstants.ERROR_REF, valueC2.getErrorValue());
    assertEquals(Cell.CELL_TYPE_ERROR, valueC2.getCellType());
    testToFormulaString(cellC2, "#REF!+7");
  }
View Full Code Here

    assertEquals(4, row2.getCell(1).getNumericCellValue(), 0.0000000000000001); //B2: 4
    assertEquals(5, row1.getCell(4).getNumericCellValue(), 0.0000000000000001); //E1: 5
    assertEquals(6, row1.getCell(5).getNumericCellValue(), 0.0000000000000001); //F1: 6
   
    //D3: =SUM(E1:F1)
    Cell cellD3 = row3.getCell(3);
    CellValue valueD3 = _evaluator.evaluate(cellD3);
    assertEquals(11, valueD3.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueD3.getCellType());
    testToFormulaString(cellD3, "SUM(E1:F1)");
   
    //Copy cell (D3 -> IV3)
    BookHelper.copyCell(cellD3, sheet1, 2, 255, Range.PASTE_ALL, Range.PASTEOP_NONE, false);
    _evaluator.notifySetFormula(cellD3);

    //A1,A2,A2,B2,E1,F1 stay as is
    assertEquals(1, row1.getCell(0).getNumericCellValue(), 0.0000000000000001); //A1: 1
    assertEquals(2, row1.getCell(1).getNumericCellValue(), 0.0000000000000001)//B1: 2
    assertEquals(3, row2.getCell(0).getNumericCellValue(), 0.0000000000000001); //A2: 3
    assertEquals(4, row2.getCell(1).getNumericCellValue(), 0.0000000000000001); //B2: 4
    assertEquals(5, row1.getCell(4).getNumericCellValue(), 0.0000000000000001); //E1: 5
    assertEquals(6, row1.getCell(5).getNumericCellValue(), 0.0000000000000001); //F1: 6
   
    //D3 stay as is
    valueD3 = _evaluator.evaluate(cellD3);
    assertEquals(11, valueD3.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueD3.getCellType());
    testToFormulaString(cellD3, "SUM(E1:F1)");
   
    //IV3: #REF!
    Cell cellIV3 = row3.getCell(255);
    CellValue valueIV3 = _evaluator.evaluate(cellIV3);
    assertEquals(ErrorConstants.ERROR_REF, valueIV3.getErrorValue());
    assertEquals(Cell.CELL_TYPE_ERROR, valueIV3.getCellType());
    testToFormulaString(cellIV3, "SUM(#REF!)");
  }
View Full Code Here

    assertEquals(14, row7.getCell(3).getNumericCellValue(), 0.0000000000000001); //D7: 14
    assertEquals(15, row7.getCell(4).getNumericCellValue(), 0.0000000000000001); //E7: 15
    assertEquals(16, row7.getCell(5).getNumericCellValue(), 0.0000000000000001); //F7: 16
   
    //A1: =SUM(C4:F7);
    Cell cellA1 = row1.getCell(0);
    CellValue valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(136, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(C4:F7)");
 
View Full Code Here

    assertEquals(14, row7.getCell(3).getNumericCellValue(), 0.0000000000000001); //D7: 14
    assertEquals(15, row7.getCell(4).getNumericCellValue(), 0.0000000000000001); //E7: 15
    assertEquals(16, row7.getCell(5).getNumericCellValue(), 0.0000000000000001); //F7: 16
   
    //A1: =SUM(C4:F7);
    Cell cellA1 = row1.getCell(0);
    CellValue valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(136, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(C4:F7)");
 
View Full Code Here

    assertEquals(14, row7.getCell(3).getNumericCellValue(), 0.0000000000000001); //D7: 14
    assertEquals(15, row7.getCell(4).getNumericCellValue(), 0.0000000000000001); //E7: 15
    assertEquals(16, row7.getCell(5).getNumericCellValue(), 0.0000000000000001); //F7: 16
   
    //A1: =SUM(C4:F7);
    Cell cellA1 = row1.getCell(0);
    CellValue valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(136, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(C4:F7)");
 
View Full Code Here

    assertEquals(14, row7.getCell(3).getNumericCellValue(), 0.0000000000000001); //D7: 14
    assertEquals(15, row7.getCell(4).getNumericCellValue(), 0.0000000000000001); //E7: 15
    assertEquals(16, row7.getCell(5).getNumericCellValue(), 0.0000000000000001); //F7: 16
   
    //A1: =SUM(C4:F7);
    Cell cellA1 = row1.getCell(0);
    CellValue valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(136, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(C4:F7)");
 
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.