Package org.zkoss.poi.ss.usermodel

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


  }
 
  @Test
  public void testMoveB4D7_C4E7() { //left side move right
    Worksheet sheet1 = _workbook.getWorksheet("Sheet1");
    Row row1 = sheet1.getRow(0);
    Row row4 = sheet1.getRow(3);
    Row row5 = sheet1.getRow(4);
    Row row6 = sheet1.getRow(5);
    Row row7 = sheet1.getRow(6);
   
    assertEquals(1, row4.getCell(2).getNumericCellValue(), 0.0000000000000001); //C4: 1
    assertEquals(2, row4.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 2
    assertEquals(3, row4.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 3
    assertEquals(4, row4.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 4

    assertEquals(5, row5.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 5
    assertEquals(6, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 6
    assertEquals(7, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 7
    assertEquals(8, row5.getCell(5).getNumericCellValue(), 0.0000000000000001); //F5: 8
   
    assertEquals(9, row6.getCell(2).getNumericCellValue(), 0.0000000000000001); //C6: 9
    assertEquals(10, row6.getCell(3).getNumericCellValue(), 0.0000000000000001); //D6: 10
    assertEquals(11, row6.getCell(4).getNumericCellValue(), 0.0000000000000001); //E6: 11
    assertEquals(12, row6.getCell(5).getNumericCellValue(), 0.0000000000000001); //F6: 12
   
    assertEquals(13, row7.getCell(2).getNumericCellValue(), 0.0000000000000001); //C7: 13
    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)");
 
    //move left from B4:D7 to C4:E7
    BookHelper.moveRange(sheet1, 3, 1, 6, 3, 0, 1);
    _evaluator.notifySetFormula(cellA1);
   
    assertNull(row4.getCell(1)); //C4: null
    assertEquals(1, row4.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 1
    assertEquals(2, row4.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 2
    assertEquals(4, row4.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 4

    assertNull(row5.getCell(1)); //C5: null
    assertEquals(5, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 5
    assertEquals(6, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 6
    assertEquals(8, row5.getCell(5).getNumericCellValue(), 0.0000000000000001); //F5: 8
   
    assertNull(row6.getCell(1)); //C6: null
    assertEquals(9, row6.getCell(3).getNumericCellValue(), 0.0000000000000001); //D6: 10
    assertEquals(10, row6.getCell(4).getNumericCellValue(), 0.0000000000000001); //E6: 11
    assertEquals(12, row6.getCell(5).getNumericCellValue(), 0.0000000000000001); //F6: 12
   
    assertNull(row7.getCell(1)); //B7: 13
    assertEquals(13, row7.getCell(3).getNumericCellValue(), 0.0000000000000001); //D7: 13
    assertEquals(14, row7.getCell(4).getNumericCellValue(), 0.0000000000000001); //E7: 14
    assertEquals(16, row7.getCell(5).getNumericCellValue(), 0.0000000000000001); //F7: 16
   
    //A1: =SUM(C4:F7) -> =SUM(D4:F7)
    cellA1 = row1.getCell(0);
    valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(100, valueA1.getNumberValue(), 0.0000000000000001);
View Full Code Here


  }
 
  @Test
  public void testMoveD4D7_F4F7() { //center side move right(within reference right edge)
    Worksheet sheet1 = _workbook.getWorksheet("Sheet1");
    Row row1 = sheet1.getRow(0);
    Row row4 = sheet1.getRow(3);
    Row row5 = sheet1.getRow(4);
    Row row6 = sheet1.getRow(5);
    Row row7 = sheet1.getRow(6);
   
    assertEquals(1, row4.getCell(2).getNumericCellValue(), 0.0000000000000001); //C4: 1
    assertEquals(2, row4.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 2
    assertEquals(3, row4.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 3
    assertEquals(4, row4.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 4

    assertEquals(5, row5.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 5
    assertEquals(6, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 6
    assertEquals(7, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 7
    assertEquals(8, row5.getCell(5).getNumericCellValue(), 0.0000000000000001); //F5: 8
   
    assertEquals(9, row6.getCell(2).getNumericCellValue(), 0.0000000000000001); //C6: 9
    assertEquals(10, row6.getCell(3).getNumericCellValue(), 0.0000000000000001); //D6: 10
    assertEquals(11, row6.getCell(4).getNumericCellValue(), 0.0000000000000001); //E6: 11
    assertEquals(12, row6.getCell(5).getNumericCellValue(), 0.0000000000000001); //F6: 12
   
    assertEquals(13, row7.getCell(2).getNumericCellValue(), 0.0000000000000001); //C7: 13
    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)");
 
    //move left from D4:D7 to F4:F7
    BookHelper.moveRange(sheet1, 3, 3, 6, 3, 0, 2);
    _evaluator.notifySetFormula(cellA1);
   
    assertEquals(1, row4.getCell(2).getNumericCellValue(), 0.0000000000000001); //C4: 1
    assertNull(row4.getCell(3));
    assertEquals(3, row4.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 3
    assertEquals(2, row4.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 2

    assertEquals(5, row5.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 5
    assertNull(row5.getCell(3));
    assertEquals(7, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 7
    assertEquals(6, row5.getCell(5).getNumericCellValue(), 0.0000000000000001); //F5: 6
   
    assertEquals(9, row6.getCell(2).getNumericCellValue(), 0.0000000000000001); //C6: 9
    assertNull(row6.getCell(3));
    assertEquals(11, row6.getCell(4).getNumericCellValue(), 0.0000000000000001); //E6: 11
    assertEquals(10, row6.getCell(5).getNumericCellValue(), 0.0000000000000001); //F6: 10
   
    assertEquals(13, row7.getCell(2).getNumericCellValue(), 0.0000000000000001); //C7: 13
    assertNull(row7.getCell(3));
    assertEquals(15, row7.getCell(4).getNumericCellValue(), 0.0000000000000001); //E7: 15
    assertEquals(14, row7.getCell(5).getNumericCellValue(), 0.0000000000000001); //F7: 14
   
   
    //A1: =SUM(C4:F7) -> =SUM(C4:F7) //no change
    cellA1 = row1.getCell(0);
    valueA1 = _evaluator.evaluate(cellA1);
View Full Code Here

  }
 
  @Test
  public void testMoveF4G7_B4C7() { //right side move left and over original reference left column
    Worksheet sheet1 = _workbook.getWorksheet("Sheet1");
    Row row1 = sheet1.getRow(0);
    Row row4 = sheet1.getRow(3);
    Row row5 = sheet1.getRow(4);
    Row row6 = sheet1.getRow(5);
    Row row7 = sheet1.getRow(6);
   
    assertEquals(1, row4.getCell(2).getNumericCellValue(), 0.0000000000000001); //C4: 1
    assertEquals(2, row4.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 2
    assertEquals(3, row4.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 3
    assertEquals(4, row4.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 4

    assertEquals(5, row5.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 5
    assertEquals(6, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 6
    assertEquals(7, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 7
    assertEquals(8, row5.getCell(5).getNumericCellValue(), 0.0000000000000001); //F5: 8
   
    assertEquals(9, row6.getCell(2).getNumericCellValue(), 0.0000000000000001); //C6: 9
    assertEquals(10, row6.getCell(3).getNumericCellValue(), 0.0000000000000001); //D6: 10
    assertEquals(11, row6.getCell(4).getNumericCellValue(), 0.0000000000000001); //E6: 11
    assertEquals(12, row6.getCell(5).getNumericCellValue(), 0.0000000000000001); //F6: 12
   
    assertEquals(13, row7.getCell(2).getNumericCellValue(), 0.0000000000000001); //C7: 13
    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)");
 
    //move left from F4:G7 to B4:C7
    BookHelper.moveRange(sheet1, 3, 5, 6, 6, 0, -4);
    _evaluator.notifySetFormula(cellA1);
   

    assertEquals(4, row4.getCell(1).getNumericCellValue(), 0.0000000000000001); //B4: 4
    assertNull(row4.getCell(2));
    assertEquals(2, row4.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 2
    assertEquals(3, row4.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 3

    assertEquals(8, row5.getCell(1).getNumericCellValue(), 0.0000000000000001); //B5: 8
    assertNull(row5.getCell(2));
    assertEquals(6, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 6
    assertEquals(7, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 7
   
    assertEquals(12, row6.getCell(1).getNumericCellValue(), 0.0000000000000001); //B6: 12
    assertNull(row6.getCell(2));
    assertEquals(10, row6.getCell(3).getNumericCellValue(), 0.0000000000000001); //D6: 10
    assertEquals(11, row6.getCell(4).getNumericCellValue(), 0.0000000000000001); //E6: 11
   
    assertEquals(16, row7.getCell(1).getNumericCellValue(), 0.0000000000000001); //B7: 16
    assertNull(row7.getCell(2));
    assertEquals(14, row7.getCell(3).getNumericCellValue(), 0.0000000000000001); //D7: 14
    assertEquals(15, row7.getCell(4).getNumericCellValue(), 0.0000000000000001); //E7: 15
   
    //A1: =SUM(C4:F7) -> =SUM(B4:E7)
    cellA1 = row1.getCell(0);
    valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(108, valueA1.getNumberValue(), 0.0000000000000001);
View Full Code Here

  }
 
  @Test
  public void testMoveC6F8_C7F9() { //bottom side move down
    Worksheet sheet1 = _workbook.getWorksheet("Sheet1");
    Row row1 = sheet1.getRow(0);
    Row row4 = sheet1.getRow(3);
    Row row5 = sheet1.getRow(4);
    Row row6 = sheet1.getRow(5);
    Row row7 = sheet1.getRow(6);
   
    assertEquals(1, row4.getCell(2).getNumericCellValue(), 0.0000000000000001); //C4: 1
    assertEquals(2, row4.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 2
    assertEquals(3, row4.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 3
    assertEquals(4, row4.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 4

    assertEquals(5, row5.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 5
    assertEquals(6, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 6
    assertEquals(7, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 7
    assertEquals(8, row5.getCell(5).getNumericCellValue(), 0.0000000000000001); //F5: 8
   
    assertEquals(9, row6.getCell(2).getNumericCellValue(), 0.0000000000000001); //C6: 9
    assertEquals(10, row6.getCell(3).getNumericCellValue(), 0.0000000000000001); //D6: 10
    assertEquals(11, row6.getCell(4).getNumericCellValue(), 0.0000000000000001); //E6: 11
    assertEquals(12, row6.getCell(5).getNumericCellValue(), 0.0000000000000001); //F6: 12
   
    assertEquals(13, row7.getCell(2).getNumericCellValue(), 0.0000000000000001); //C7: 13
    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)");
 
    //move right from C6:F8 to C7:F9
    BookHelper.moveRange(sheet1, 5, 2, 7, 5, 1, 0);
    _evaluator.notifySetFormula(cellA1);
   
    assertEquals(1, row4.getCell(2).getNumericCellValue(), 0.0000000000000001); //C4: 1
    assertEquals(2, row4.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 2
    assertEquals(3, row4.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 3
    assertEquals(4, row4.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 4

    assertEquals(5, row5.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 5
    assertEquals(6, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 6
    assertEquals(7, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 7
    assertEquals(8, row5.getCell(5).getNumericCellValue(), 0.0000000000000001); //F5: 8
   
    assertEquals(9, row7.getCell(2).getNumericCellValue(), 0.0000000000000001); //C7: 9
    assertEquals(10, row7.getCell(3).getNumericCellValue(), 0.0000000000000001); //D7: 10
    assertEquals(11, row7.getCell(4).getNumericCellValue(), 0.0000000000000001); //E7: 11
    assertEquals(12, row7.getCell(5).getNumericCellValue(), 0.0000000000000001); //F7: 12
   
    Row row8 = sheet1.getRow(7);
    assertEquals(13, row8.getCell(2).getNumericCellValue(), 0.0000000000000001); //C8: 13
    assertEquals(14, row8.getCell(3).getNumericCellValue(), 0.0000000000000001); //D8: 14
    assertEquals(15, row8.getCell(4).getNumericCellValue(), 0.0000000000000001); //E8: 15
    assertEquals(16, row8.getCell(5).getNumericCellValue(), 0.0000000000000001); //F8: 16
   
    //A1: =SUM(C4:F7) -> =SUM(C4:F8)
    cellA1 = row1.getCell(0);
    valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(136, valueA1.getNumberValue(), 0.0000000000000001);
View Full Code Here

  }
 
  @Test
  public void testMoveC3F5_C1F3() { //top side move up
    Worksheet sheet1 = _workbook.getWorksheet("Sheet1");
    Row row1 = sheet1.getRow(0);
    Row row4 = sheet1.getRow(3);
    Row row5 = sheet1.getRow(4);
    Row row6 = sheet1.getRow(5);
    Row row7 = sheet1.getRow(6);
   
    assertEquals(1, row4.getCell(2).getNumericCellValue(), 0.0000000000000001); //C4: 1
    assertEquals(2, row4.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 2
    assertEquals(3, row4.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 3
    assertEquals(4, row4.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 4

    assertEquals(5, row5.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 5
    assertEquals(6, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 6
    assertEquals(7, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 7
    assertEquals(8, row5.getCell(5).getNumericCellValue(), 0.0000000000000001); //F5: 8
   
    assertEquals(9, row6.getCell(2).getNumericCellValue(), 0.0000000000000001); //C6: 9
    assertEquals(10, row6.getCell(3).getNumericCellValue(), 0.0000000000000001); //D6: 10
    assertEquals(11, row6.getCell(4).getNumericCellValue(), 0.0000000000000001); //E6: 11
    assertEquals(12, row6.getCell(5).getNumericCellValue(), 0.0000000000000001); //F6: 12
   
    assertEquals(13, row7.getCell(2).getNumericCellValue(), 0.0000000000000001); //C7: 13
    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)");
 
    //move up from C3:F4 to C1:F2
    BookHelper.moveRange(sheet1, 2, 2, 3, 5, -2, 0);
    _evaluator.notifySetFormula(cellA1);
    Row row2 = sheet1.getRow(1);
    assertEquals(1, row2.getCell(2).getNumericCellValue(), 0.0000000000000001); //C2: 1
    assertEquals(2, row2.getCell(3).getNumericCellValue(), 0.0000000000000001); //D2: 2
    assertEquals(3, row2.getCell(4).getNumericCellValue(), 0.0000000000000001); //E2: 3
    assertEquals(4, row2.getCell(5).getNumericCellValue(), 0.0000000000000001); //F2: 4

    assertEquals(5, row5.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 5
    assertEquals(6, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 6
    assertEquals(7, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 7
    assertEquals(8, row5.getCell(5).getNumericCellValue(), 0.0000000000000001); //F5: 8
View Full Code Here

  }
 
  @Test
  public void testMoveC6F8_C2F4() { //bottom side move top and over original reference top row 
    Worksheet sheet1 = _workbook.getWorksheet("Sheet1");
    Row row1 = sheet1.getRow(0);
    Row row4 = sheet1.getRow(3);
    Row row5 = sheet1.getRow(4);
    Row row6 = sheet1.getRow(5);
    Row row7 = sheet1.getRow(6);
   
    assertEquals(1, row4.getCell(2).getNumericCellValue(), 0.0000000000000001); //C4: 1
    assertEquals(2, row4.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 2
    assertEquals(3, row4.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 3
    assertEquals(4, row4.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 4

    assertEquals(5, row5.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 5
    assertEquals(6, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 6
    assertEquals(7, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 7
    assertEquals(8, row5.getCell(5).getNumericCellValue(), 0.0000000000000001); //F5: 8
   
    assertEquals(9, row6.getCell(2).getNumericCellValue(), 0.0000000000000001); //C6: 9
    assertEquals(10, row6.getCell(3).getNumericCellValue(), 0.0000000000000001); //D6: 10
    assertEquals(11, row6.getCell(4).getNumericCellValue(), 0.0000000000000001); //E6: 11
    assertEquals(12, row6.getCell(5).getNumericCellValue(), 0.0000000000000001); //F6: 12
   
    assertEquals(13, row7.getCell(2).getNumericCellValue(), 0.0000000000000001); //C7: 13
    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)");
 
    //move left from C6:F8 to C2:F4
    BookHelper.moveRange(sheet1, 5, 2, 7, 5, -4, 0);
    _evaluator.notifySetFormula(cellA1);
   
    assertNull(row4.getCell(2));
    assertNull(row4.getCell(3));
    assertNull(row4.getCell(4));
    assertNull(row4.getCell(5));

    assertEquals(5, row5.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 5
    assertEquals(6, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 6
    assertEquals(7, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 7
    assertEquals(8, row5.getCell(5).getNumericCellValue(), 0.0000000000000001); //F5: 8
   
    Row row2 = sheet1.getRow(1);
    assertEquals(9, row2.getCell(2).getNumericCellValue(), 0.0000000000000001); //C6: 9
    assertEquals(10, row2.getCell(3).getNumericCellValue(), 0.0000000000000001); //D6: 10
    assertEquals(11, row2.getCell(4).getNumericCellValue(), 0.0000000000000001); //E6: 11
    assertEquals(12, row2.getCell(5).getNumericCellValue(), 0.0000000000000001); //F6: 12
   
    Row row3 = sheet1.getRow(2);
    assertEquals(13, row3.getCell(2).getNumericCellValue(), 0.0000000000000001); //C7: 13
    assertEquals(14, row3.getCell(3).getNumericCellValue(), 0.0000000000000001); //D7: 14
    assertEquals(15, row3.getCell(4).getNumericCellValue(), 0.0000000000000001); //E7: 15
    assertEquals(16, row3.getCell(5).getNumericCellValue(), 0.0000000000000001); //F7: 16
   
    //A1: =SUM(C4:F7) -> =SUM(C2:F5)
    cellA1 = row1.getCell(0);
    valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(126, valueA1.getNumberValue(), 0.0000000000000001);
View Full Code Here

  }
 
  @Test
  public void testMoveC3F5_C4E7() { //top side move down
    Worksheet sheet1 = _workbook.getWorksheet("Sheet1");
    Row row1 = sheet1.getRow(0);
    Row row4 = sheet1.getRow(3);
    Row row5 = sheet1.getRow(4);
    Row row6 = sheet1.getRow(5);
    Row row7 = sheet1.getRow(6);
   
    assertEquals(1, row4.getCell(2).getNumericCellValue(), 0.0000000000000001); //C4: 1
    assertEquals(2, row4.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 2
    assertEquals(3, row4.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 3
    assertEquals(4, row4.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 4

    assertEquals(5, row5.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 5
    assertEquals(6, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 6
    assertEquals(7, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 7
    assertEquals(8, row5.getCell(5).getNumericCellValue(), 0.0000000000000001); //F5: 8
   
    assertEquals(9, row6.getCell(2).getNumericCellValue(), 0.0000000000000001); //C6: 9
    assertEquals(10, row6.getCell(3).getNumericCellValue(), 0.0000000000000001); //D6: 10
    assertEquals(11, row6.getCell(4).getNumericCellValue(), 0.0000000000000001); //E6: 11
    assertEquals(12, row6.getCell(5).getNumericCellValue(), 0.0000000000000001); //F6: 12
   
    assertEquals(13, row7.getCell(2).getNumericCellValue(), 0.0000000000000001); //C7: 13
    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)");
 
    //move left from C3:F5 to C5:F7
    BookHelper.moveRange(sheet1, 2, 2, 4, 5, 2, 0);
    _evaluator.notifySetFormula(cellA1);
   
    assertEquals(1, row6.getCell(2).getNumericCellValue(), 0.0000000000000001); //C4: 1
    assertEquals(2, row6.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 2
    assertEquals(3, row6.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 3
    assertEquals(4, row6.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 4

    assertEquals(5, row7.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 5
    assertEquals(6, row7.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 6
    assertEquals(7, row7.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 7
    assertEquals(8, row7.getCell(5).getNumericCellValue(), 0.0000000000000001); //F5: 8
   
    assertNull(row4.getCell(2));
    assertNull(row4.getCell(3));
    assertNull(row4.getCell(4));
    assertNull(row4.getCell(5));
View Full Code Here

  }
 
  @Test
  public void testMoveC6F6_C7F7() { //center side move down(within reference right edge)
    Worksheet sheet1 = _workbook.getWorksheet("Sheet1");
    Row row1 = sheet1.getRow(0);
    Row row4 = sheet1.getRow(3);
    Row row5 = sheet1.getRow(4);
    Row row6 = sheet1.getRow(5);
    Row row7 = sheet1.getRow(6);
   
    assertEquals(1, row4.getCell(2).getNumericCellValue(), 0.0000000000000001); //C4: 1
    assertEquals(2, row4.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 2
    assertEquals(3, row4.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 3
    assertEquals(4, row4.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 4

    assertEquals(5, row5.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 5
    assertEquals(6, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 6
    assertEquals(7, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 7
    assertEquals(8, row5.getCell(5).getNumericCellValue(), 0.0000000000000001); //F5: 8
   
    assertEquals(9, row6.getCell(2).getNumericCellValue(), 0.0000000000000001); //C6: 9
    assertEquals(10, row6.getCell(3).getNumericCellValue(), 0.0000000000000001); //D6: 10
    assertEquals(11, row6.getCell(4).getNumericCellValue(), 0.0000000000000001); //E6: 11
    assertEquals(12, row6.getCell(5).getNumericCellValue(), 0.0000000000000001); //F6: 12
   
    assertEquals(13, row7.getCell(2).getNumericCellValue(), 0.0000000000000001); //C7: 13
    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)");
 
    //move left from C6:F6 to C7:F7
    BookHelper.moveRange(sheet1, 5, 2, 5, 5, 1, 0);
    _evaluator.notifySetFormula(cellA1);
   
    assertEquals(1, row4.getCell(2).getNumericCellValue(), 0.0000000000000001); //C4: 1
    assertEquals(2, row4.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 2
    assertEquals(3, row4.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 3
    assertEquals(4, row4.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 4

    assertEquals(5, row5.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 5
    assertEquals(6, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 6
    assertEquals(7, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 7
    assertEquals(8, row5.getCell(5).getNumericCellValue(), 0.0000000000000001); //F5: 8
   
    assertEquals(9, row7.getCell(2).getNumericCellValue(), 0.0000000000000001); //C6: 9
    assertEquals(10, row7.getCell(3).getNumericCellValue(), 0.0000000000000001); //D6: 10
    assertEquals(11, row7.getCell(4).getNumericCellValue(), 0.0000000000000001); //E6: 11
    assertEquals(12, row7.getCell(5).getNumericCellValue(), 0.0000000000000001); //F6: 12
   
    assertNull(row6.getCell(2));
    assertNull(row6.getCell(3));
    assertNull(row6.getCell(4));
    assertNull(row6.getCell(5));
View Full Code Here

  }
 
  @Test
  public void testMoveC7F9_C5F7() { //bottom side move up
    Worksheet sheet1 = _workbook.getWorksheet("Sheet1");
    Row row1 = sheet1.getRow(0);
    Row row4 = sheet1.getRow(3);
    Row row5 = sheet1.getRow(4);
    Row row6 = sheet1.getRow(5);
    Row row7 = sheet1.getRow(6);
   
    assertEquals(1, row4.getCell(2).getNumericCellValue(), 0.0000000000000001); //C4: 1
    assertEquals(2, row4.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 2
    assertEquals(3, row4.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 3
    assertEquals(4, row4.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 4

    assertEquals(5, row5.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 5
    assertEquals(6, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 6
    assertEquals(7, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 7
    assertEquals(8, row5.getCell(5).getNumericCellValue(), 0.0000000000000001); //F5: 8
   
    assertEquals(9, row6.getCell(2).getNumericCellValue(), 0.0000000000000001); //C6: 9
    assertEquals(10, row6.getCell(3).getNumericCellValue(), 0.0000000000000001); //D6: 10
    assertEquals(11, row6.getCell(4).getNumericCellValue(), 0.0000000000000001); //E6: 11
    assertEquals(12, row6.getCell(5).getNumericCellValue(), 0.0000000000000001); //F6: 12
   
    assertEquals(13, row7.getCell(2).getNumericCellValue(), 0.0000000000000001); //C7: 13
    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)");
 
    //move left from C7:F9 to C5:F7
    BookHelper.moveRange(sheet1, 6, 2, 8, 5, -2, 0);
    _evaluator.notifySetFormula(cellA1);

    assertEquals(1, row4.getCell(2).getNumericCellValue(), 0.0000000000000001); //C4: 1
    assertEquals(2, row4.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 2
    assertEquals(3, row4.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 3
    assertEquals(4, row4.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 4

    assertEquals(13, row5.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 13
    assertEquals(14, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 14
    assertEquals(15, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 15
    assertEquals(16, row5.getCell(5).getNumericCellValue(), 0.0000000000000001); //F5: 16
   
    assertNull(row6.getCell(2));
    assertNull(row6.getCell(3));
    assertNull(row6.getCell(4));
    assertNull(row6.getCell(5));
   
    assertNull(row7.getCell(2));
    assertNull(row7.getCell(3));
    assertNull(row7.getCell(4));
    assertNull(row7.getCell(5));
   
    //A1: =SUM(C4:F7) -> =SUM(B4:E7)
    cellA1 = row1.getCell(0);
    valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(68, valueA1.getNumberValue(), 0.0000000000000001);
View Full Code Here

  }
 
  @Test
  public void testMoveB2G8_C3H9() { //block move down-right
    Worksheet sheet1 = _workbook.getWorksheet("Sheet1");
    Row row1 = sheet1.getRow(0);
    Row row4 = sheet1.getRow(3);
    Row row5 = sheet1.getRow(4);
    Row row6 = sheet1.getRow(5);
    Row row7 = sheet1.getRow(6);
   
    assertEquals(1, row4.getCell(2).getNumericCellValue(), 0.0000000000000001); //C4: 1
    assertEquals(2, row4.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 2
    assertEquals(3, row4.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 3
    assertEquals(4, row4.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 4

    assertEquals(5, row5.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 5
    assertEquals(6, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 6
    assertEquals(7, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 7
    assertEquals(8, row5.getCell(5).getNumericCellValue(), 0.0000000000000001); //F5: 8
   
    assertEquals(9, row6.getCell(2).getNumericCellValue(), 0.0000000000000001); //C6: 9
    assertEquals(10, row6.getCell(3).getNumericCellValue(), 0.0000000000000001); //D6: 10
    assertEquals(11, row6.getCell(4).getNumericCellValue(), 0.0000000000000001); //E6: 11
    assertEquals(12, row6.getCell(5).getNumericCellValue(), 0.0000000000000001); //F6: 12
   
    assertEquals(13, row7.getCell(2).getNumericCellValue(), 0.0000000000000001); //C7: 13
    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)");
 
    //move left from B2:G8 to C3:H9
    BookHelper.moveRange(sheet1, 1, 1, 7, 6, 1, 1);
    _evaluator.notifySetFormula(cellA1);

    assertNull(row5.getCell(2));
    assertEquals(1, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 1
    assertEquals(2, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 2
    assertEquals(3, row5.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 3
    assertEquals(4, row5.getCell(6).getNumericCellValue(), 0.0000000000000001); //G4: 4

    assertNull(row6.getCell(2));
    assertEquals(5, row6.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 5
    assertEquals(6, row6.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 6
    assertEquals(7, row6.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 7
    assertEquals(8, row6.getCell(6).getNumericCellValue(), 0.0000000000000001); //G4: 8
   
    assertNull(row7.getCell(2));
    assertEquals(9, row7.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 9
    assertEquals(10, row7.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 10
    assertEquals(11, row7.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 11
    assertEquals(12, row7.getCell(6).getNumericCellValue(), 0.0000000000000001); //G4: 12
   
    Row row8 = sheet1.getRow(7);
    assertNull(row8.getCell(2));
    assertEquals(13, row8.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 13
    assertEquals(14, row8.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 14
    assertEquals(15, row8.getCell(5).getNumericCellValue(), 0.0000000000000001); //F4: 15
    assertEquals(16, row8.getCell(6).getNumericCellValue(), 0.0000000000000001); //G4: 16
   
    assertNull(row4.getCell(2));
    assertNull(row4.getCell(3));
    assertNull(row4.getCell(4));
    assertNull(row4.getCell(5));
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.