Package org.zkoss.poi.ss.usermodel

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


    assertEquals(9, row1.getCell(2).getNumericCellValue(), 0.0000000000000001); //C1: 9
    assertEquals(11, row1.getCell(3).getNumericCellValue(), 0.0000000000000001); //D1: 11
   
    //A1: =SUM(F1:F3)
    Cell cellA1 = row1.getCell(0); //A1: =SUM(F1:F3)
    CellValue valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(6, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(F1:F3)");
   
    //A2: =SUM(D2:XFD2) XFD: 16384
    Cell cellA2 = row2.getCell(0);
    CellValue valueA2 = _evaluator.evaluate(cellA2);
    assertEquals(2, valueA2.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA2.getCellType());
    testToFormulaString(cellA2, "SUM(D2:XFD2)");

    //A3: =SUM(XFC3:XFD3) XFC: 16383, XFD: 16384
    Cell cellA3 = row3.getCell(0); //A3: =SUM(XFC3:XFD3)
    CellValue valueA3 = _evaluator.evaluate(cellA3);
    assertEquals(0, valueA3.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA3.getCellType());
    testToFormulaString(cellA3, "SUM(XFC3:XFD3)");
   
    //A5: =SUM(C1:D1)
    Cell cellA5 = row5.getCell(0);
    CellValue valueA5 = _evaluator.evaluate(cellA5);
    assertEquals(20, valueA5.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA5.getCellType());
    testToFormulaString(cellA5, "SUM(C1:D1)");
   
    //A6: =SUM(B1:D1)
    Cell cellA6 = row6.getCell(0);
    CellValue valueA6 = _evaluator.evaluate(cellA6);
    assertEquals(20, valueA6.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA6.getCellType());
    testToFormulaString(cellA6, "SUM(B1:D1)");
   
    //H1: =SUM(F1:F3)
    Cell cellH1 = row1.getCell(7);
    CellValue valueH1 = _evaluator.evaluate(cellH1);
    assertEquals(6, valueH1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueH1.getCellType());
    testToFormulaString(cellH1, "SUM(F1:F3)");

    //H4: =A4
    Cell cellH4 = row4.getCell(7);
    CellValue valueH4 = _evaluator.evaluate(cellH4);
    assertEquals(7, valueH4.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueH4.getCellType());
    testToFormulaString(cellH4, "A4");
   
    //Insert C1:C4
    BookHelper.insertRange(sheet1, 0, 2, 3, 2, true, Range.FORMAT_LEFTABOVE);
    _evaluator.notifySetFormula(cellA1);
    _evaluator.notifySetFormula(cellA2);
    _evaluator.notifySetFormula(cellA3);
    _evaluator.notifySetFormula(cellA5);
    _evaluator.notifySetFormula(cellA6);
   
    assertEquals(1, row1.getCell(6).getNumericCellValue(), 0.0000000000000001); //G1: 1
    assertEquals(2, row2.getCell(6).getNumericCellValue(), 0.0000000000000001)//G2: 2
    assertEquals(3, row3.getCell(6).getNumericCellValue(), 0.0000000000000001); //G3: 3
    assertEquals(7, row4.getCell(0).getNumericCellValue(), 0.0000000000000001); //A4: 7
    assertEquals(9, row1.getCell(3).getNumericCellValue(), 0.0000000000000001); //D1: 9
    assertEquals(11, row1.getCell(4).getNumericCellValue(), 0.0000000000000001); //E1: 11

    //A1: =SUM(G1:G3)
    valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(6, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(G1:G3)");
   
    //A2: =SUM(E2:XFD2) XFD: 16384
    valueA2 = _evaluator.evaluate(cellA2);
    assertEquals(2, valueA2.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA2.getCellType());
    testToFormulaString(cellA2, "SUM(E2:XFD2)");

    //A3: =SUM(XFC3:XFD3) -> =SUM(XFD3:XFD3) XFD: 16384
    cellA3 = row3.getCell(0);
    valueA6 = _evaluator.evaluate(cellA3);
    assertEquals(0, valueA6.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA6.getCellType());
    testToFormulaString(cellA3, "SUM(XFD3:XFD3)");
   
    //A5: =SUM(C1:D1) -> =SUM(D1:E1)
    cellA5 = row5.getCell(0);
    valueA5 = _evaluator.evaluate(cellA5);
    assertEquals(20, valueA5.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA5.getCellType());
    testToFormulaString(cellA5, "SUM(D1:E1)");
   
    //A6: =SUM(B1:D1) -> =SUM(B1:E1)
    cellA6 = row6.getCell(0);
    valueA6 = _evaluator.evaluate(cellA6);
    assertEquals(20, valueA6.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA6.getCellType());
    testToFormulaString(cellA6, "SUM(B1:E1)");
   
    //I1: =SUM(G1:G3)
    Cell cellI1 = row1.getCell(8);
    CellValue valueI1 = _evaluator.evaluate(cellI1);
    assertEquals(6, valueI1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueI1.getCellType());
    testToFormulaString(cellI1, "SUM(G1:G3)");

    //I4: =A4
    Cell cellI4 = row4.getCell(8);
    CellValue valueI4 = _evaluator.evaluate(cellI4);
    assertEquals(7, valueI4.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueI4.getCellType());
    testToFormulaString(cellI4, "A4");
   
  }
View Full Code Here


    assertEquals(9, row1.getCell(2).getNumericCellValue(), 0.0000000000000001); //C1: 9
    assertEquals(11, row1.getCell(3).getNumericCellValue(), 0.0000000000000001); //D1: 11
   
    //A1: =SUM(F1:F3)
    Cell cellA1 = row1.getCell(0); //A1: =SUM(F1:F3)
    CellValue valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(6, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(F1:F3)");
   
    //A2: =SUM(D2:IV2) IV: 256
    Cell cellA2 = row2.getCell(0); //A2: =SUM(D2:IV2) IV: 256
    CellValue valueA2 = _evaluator.evaluate(cellA2);
    assertEquals(2, valueA2.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA2.getCellType());
    testToFormulaString(cellA2, "SUM(D2:IV2)");

    //A3: =SUM(IU3:IV3) IU: 255, IV: 256
    Cell cellA3 = row3.getCell(0); //A3: =SUM(IU3:IV3)
    CellValue valueA3 = _evaluator.evaluate(cellA3);
    assertEquals(0, valueA3.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA3.getCellType());
    testToFormulaString(cellA3, "SUM(IU3:IV3)");
   
    //A5: =SUM(C1:D1)
    Cell cellA5 = row5.getCell(0);
    CellValue valueA5 = _evaluator.evaluate(cellA5);
    assertEquals(20, valueA5.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA5.getCellType());
    testToFormulaString(cellA5, "SUM(C1:D1)");
   
    //A6: =SUM(B1:D1)
    Cell cellA6 = row6.getCell(0);
    CellValue valueA6 = _evaluator.evaluate(cellA6);
    assertEquals(20, valueA6.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA6.getCellType());
    testToFormulaString(cellA6, "SUM(B1:D1)");
   
    //H1: =SUM(F1:F3)
    Cell cellH1 = row1.getCell(7);
    CellValue valueH1 = _evaluator.evaluate(cellH1);
    assertEquals(6, valueH1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueH1.getCellType());
    testToFormulaString(cellH1, "SUM(F1:F3)");

    //H4: =A4
    Cell cellH4 = row4.getCell(7);
    CellValue valueH4 = _evaluator.evaluate(cellH4);
    assertEquals(7, valueH4.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueH4.getCellType());
    testToFormulaString(cellH4, "A4");
   
    //Insert before column C
    BookHelper.insertColumns(sheet1, 2, 1, Range.FORMAT_LEFTABOVE);
    _evaluator.notifySetFormula(cellA1);
    _evaluator.notifySetFormula(cellA2);
    _evaluator.notifySetFormula(cellA3);
    _evaluator.notifySetFormula(cellA5);
    _evaluator.notifySetFormula(cellA6);
   
    assertEquals(sheet1.getColumnWidth(1), sheet1.getColumnWidth(2)); //column c width == column b width
    assertEquals(HSSFColor.RED.index, row1.getCell(1).getCellStyle().getFillForegroundColor());
    assertEquals(HSSFColor.YELLOW.index, row1.getCell(1).getCellStyle().getFillBackgroundColor());
    assertEquals(HSSFColor.RED.index, row1.getCell(2).getCellStyle().getFillForegroundColor());
    assertEquals(HSSFColor.YELLOW.index, row1.getCell(2).getCellStyle().getFillBackgroundColor());
   
    assertEquals(1, row1.getCell(6).getNumericCellValue(), 0.0000000000000001); //G1: 1
    assertEquals(2, row2.getCell(6).getNumericCellValue(), 0.0000000000000001)//G2: 2
    assertEquals(3, row3.getCell(6).getNumericCellValue(), 0.0000000000000001); //G3: 3
    assertEquals(7, row4.getCell(0).getNumericCellValue(), 0.0000000000000001); //A4: 7

    //A1: =SUM(G1:G3)
    valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(6, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(G1:G3)");
   
    //A2: =SUM(E2:IV2) IV: 256
    valueA2 = _evaluator.evaluate(cellA2);
    assertEquals(2, valueA2.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA2.getCellType());
    testToFormulaString(cellA2, "SUM(E2:IV2)");

    //A3: =SUM(IV3:IV3) IV: 256
    cellA3 = row3.getCell(0); //A3: =SUM(IU3:IV3)
    valueA6 = _evaluator.evaluate(cellA3);
    assertEquals(0, valueA6.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA6.getCellType());
    testToFormulaString(cellA3, "SUM(IV3:IV3)");
   
    //A5: =SUM(C1:D1) -> =SUM(D1:E1)
    cellA5 = row5.getCell(0);
    valueA5 = _evaluator.evaluate(cellA5);
    assertEquals(20, valueA5.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA5.getCellType());
    testToFormulaString(cellA5, "SUM(D1:E1)");
   
    //A6: =SUM(B1:D1) -> =SUM(B1:E1)
    cellA6 = row6.getCell(0);
    valueA6 = _evaluator.evaluate(cellA6);
    assertEquals(20, valueA6.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA6.getCellType());
    testToFormulaString(cellA6, "SUM(B1:E1)");
   
    //I1: =SUM(G1:G3)
    Cell cellI1 = row1.getCell(8);
    CellValue valueI1 = _evaluator.evaluate(cellI1);
    assertEquals(6, valueI1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueI1.getCellType());
    testToFormulaString(cellI1, "SUM(G1:G3)");

    //I4: =A4
    Cell cellI4 = row4.getCell(8);
    CellValue valueI4 = _evaluator.evaluate(cellI4);
    assertEquals(7, valueI4.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueI4.getCellType());
    testToFormulaString(cellI4, "A4");
   
  }
View Full Code Here

    assertEquals(9, row1.getCell(2).getNumericCellValue(), 0.0000000000000001); //C1: 9
    assertEquals(11, row1.getCell(3).getNumericCellValue(), 0.0000000000000001); //D1: 11
   
    //A1: =SUM(F1:F3)
    Cell cellA1 = row1.getCell(0); //A1: =SUM(F1:F3)
    CellValue valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(6, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(F1:F3)");
   
    //A2: =SUM(D2:IV2) IV: 256
    Cell cellA2 = row2.getCell(0); //A2: =SUM(D2:IV2) IV: 256
    CellValue valueA2 = _evaluator.evaluate(cellA2);
    assertEquals(2, valueA2.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA2.getCellType());
    testToFormulaString(cellA2, "SUM(D2:IV2)");

    //A3: =SUM(IU3:IV3) IU: 255, IV: 256
    Cell cellA3 = row3.getCell(0); //A3: =SUM(IU3:IV3)
    CellValue valueA3 = _evaluator.evaluate(cellA3);
    assertEquals(0, valueA3.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA3.getCellType());
    testToFormulaString(cellA3, "SUM(IU3:IV3)");
   
    //A5: =SUM(C1:D1)
    Cell cellA5 = row5.getCell(0);
    CellValue valueA5 = _evaluator.evaluate(cellA5);
    assertEquals(20, valueA5.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA5.getCellType());
    testToFormulaString(cellA5, "SUM(C1:D1)");
   
    //A6: =SUM(B1:D1)
    Cell cellA6 = row6.getCell(0);
    CellValue valueA6 = _evaluator.evaluate(cellA6);
    assertEquals(20, valueA6.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA6.getCellType());
    testToFormulaString(cellA6, "SUM(B1:D1)");
   
    //H1: =SUM(F1:F3)
    Cell cellH1 = row1.getCell(7);
    CellValue valueH1 = _evaluator.evaluate(cellH1);
    assertEquals(6, valueH1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueH1.getCellType());
    testToFormulaString(cellH1, "SUM(F1:F3)");

    //H4: =A4
    Cell cellH4 = row4.getCell(7);
    CellValue valueH4 = _evaluator.evaluate(cellH4);
    assertEquals(7, valueH4.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueH4.getCellType());
    testToFormulaString(cellH4, "A4");
   
    //Insert C1:C4
    BookHelper.insertRange(sheet1, 0, 2, 3, 2, true, Range.FORMAT_LEFTABOVE);
    _evaluator.notifySetFormula(cellA1);
    _evaluator.notifySetFormula(cellA2);
    _evaluator.notifySetFormula(cellA3);
    _evaluator.notifySetFormula(cellA5);
    _evaluator.notifySetFormula(cellA6);
   
    assertEquals(1, row1.getCell(6).getNumericCellValue(), 0.0000000000000001); //G1: 1
    assertEquals(2, row2.getCell(6).getNumericCellValue(), 0.0000000000000001)//G2: 2
    assertEquals(3, row3.getCell(6).getNumericCellValue(), 0.0000000000000001); //G3: 3
    assertEquals(7, row4.getCell(0).getNumericCellValue(), 0.0000000000000001); //A4: 7
    assertEquals(9, row1.getCell(3).getNumericCellValue(), 0.0000000000000001); //D1: 9
    assertEquals(11, row1.getCell(4).getNumericCellValue(), 0.0000000000000001); //E1: 11

    //A1: =SUM(G1:G3)
    valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(6, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(G1:G3)");
   
    //A2: =SUM(E2:IV2) IV: 256
    valueA2 = _evaluator.evaluate(cellA2);
    assertEquals(2, valueA2.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA2.getCellType());
    testToFormulaString(cellA2, "SUM(E2:IV2)");

    //A3: =SUM(IV3:IV3) IV: 256
    cellA3 = row3.getCell(0); //A3: =SUM(IU3:IV3)
    valueA6 = _evaluator.evaluate(cellA3);
    assertEquals(0, valueA6.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA6.getCellType());
    testToFormulaString(cellA3, "SUM(IV3:IV3)");
   
    //A5: =SUM(C1:D1) -> =SUM(D1:E1)
    cellA5 = row5.getCell(0);
    valueA5 = _evaluator.evaluate(cellA5);
    assertEquals(20, valueA5.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA5.getCellType());
    testToFormulaString(cellA5, "SUM(D1:E1)");
   
    //A6: =SUM(B1:D1) -> =SUM(B1:E1)
    cellA6 = row6.getCell(0);
    valueA6 = _evaluator.evaluate(cellA6);
    assertEquals(20, valueA6.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA6.getCellType());
    testToFormulaString(cellA6, "SUM(B1:E1)");
   
    //I1: =SUM(G1:G3)
    Cell cellI1 = row1.getCell(8);
    CellValue valueI1 = _evaluator.evaluate(cellI1);
    assertEquals(6, valueI1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueI1.getCellType());
    testToFormulaString(cellI1, "SUM(G1:G3)");

    //I4: =A4
    Cell cellI4 = row4.getCell(8);
    CellValue valueI4 = _evaluator.evaluate(cellI4);
    assertEquals(7, valueI4.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueI4.getCellType());
    testToFormulaString(cellI4, "A4");
   
  }
View Full Code Here

    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 E4:F7 to F4:G7
    BookHelper.moveRange(sheet1, 3, 4, 6, 5, 0, 1);
    _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(5).getNumericCellValue(), 0.0000000000000001); //E4: 3
    assertEquals(4, row4.getCell(6).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(5).getNumericCellValue(), 0.0000000000000001); //E5: 7
    assertEquals(8, row5.getCell(6).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(5).getNumericCellValue(), 0.0000000000000001); //E6: 11
    assertEquals(12, row6.getCell(6).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(5).getNumericCellValue(), 0.0000000000000001); //E7: 15
    assertEquals(16, row7.getCell(6).getNumericCellValue(), 0.0000000000000001); //F7: 16
   
    //A1: =SUM(C4:G7)
    cellA1 = row1.getCell(0);
    valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(136, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(C4:G7)");
  }
View Full Code Here

    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 C4:D7 to B4:C7
    BookHelper.moveRange(sheet1, 3, 2, 6, 3, 0, -1);
    _evaluator.notifySetFormula(cellA1);
   
    assertEquals(1, row4.getCell(1).getNumericCellValue(), 0.0000000000000001); //B4: 1
    assertEquals(2, row4.getCell(2).getNumericCellValue(), 0.0000000000000001); //C4: 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(1).getNumericCellValue(), 0.0000000000000001); //B5: 5
    assertEquals(6, row5.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 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(1).getNumericCellValue(), 0.0000000000000001); //B6: 9
    assertEquals(10, row6.getCell(2).getNumericCellValue(), 0.0000000000000001); //C6: 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(1).getNumericCellValue(), 0.0000000000000001); //B7: 13
    assertEquals(14, row7.getCell(2).getNumericCellValue(), 0.0000000000000001); //C7: 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) -> =SUM(B4:F7)
    cellA1 = row1.getCell(0);
    valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(136, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(B4:F7)");
  }
View Full Code Here

    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 E4:G7 to D4:F7
    BookHelper.moveRange(sheet1, 3, 4, 6, 6, 0, -1);
    _evaluator.notifySetFormula(cellA1);
   
    assertEquals(1, row4.getCell(2).getNumericCellValue(), 0.0000000000000001); //C4: 1
    assertEquals(3, row4.getCell(3).getNumericCellValue(), 0.0000000000000001); //D4: 3
    assertEquals(4, row4.getCell(4).getNumericCellValue(), 0.0000000000000001); //E4: 4
    assertNull(row4.getCell(6)); //F4: null

    assertEquals(5, row5.getCell(2).getNumericCellValue(), 0.0000000000000001); //C5: 5
    assertEquals(7, row5.getCell(3).getNumericCellValue(), 0.0000000000000001); //D5: 7
    assertEquals(8, row5.getCell(4).getNumericCellValue(), 0.0000000000000001); //E5: 8
    assertNull(row5.getCell(6))//F5: null
   
    assertEquals(9, row6.getCell(2).getNumericCellValue(), 0.0000000000000001); //C6: 9
    assertEquals(11, row6.getCell(3).getNumericCellValue(), 0.0000000000000001); //D6: 11
    assertEquals(12, row6.getCell(4).getNumericCellValue(), 0.0000000000000001); //E6: 12
    assertNull(row6.getCell(6)); //F6: null
   
    assertEquals(13, row7.getCell(2).getNumericCellValue(), 0.0000000000000001); //C7: 13
    assertEquals(15, row7.getCell(3).getNumericCellValue(), 0.0000000000000001); //D7: 15
    assertEquals(16, row7.getCell(4).getNumericCellValue(), 0.0000000000000001); //E7: 16
    assertNull(row7.getCell(6)); //F7: null
   
    //A1: =SUM(C4:G7) -> =SUM(C4:E7)
    cellA1 = row1.getCell(0);
    valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(104, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(C4:E7)");
  }
View Full Code Here

    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);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(D4:F7)");
  }
View Full Code Here

    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);
    assertEquals(96, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(C4:F7)");
  }
View Full Code Here

    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);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(B4:E7)");
  }
View Full Code Here

    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);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(C4:F8)");
  }
View Full Code Here

TOP

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

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.