Package org.zkoss.zss.model

Examples of org.zkoss.zss.model.Cell


      for(int i=0;i<args.length;i++){
        if(i>0) sb.append(", ");
        if(args[i] instanceof RangeRef){
          RangeRef ref = (RangeRef)args[i];
          for(Iterator iter = ref.getCells().iterator();iter.hasNext();){
            Cell cell = (Cell)iter.next();
            sb.append(cell.getText());
            if(iter.hasNext()) sb.append(", ");
          }
        }else if(args[i]!=null){
          sb.append(args[i].toString());
        }
View Full Code Here


    map.put("DEF", "Hello ZK");
    book.addVariableResolver(resolver);

    FunctionMapper mapper = new MyMapper();
    book.addFunctionMapper(mapper);
    Cell cellA1 = sheet1.getCell(0,0);
System.out.println(cellA1.getValue());
   
Cell cellA2 = sheet1.getCell(1,0);
System.out.println(cellA2.getValue());

    assertEquals("Hello ZK", cellA1.getText());
  }
View Full Code Here

  public void testSpecialFunction2() {
    final String nm = "fun2.xls";

    Book book = new ExcelImporter().imports(getClass().getResource("/"+nm));
    Sheet sheet1 = (Sheet) book.getSheets().get(0);
    Cell cellA1 = sheet1.getCell(0,0);
    assertEquals("=MROUND(10.0,3.0)", cellA1.getEditText());
    assertEquals("9", cellA1.getText());
   
    Cell cellB1 = sheet1.getCell(0,1);
    assertEquals("=LCM(5.0,2.0)", cellB1.getEditText());
    assertEquals("10", cellB1.getText());
  }
View Full Code Here

  public void testSpecialFunction3() {
    final String nm = "fun3.xls";

    Book book = new ExcelImporter().imports(getClass().getResource("/"+nm));
    Sheet sheet1 = (Sheet) book.getSheets().get(0);
    Cell cellA1 = sheet1.getCell(0,0);
    assertEquals("=DB(3000000.0,200000.0,10.0,2.0,9.0)", cellA1.getEditText());
    Cell cellA2 = sheet1.getCell(1,0);
    assertEquals("=PMT(0.1/12.0,6.0,100000.0,2000.0,1.0)", cellA2.getEditText());
//    assertEquals("9", cellA1.getText());
  }
View Full Code Here

    lastRow = event.getRow();
    lastCol = event.getColumn();
    Label lbpos = (Label)getFellow("lbpos");
    Textbox tbxval = (Textbox)getFellow("tbxval");
   
    Cell cell = sheet.getCell(lastRow, lastCol);
    lbpos.setValue(Indexes.toA1(lastRow,lastCol,false,false));
    tbxval.setValue(cell == null ? "" : cell.getEditText());
  }
View Full Code Here

  void doCellChange(String value){
    if(lastRow == -1){
      return;
    }
    Sheet sheet = (Sheet)book.getSheets().get(0);
    Cell cell = sheet.getCell(lastRow, lastCol);
    if(cell==null){
      sheet.setCellValue(lastRow, lastCol, "");
      cell = (Cell)sheet.getCell(lastRow,lastCol);
    }
    cell.setEditText(value);
  }
View Full Code Here

                      // cells
      final Range rng = (Range) arg;
      final Book book = rng.getSheet().getBook();
      final Collection cells = rng.getCells();
      for(final Iterator it = cells.iterator(); it.hasNext();) {
        final Cell cell = (Cell) it.next();
        total= sumDeviation(total, cell.getResult(),mean, (XelContext) book); // recursive
      }
      return total;
    } else if (arg == null) {
      return total;
    } else {
View Full Code Here

    System.out.println(""+expect+", "+val);
    assertEquals(expect, val, err);
  }

  public void testVariable1() {
    Cell cellA1 = _sheet1.setCellEditText(0, 0, "=variable1"); //A1
    cellA1 = _sheet1.setCellEditText(0, 0, "=variable1"); //A1
  }
View Full Code Here

    Cell cellA1 = _sheet1.setCellEditText(0, 0, "=variable1"); //A1
    cellA1 = _sheet1.setCellEditText(0, 0, "=variable1"); //A1
  }

  public void testVariable2() {
    Cell cellA1 = _sheet1.setCellEditText(0, 0, "=bankAccount1"); //A1
    Cell cellB1 = _sheet1.setCellEditText(0, 1, "=bankAccount2"); //B1
    Cell cellC1 = _sheet1.setCellEditText(0, 2, "=bankAccount3"); //C1
    Cell cellD1 = _sheet1.setCellEditText(0, 3, "=SUM(A1:C1)"); //D1
    Cell cellE1 = _sheet1.setCellEditText(0, 4, "=bankAccount1 + bankAccount2 + bankAccount3"); //E1
   
    Map varmap = new HashMap();
    VariableResolver resolver = new SimpleResolver(varmap);
    _book.addVariableResolver(resolver);

    varmap.put("bankAccount1", new Double(1d));
    varmap.put("bankAccount2", new Double(10d));
    varmap.put("bankAccount3", new Double(100d));
   
    assertValue(1d, ((Number)cellA1.getResult()).doubleValue(), 0d);
    assertValue(10d, ((Number)cellB1.getResult()).doubleValue(), 0d);
    assertValue(100d, ((Number)cellC1.getResult()).doubleValue(), 0d);
    assertValue(111d, ((Number)cellD1.getResult()).doubleValue(), 0d);
    assertValue(111d, ((Number)cellE1.getResult()).doubleValue(), 0d);

    varmap.put("bankAccount1", new Double(2d));
    varmap.put("bankAccount2", new Double(20d));
    varmap.put("bankAccount3", new Double(200d));

    assertValue(2d, ((Number)cellA1.getResult()).doubleValue(), 0d);
    assertValue(20d, ((Number)cellB1.getResult()).doubleValue(), 0d);
    assertValue(200d, ((Number)cellC1.getResult()).doubleValue(), 0d);
    assertValue(222d, ((Number)cellD1.getResult()).doubleValue(), 0d);
    assertValue(222d, ((Number)cellE1.getResult()).doubleValue(), 0d);
  }
View Full Code Here

      return acc3;
    }
  }
  public void testVariable3() {
   
    Cell cellA1 = _sheet1.setCellEditText(0, 0, "=account.acc1"); //A1
    Cell cellB1 = _sheet1.setCellEditText(0, 1, "=account.acc2"); //B1
    Cell cellC1 = _sheet1.setCellEditText(0, 2, "=account.acc3"); //C1
    Cell cellD1 = _sheet1.setCellEditText(0, 3, "=SUM(A1:C1)"); //D1
    Cell cellE1 = _sheet1.setCellEditText(0, 4, "=account.acc1 + account.acc2 + account.acc3"); //E1
   
    Map varmap = new HashMap();
    VariableResolver resolver = new SimpleResolver(varmap);
    _book.addVariableResolver(resolver);

    varmap.put("account", new MyAccount());
   
    assertValue(2d, ((Number)cellA1.getResult()).doubleValue(), 0d);
    assertValue(20d, ((Number)cellB1.getResult()).doubleValue(), 0d);
    assertValue(200d, ((Number)cellC1.getResult()).doubleValue(), 0d);
    assertValue(222d, ((Number)cellD1.getResult()).doubleValue(), 0d);
    assertValue(222d, ((Number)cellE1.getResult()).doubleValue(), 0d);

  }
View Full Code Here

TOP

Related Classes of org.zkoss.zss.model.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.