Package org.zkoss.poi.ss.usermodel

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


  }
 
  @Test
  public void testSetBgColor() {
    Worksheet sheet1 = _workbook.getWorksheet("Sheet1");
    Row row1 = sheet1.getRow(0);
    Cell A1 = BookHelper.getOrCreateCell(sheet1, 0, 0);
    CellStyle newCellStyle = _workbook.createCellStyle();
    newCellStyle.cloneStyleFrom(A1.getCellStyle());
    final Color bsColor = BookHelper.HTMLToColor(_workbook, "#00FF00");
    BookHelper.setFillForegroundColor(newCellStyle, bsColor);
    BookHelper.setCellStyle(sheet1, 0, 0, 0, 0, newCellStyle);
    assertEquals("FF00FF00", ((XSSFColor)row1.getCell(0).getCellStyle().getFillForegroundColorColor()).getARGBHex()); //A1: Green
  }
View Full Code Here


  }
 
  @Test
  public void testDelete4_6() {
    Worksheet sheet1 = _workbook.getWorksheet("Sheet1");
    Row row5 = sheet1.getRow(4);
    Row row6 = sheet1.getRow(5);
    Row row7 = sheet1.getRow(6);
    Row row8 = sheet1.getRow(7);
    Row row9 = sheet1.getRow(8);
    Row row10 = sheet1.getRow(9);
    assertEquals(1, row5.getCell(1).getNumericCellValue(), 0.0000000000000001);
    assertEquals(2, row5.getCell(2).getNumericCellValue(), 0.0000000000000001);
    assertEquals(3, row6.getCell(1).getNumericCellValue(), 0.0000000000000001);
    assertEquals(5, row7.getCell(1).getNumericCellValue(), 0.0000000000000001);
    assertEquals(7, row8.getCell(1).getNumericCellValue(), 0.0000000000000001);
    assertEquals(9, row9.getCell(1).getNumericCellValue(), 0.0000000000000001);
    assertEquals(11, row10.getCell(1).getNumericCellValue(), 0.0000000000000001);

    //A1: =SUM(B5:C5)
    Row row1 = sheet1.getRow(0);
    Cell cellA1 = row1.getCell(0); //A1: =SUM(B5:C5)
    CellValue valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(3, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(B5:C5)");

    //B1: =SUM(B5:B10)
    Cell cellB1 = row1.getCell(1); //B1: =SUM(B5:B10)
    CellValue valueB1 = _evaluator.evaluate(cellB1);
    assertEquals(36, valueB1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueB1.getCellType());
    testToFormulaString(cellB1, "SUM(B5:B10)");
   
    //C1: =SUM(B8:B10)
    Cell cellC1 = row1.getCell(2); //C1: =SUM(B8:B10)
    CellValue valueC1 = _evaluator.evaluate(cellC1);
    assertEquals(27, valueC1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueC1.getCellType());
    testToFormulaString(cellC1, "SUM(B8:B10)");
   
    //6 merge area
    assertEquals(6, sheet1.getNumMergedRegions());
    for (int j = 0; j < 6; ++j) {
      CellRangeAddress rng = sheet1.getMergedRegion(j);
      switch(j) {
      case 0:
        assertEquals("E6:F8", rng.formatAsString());
        break;
      case 1:
        assertEquals("E10:F12", rng.formatAsString());
        break;
      case 2:
        assertEquals("G5:H5", rng.formatAsString());
        break;
      case 3:
        assertEquals("E3:F4", rng.formatAsString());
        break;
      case 4:
        assertEquals("I3:J7", rng.formatAsString());
        break;
      case 5:
        assertEquals("E14:F15", rng.formatAsString());
        break;
      }
    }
 
    //remove rows 4 ~ 6
    BookHelper.deleteRows(sheet1, 3, 3); //remove rows 4 ~ 6
    _evaluator.notifySetFormula(cellA1);
    _evaluator.notifySetFormula(cellB1);
    _evaluator.notifySetFormula(cellC1);
   
    //B4: 5, B5:7, C5: empty, B6: 9, B7: 11, row 8 ~ row 10 empty
    Row row4 = sheet1.getRow(3);
    row5 = sheet1.getRow(4);
    row6 = sheet1.getRow(5);
    row7 = sheet1.getRow(6);
   
    row8 = sheet1.getRow(7);
    row9 = sheet1.getRow(8);
    row10 = sheet1.getRow(9);
   
    assertNull(row5.getCell(2)); //C5 not exist
    assertNull(row8.getCell(1));
    assertNull(row9.getCell(1));
    assertNull(row10);
   
    assertEquals(5, row4.getCell(1).getNumericCellValue(), 0.0000000000000001);
    assertEquals(7, row5.getCell(1).getNumericCellValue(), 0.0000000000000001);
    assertEquals(9, row6.getCell(1).getNumericCellValue(), 0.0000000000000001);
    assertEquals(11, row7.getCell(1).getNumericCellValue(), 0.0000000000000001);
   
    //C1: =SUM(B5:B7)
View Full Code Here

  }
 
  @Test
  public void testDeleteA4_J6() {
    Worksheet sheet1 = _workbook.getWorksheet("Sheet1");
    Row row5 = sheet1.getRow(4);
    Row row6 = sheet1.getRow(5);
    Row row7 = sheet1.getRow(6);
    Row row8 = sheet1.getRow(7);
    Row row9 = sheet1.getRow(8);
    Row row10 = sheet1.getRow(9);
    assertEquals(1, row5.getCell(1).getNumericCellValue(), 0.0000000000000001);
    assertEquals(2, row5.getCell(2).getNumericCellValue(), 0.0000000000000001);
    assertEquals(3, row6.getCell(1).getNumericCellValue(), 0.0000000000000001);
    assertEquals(5, row7.getCell(1).getNumericCellValue(), 0.0000000000000001);
    assertEquals(7, row8.getCell(1).getNumericCellValue(), 0.0000000000000001);
    assertEquals(9, row9.getCell(1).getNumericCellValue(), 0.0000000000000001);
    assertEquals(11, row10.getCell(1).getNumericCellValue(), 0.0000000000000001);

    //A1: =SUM(B5:C5)
    Row row1 = sheet1.getRow(0);
    Cell cellA1 = row1.getCell(0); //A1: =SUM(B5:C5)
    CellValue valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(3, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(B5:C5)");

    //B1: =SUM(B5:B10)
    Cell cellB1 = row1.getCell(1); //B1: =SUM(B5:B10)
    CellValue valueB1 = _evaluator.evaluate(cellB1);
    assertEquals(36, valueB1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueB1.getCellType());
    testToFormulaString(cellB1, "SUM(B5:B10)");
   
    //C1: =SUM(B8:B10)
    Cell cellC1 = row1.getCell(2); //C1: =SUM(B8:B10)
    CellValue valueC1 = _evaluator.evaluate(cellC1);
    assertEquals(27, valueC1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueC1.getCellType());
    testToFormulaString(cellC1, "SUM(B8:B10)");
   
    //6 merge area
    assertEquals(6, sheet1.getNumMergedRegions());
    for (int j = 0; j < 6; ++j) {
      CellRangeAddress rng = sheet1.getMergedRegion(j);
      switch(j) {
      case 0:
        assertEquals("E6:F8", rng.formatAsString());
        break;
      case 1:
        assertEquals("E10:F12", rng.formatAsString());
        break;
      case 2:
        assertEquals("G5:H5", rng.formatAsString());
        break;
      case 3:
        assertEquals("E3:F4", rng.formatAsString());
        break;
      case 4:
        assertEquals("I3:J7", rng.formatAsString());
        break;
      case 5:
        assertEquals("E14:F15", rng.formatAsString());
        break;
      }
    }
 
    //remove A4:J6
    BookHelper.deleteRange(sheet1, 3, 0, 5, 9, false);
    _evaluator.notifySetFormula(cellA1);
    _evaluator.notifySetFormula(cellB1);
    _evaluator.notifySetFormula(cellC1);
   
    //B4: 5, B5:7, C5: empty, B6: 9, B7: 11, row 8 ~ row 10 empty
    Row row4 = sheet1.getRow(3);
    row5 = sheet1.getRow(4);
    row6 = sheet1.getRow(5);
    row7 = sheet1.getRow(6);
   
    row8 = sheet1.getRow(7);
    row9 = sheet1.getRow(8);
    row10 = sheet1.getRow(9);
   
    assertNull(row5.getCell(2)); //C5 not exist
    assertNull(row8.getCell(1));
    assertNull(row9.getCell(1));
    assertNull(row10.getCell(1));
   
    assertEquals(5, row4.getCell(1).getNumericCellValue(), 0.0000000000000001);
    assertEquals(7, row5.getCell(1).getNumericCellValue(), 0.0000000000000001);
    assertEquals(9, row6.getCell(1).getNumericCellValue(), 0.0000000000000001);
    assertEquals(11, row7.getCell(1).getNumericCellValue(), 0.0000000000000001);
   
    //C1: =SUM(B5:B7)
View Full Code Here

  }
 
  @Test
  public void testLoadHyperlinks() {
    Worksheet sheet1 = (Worksheet)_workbook.getSheet("Sheet1");
    Row row1 = sheet1.getRow(0);
    Row row2 = sheet1.getRow(1);
    Row row3 = sheet1.getRow(2);
    Row row4 = sheet1.getRow(3);
    Row row5 = sheet1.getRow(4);
    Row row6 = sheet1.getRow(5);
   
    Cell cellA2 = row2.getCell(0);
    BookHelper.evaluate((Book)_workbook, cellA2);
    Hyperlink hlinkA1 = Utils.getHyperlink(row1.getCell(0));
    Hyperlink hlinkA2 = Utils.getHyperlink(cellA2);
    Hyperlink hlinkA3 = Utils.getHyperlink(row3.getCell(0));
    Hyperlink hlinkA4 = Utils.getHyperlink(row4.getCell(0));
    Hyperlink hlinkA5 = Utils.getHyperlink(row5.getCell(0));
    Hyperlink hlinkA6 = Utils.getHyperlink(row6.getCell(0));
   
    String stringA1 = Utils.formatHyperlink(sheet1, hlinkA1, "", true);
    String stringA2 = Utils.formatHyperlink(sheet1, hlinkA2, "", true);
    String stringA3 = Utils.formatHyperlink(sheet1, hlinkA3, "", true);
    String stringA4 = Utils.formatHyperlink(sheet1, hlinkA4, "", true);
View Full Code Here

  }
 
  @Test
  public void testMergeCells() {
    Worksheet sheet1 = _workbook.getWorksheet("Sheet1");
    Row row1 = sheet1.getRow(0);
    Row row2 = sheet1.getRow(1);
   
    Row row6 = sheet1.getRow(5);
    Row row7 = sheet1.getRow(6);
   
    Row row9 = sheet1.getRow(8);
    Row row10 = sheet1.getRow(9);
    Row row11 = sheet1.getRow(10);
    Row row12 = sheet1.getRow(11);

    //merged range (A1:B2)
    assertEquals(Cell.CELL_TYPE_BLANK, row1.getCell(0).getCellType()); //A1
    assertEquals(Cell.CELL_TYPE_BLANK, row1.getCell(1).getCellType()); //A2
    assertNull(row1.getCell(2)); //A3
    assertEquals(Cell.CELL_TYPE_BLANK, row2.getCell(0).getCellType()); //B1
    assertEquals(Cell.CELL_TYPE_BLANK, row2.getCell(1).getCellType()); //B2
    assertNull(row2.getCell(2)); //B3
    assertEquals(1, row9.getCell(0).getNumericCellValue(), 0.0000000000000001); //A9: 1
    assertEquals(2, row7.getCell(3).getNumericCellValue(), 0.0000000000000001)//D7: 2
    assertNull(sheet1.getRow(4)); //B5
   
    //C6: =A9
    Cell cellC6 = row6.getCell(2);
    CellValue valueC6 = _evaluator.evaluate(cellC6);
    assertEquals(1, valueC6.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueC6.getCellType());
    testToFormulaString(cellC6, "A9");

    //A10: =C6
    Cell cellA10 = row10.getCell(0);
    CellValue valueA10 = _evaluator.evaluate(cellA10);
    assertEquals(1, valueA10.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA10.getCellType());
    testToFormulaString(cellA10, "C6");
   
    //A11: =B5
    Cell cellA11 = row11.getCell(0);
    CellValue valueA11 = _evaluator.evaluate(cellA11);
    assertEquals(0, valueA11.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA11.getCellType());
    testToFormulaString(cellA11, "B5");

    //A12: =D7
    Cell cellA12 = row12.getCell(0);
    CellValue valueA12 = _evaluator.evaluate(cellA12);
    assertEquals(2, valueA12.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA12.getCellType());
    testToFormulaString(cellA12, "D7");
   
    //merge B5:D7
    BookHelper.merge(sheet1, 4, 1, 6, 3, true);
   
    Row row5 = sheet1.getRow(4);
    assertEquals(Cell.CELL_TYPE_FORMULA, row5.getCell(1).getCellType()); //B5: null -> =A9
    assertEquals(Cell.CELL_TYPE_BLANK, row5.getCell(2).getCellType()); //C5
    assertEquals(Cell.CELL_TYPE_BLANK, row5.getCell(3).getCellType()); //D5
    assertNull(row5.getCell(4)); //E5
    assertEquals(Cell.CELL_TYPE_BLANK, row6.getCell(1).getCellType()); //B6
    assertEquals(Cell.CELL_TYPE_BLANK, row6.getCell(2).getCellType()); //C6: =A9 -> blank
    assertEquals(Cell.CELL_TYPE_BLANK, row6.getCell(3).getCellType()); //D6
    assertNull(row6.getCell(4)); //E6
    assertEquals(Cell.CELL_TYPE_BLANK, row7.getCell(1).getCellType()); //B7
    assertEquals(Cell.CELL_TYPE_BLANK, row7.getCell(2).getCellType()); //C7
    assertEquals(Cell.CELL_TYPE_BLANK, row7.getCell(3).getCellType()); //D7: 2 -> blank
    assertNull(row7.getCell(4)); //E7
   
    //B5: =A9
    Cell cellB5 = row5.getCell(1);
    CellValue valueB5 = _evaluator.evaluate(cellB5);
    assertEquals(1, valueB5.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueB5.getCellType());
    testToFormulaString(cellB5, "A9");
View Full Code Here

  }
 
  @Test
  public void testInsertA5_D5() {
    Worksheet sheet1 = _workbook.getWorksheet("Sheet1");
    Row row1 = sheet1.getRow(0);
    Row row8 = sheet1.getRow(7);
    assertEquals(1, row8.getCell(0).getNumericCellValue(), 0.0000000000000001); //A8: 1
    assertEquals(2, row8.getCell(1).getNumericCellValue(), 0.0000000000000001)//B8: 2
    assertEquals(3, row8.getCell(2).getNumericCellValue(), 0.0000000000000001); //C8: 3
    assertEquals(7, row1.getCell(3).getNumericCellValue(), 0.0000000000000001); //D1: 7
   
    //A1: =SUM(A8:C8)
    Cell cellA1 = row1.getCell(0); //A1: =SUM(A8:C8)
    CellValue valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(6, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(A8:C8)");
   
    //B1: =SUM(B5:B1048576)
    Cell cellB1 = row1.getCell(1);
    CellValue valueB1 = _evaluator.evaluate(cellB1);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueB1.getCellType());
    testToFormulaString(cellB1, "SUM(B5:B1048576)");
    assertEquals(2, valueB1.getNumberValue(), 0.0000000000000001);

    //C1: =SUM(B1048575:B1048576)
    Cell cellC1 = row1.getCell(2);
    CellValue valueC1 = _evaluator.evaluate(cellC1);
    assertEquals(0, valueC1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueC1.getCellType());
    testToFormulaString(cellC1, "SUM(B1048575:B1048576)");
   
    //A10: =SUM(A8:C8)
    Row row10 = sheet1.getRow(9);
    Cell cellA10 = row10.getCell(0);
    CellValue valueA10 = _evaluator.evaluate(cellA10);
    assertEquals(6, valueA10.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA10.getCellType());
    testToFormulaString(cellA10, "SUM(A8:C8)");

    //D10: =D1
    Cell cellD10 = row10.getCell(3);
    CellValue valueD10 = _evaluator.evaluate(cellD10);
    assertEquals(7, valueD10.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueD10.getCellType());
    testToFormulaString(cellD10, "D1");
   
    //Insert A5:D5
    BookHelper.insertRange(sheet1, 4, 0, 4, 3, false, Range.FORMAT_LEFTABOVE);
    _evaluator.notifySetFormula(cellC1);
   
    Row row9 = sheet1.getRow(8);
    assertEquals(1, row9.getCell(0).getNumericCellValue(), 0.0000000000000001); //A9: 1
    assertEquals(2, row9.getCell(1).getNumericCellValue(), 0.0000000000000001); //B9: 2
    assertEquals(3, row9.getCell(2).getNumericCellValue(), 0.0000000000000001); //C9: 3
    assertEquals(7, row1.getCell(3).getNumericCellValue(), 0.0000000000000001); //D1: 7

    //A1: =SUM(A9:C9)
    cellA1 = row1.getCell(0);
    valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(6, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(A9:C9)");
   
    //B1: =SUM(B6:B1048576)
    cellB1 = row1.getCell(1);
    valueB1 = _evaluator.evaluate(cellB1);
    assertEquals(2, valueB1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueB1.getCellType());
    testToFormulaString(cellB1, "SUM(B6:B1048576)");

    //C1: =SUM(B1048576:B1048576)
    cellC1 = row1.getCell(2);
    valueC1 = _evaluator.evaluate(cellC1);
    assertEquals(0, valueC1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueC1.getCellType());
    testToFormulaString(cellC1, "SUM(B1048576:B1048576)");
   
    //A11: =SUM(A9:C9)
    Row row11 = sheet1.getRow(10);
    Cell cellA11 = row11.getCell(0);
    CellValue valueA11 = _evaluator.evaluate(cellA11);
    assertEquals(6, valueA11.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA11.getCellType());
    testToFormulaString(cellA11, "SUM(A9:C9)");

    //D11: =D1
    Cell cellD11 = row11.getCell(3); //D11: =D1
    CellValue valueD11 = _evaluator.evaluate(cellD11);
    assertEquals(7, valueD11.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueD11.getCellType());
    testToFormulaString(cellD11, "D1");
View Full Code Here

  }
 
  @Test
  public void testInsertRow5() {
    Worksheet sheet1 = _workbook.getWorksheet("Sheet1");
    Row row1 = sheet1.getRow(0);
    Row row8 = sheet1.getRow(7);
    assertEquals(1, row8.getCell(0).getNumericCellValue(), 0.0000000000000001); //A8: 1
    assertEquals(2, row8.getCell(1).getNumericCellValue(), 0.0000000000000001)//B8: 2
    assertEquals(3, row8.getCell(2).getNumericCellValue(), 0.0000000000000001); //C8: 3
    assertEquals(7, row1.getCell(3).getNumericCellValue(), 0.0000000000000001); //D1: 7
   
    //A1: =SUM(A8:C8)
    Cell cellA1 = row1.getCell(0); //A1: =SUM(A8:C8)
    CellValue valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(6, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(A8:C8)");
   
    //B1: =SUM(B5:B1048576)
    Cell cellB1 = row1.getCell(1);
    CellValue valueB1 = _evaluator.evaluate(cellB1);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueB1.getCellType());
    testToFormulaString(cellB1, "SUM(B5:B1048576)");
    assertEquals(2, valueB1.getNumberValue(), 0.0000000000000001);

    //C1: =SUM(B1048575:B1048576)
    Cell cellC1 = row1.getCell(2);
    CellValue valueC1 = _evaluator.evaluate(cellC1);
    assertEquals(0, valueC1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueC1.getCellType());
    testToFormulaString(cellC1, "SUM(B1048575:B1048576)");
   
    //A10: =SUM(A8:C8)
    Row row10 = sheet1.getRow(9);
    Cell cellA10 = row10.getCell(0);
    CellValue valueA10 = _evaluator.evaluate(cellA10);
    assertEquals(6, valueA10.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA10.getCellType());
    testToFormulaString(cellA10, "SUM(A8:C8)");

    //D10: =D1
    Cell cellD10 = row10.getCell(3);
    CellValue valueD10 = _evaluator.evaluate(cellD10);
    assertEquals(7, valueD10.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueD10.getCellType());
    testToFormulaString(cellD10, "D1");
   
    //Insert row 5
    BookHelper.insertRows(sheet1, 4, 1, Range.FORMAT_LEFTABOVE);
    _evaluator.notifySetFormula(cellC1);
   
    //height shall be the same
    Row row4 = sheet1.getRow(3);
    Row row5 = sheet1.getRow(4);
    assertEquals(row4.getHeight(), row5.getHeight());
   
    Row row9 = sheet1.getRow(8);
    assertEquals(1, row9.getCell(0).getNumericCellValue(), 0.0000000000000001); //A9: 1
    assertEquals(2, row9.getCell(1).getNumericCellValue(), 0.0000000000000001); //B9: 2
    assertEquals(3, row9.getCell(2).getNumericCellValue(), 0.0000000000000001); //C9: 3
    assertEquals(7, row1.getCell(3).getNumericCellValue(), 0.0000000000000001); //D1: 7

    //A1: =SUM(A9:C9)
    cellA1 = row1.getCell(0);
    valueA1 = _evaluator.evaluate(cellA1);
    assertEquals(6, valueA1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA1.getCellType());
    testToFormulaString(cellA1, "SUM(A9:C9)");
   
    //B1: =SUM(B6:B1048576)
    cellB1 = row1.getCell(1);
    valueB1 = _evaluator.evaluate(cellB1);
    assertEquals(2, valueB1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueB1.getCellType());
    testToFormulaString(cellB1, "SUM(B6:B1048576)");

    //C1: =SUM(B1048576:B1048576)
    cellC1 = row1.getCell(2);
    valueC1 = _evaluator.evaluate(cellC1);
    assertEquals(0, valueC1.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueC1.getCellType());
    testToFormulaString(cellC1, "SUM(B1048576:B1048576)");
   
    //A11: =SUM(A9:C9)
    Row row11 = sheet1.getRow(10);
    Cell cellA11 = row11.getCell(0);
    CellValue valueA11 = _evaluator.evaluate(cellA11);
    assertEquals(6, valueA11.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueA11.getCellType());
    testToFormulaString(cellA11, "SUM(A9:C9)");

    //D11: =D1
    Cell cellD11 = row11.getCell(3); //D11: =D1
    CellValue valueD11 = _evaluator.evaluate(cellD11);
    assertEquals(7, valueD11.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueD11.getCellType());
    testToFormulaString(cellD11, "D1");
View Full Code Here

  }

  @Test
  public void testEvaluateArea() {
    Worksheet sheet1 = _book.getWorksheet("Sheet 1");
    Row row = sheet1.getRow(0);
    assertEquals(null, row.getCell(0));
    assertEquals(2, row.getCell(1).getNumericCellValue(), 0.0000000000000001);
    assertEquals(3, row.getCell(2).getNumericCellValue(), 0.0000000000000001);
   
    Cell cell = row.getCell(3); //D1: =SUM(A1:C1)
    CellValue value = _evaluator.evaluate(cell);
    assertEquals(5, value.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, value.getCellType());
    testToFormulaString(cell, "SUM(A1:C1)");
   
View Full Code Here

    Worksheet sheet2 = _book.getWorksheet("Sheet2");
    assertEquals(1, sheet2.getRow(1).getCell(0).getNumericCellValue(), 0.0000000000000001);
    assertEquals(2, sheet2.getRow(1).getCell(1).getNumericCellValue(), 0.0000000000000001);
    assertEquals(3, sheet2.getRow(1).getCell(2).getNumericCellValue(), 0.0000000000000001);
   
    Row row = sheet1.getRow(1);
    Cell cell = row.getCell(3); //D2: =SUM(Sheet2!A2:C2)
    CellValue value = _evaluator.evaluate(cell);
    assertEquals(6, value.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, value.getCellType());
    testToFormulaString(cell, "SUM(Sheet2!A2:C2)");
   
View Full Code Here

    Worksheet sheet3 = _book.getWorksheet("Sheet3");
    assertEquals(1, sheet1.getRow(2).getCell(2).getNumericCellValue(), 0.0000000000000001);
    assertEquals(2, sheet2.getRow(2).getCell(2).getNumericCellValue(), 0.0000000000000001);
    assertEquals(3, sheet3.getRow(2).getCell(2).getNumericCellValue(), 0.0000000000000001);
   
    Row row = sheet1.getRow(2);
    Cell cell = row.getCell(3); //D3: =SUM(Sheet1:Sheet3!A3:C3)
    CellValue value = _evaluator.evaluate(cell);
    assertEquals(6, value.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, value.getCellType());
    testToFormulaString(cell, "SUM('Sheet 1:Sheet3'!A3:C3)");
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.