Package org.zkoss.zss.model

Examples of org.zkoss.zss.model.Cell


      cs = 1;
    }
     
    for(int r = rb; r != re; r += rs) {
      for(int c = cb; c != ce; c += cs) {
        final Cell srcCell = srcSheet.getCell((r % srcRowSize) + srcTop, (c % srcColSize) + srcLeft);
        final int dstr = r+dstTop;
        final int dstc = c+dstLeft;
        if (srcCell == null) {
          dstSheet.removeCell(dstr, dstc);
        } else {
View Full Code Here


    } else if (arg instanceof Range) { // a range, iterator thru available 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();
        toListHelper(result, cell.getResult(), skipBoolean, skipText, (XelContext) book); // recursive
      }
    } else if (arg instanceof Range[]) { //a range array, iterator thru available ranges
      for (int j = 0; j < ((Range[])arg).length; ++j) {
        final Range rng = (Range) ((Range[])arg)[j];
        final Book book = rng.getSheet().getBook();
View Full Code Here

      final int colsz = cella[0][0].length;
      final double[][] vala = new double[rowsz][];
      for (int rj = 0; rj < colsz; ++rj) {
        vala[rj] = new double[colsz];
        for (int cj = 0; cj < colsz; ++cj) {
          final Cell cell = cella[0][rj][cj];
          double num = 0d;
          if (cell != null) {
            final Object val = cell.getResult();
            if (val instanceof SSError) {
              throw new SSErrorXelException((SSError)val);
            } else if (val instanceof Number) {
              num = ((Number)val).doubleValue();
            }
View Full Code Here

      } else if (_subtype == TokenSubtype.ERROR) {
        throw new SSErrorXelException(SSError.valueOf((String)_value));
      } else if (_subtype == TokenSubtype.CELL) { //refer to a cell
        final Range rng = (Range) _value;
        final Iterator it = rng.getCells().iterator();
        final Cell cell = it.hasNext() ? (Cell) it.next() : null;
        return cell != null ? cell.getResult() : null;
      } else if (_subtype == TokenSubtype.RANGE) { //refer to a range
        return (Range) _value;
      } else if (_subtype == TokenSubtype.VAR) { //refer to a variable
        final VariableResolver resolver = ctx.getVariableResolver();
/*        final Reference ref =
View Full Code Here

      } else if (_subtype == TokenSubtype.ERROR) {
        sb.append(_value);
      } else if (_subtype == TokenSubtype.CELL) { //refer to a cell
        final Range rng = (Range) _value;
        final Iterator it = rng.getCells().iterator();
        final Cell cell = it.hasNext() ? (Cell) it.next() : null;
        sb.append(getCellPrintString(cell, rng.isTopAbsolute(), rng.isLeftAbsolute(), ctx));
      } else if (_subtype == TokenSubtype.RANGE) { //refer to a range
        sb.append(getRangePrintString((Range) _value, ctx));
      } else if (_subtype == TokenSubtype.VAR) { //refer to a variable
        sb.append(_value);
View Full Code Here

  public void testInfoFunctions() {
    Sheet sheet1 = ((BookImpl)_book).addSheet("sheet1", 256, 64*1024);
    assertEquals(sheet1, _book.lookupSheet("sheet1"));
   
    //ISERROR and ISERR
    Cell cellA1 = ((SheetImpl)sheet1).setCellEditText(0,0,"#N/A"); //A1
    assertEquals(SSError.NA, cellA1.getResult());

    Cell cellA2 = ((SheetImpl)sheet1).setCellEditText(1,0,"=ISERROR(A1)"); //A2
    assertEquals(Boolean.TRUE, cellA2.getResult());

    ((SheetImpl)sheet1).setCellEditText(1,0,"=ISERR(A1)"); //A2
    assertEquals(Boolean.FALSE, cellA2.getResult());

    ((SheetImpl)sheet1).setCellEditText(0,0,"=1/0"); //A1
    assertEquals(SSError.DIV0, cellA1.getResult());

    ((SheetImpl)sheet1).setCellEditText(1,0,"=ISERROR(A1)"); //A2
    assertEquals(Boolean.TRUE, cellA2.getResult());

    ((SheetImpl)sheet1).setCellEditText(1,0,"=ISERR(A1)"); //A2
    assertEquals(Boolean.TRUE, cellA2.getResult());

    ((SheetImpl)sheet1).setCellEditText(0,0,"#REF!");
    assertEquals(SSError.REF, cellA1.getResult());
   
    ((SheetImpl)sheet1).setCellEditText(1,0,"=ISERROR(A1)"); //A2
    assertEquals(Boolean.TRUE, cellA2.getResult());

    ((SheetImpl)sheet1).setCellEditText(1,0,"=ISERR(A1)"); //A2
    assertEquals(Boolean.TRUE, cellA2.getResult());

    ((SheetImpl)sheet1).setCellEditText(0,0,"=sheet2!A1");
    assertEquals(SSError.REF, cellA1.getResult());
   
    ((SheetImpl)sheet1).setCellEditText(1,0,"=ISERROR(A1)"); //A2
    assertEquals(Boolean.TRUE, cellA2.getResult());

    ((SheetImpl)sheet1).setCellEditText(1,0,"=ISERR(A1)"); //A2
    assertEquals(Boolean.TRUE, cellA2.getResult());
   
    ((SheetImpl)sheet1).setCellEditText(1,0,"=ISERROR(Sheet2!A1)"); //A2
    assertEquals(Boolean.TRUE, cellA2.getResult());
   
    /*    ((SheetImpl)sheet1).setCellEditText(0,0,"#NAME?");
    assertEquals(SSError.NAME, cellA1.getResult());

    ((SheetImpl)sheet1).setCellEditText(0,0,"#NUM!");
View Full Code Here

 
  public void testSumproduct() {
    Sheet sheet1 = ((BookImpl)_book).addSheet("sheet1", 256, 64*1024);
    assertEquals(sheet1, _book.lookupSheet("sheet1"));

    Cell cellA1 = ((SheetImpl)sheet1).setCellEditText(0,0,"1"); //A1
    Cell cellA2 = ((SheetImpl)sheet1).setCellEditText(1,0,"2"); //A2
    Cell cellA3 = ((SheetImpl)sheet1).setCellEditText(2,0,"3"); //A3
    Cell cellA4 = ((SheetImpl)sheet1).setCellEditText(3,0,"4"); //A4
   
    Cell cellB1 = ((SheetImpl)sheet1).setCellEditText(0,1,"5"); //B1
    Cell cellB2 = ((SheetImpl)sheet1).setCellEditText(1,1,"6"); //B2
    Cell cellB3 = ((SheetImpl)sheet1).setCellEditText(2,1,"7"); //B3
    Cell cellB4 = ((SheetImpl)sheet1).setCellEditText(3,1,"8"); //B4
   
    Cell cellC1 = ((SheetImpl)sheet1).setCellEditText(0,2,"=SUMPRODUCT(A1:B2,A3:B4)"); //C1
    assertEquals(1d*3+2*4+5*7+6*8, ((Number)cellC1.getResult()).doubleValue(), 0d);
   
    ((SheetImpl)sheet1).setCellEditText(0,2,"=SUMPRODUCT({1,3;7,2}, {2,0;0,2})");//C1
    assertEquals(6d, ((Number)cellC1.getResult()).doubleValue(), 0d);
  }
View Full Code Here

  public void testDouble15() {
    Sheet sheet1 = ((BookImpl)_book).addSheet("sheet1", 6, 6);
    assertEquals(sheet1, _book.lookupSheet("sheet1"));
   
    ((SheetImpl)sheet1).setCellValue(5,5, new FormulaImpl("=761.6+2732+20836.1+7262+48.1-10.3")); //F6
    final Cell cell = sheet1.getCell(5,5);
    final Object result = cell.getResult(); //F6
    assertEquals(31629.5d, ((Double)result).doubleValue(), 0d);
  }
View Full Code Here

  public void testCell2() {
    Sheet sheet1 = ((BookImpl)_book).addSheet("sheet1", 6, 6);
    assertEquals(sheet1, _book.lookupSheet("sheet1"));
   
    ((SheetImpl)sheet1).setCellValue(5,5, new FormulaImpl("=SUM(A1:E6)")); //F6
    final Cell cell = sheet1.getCell(5,5);
   
    ((SheetImpl)sheet1).setCellValue(0,1,new Integer(1)); //B1
    assertCellEquals(sheet1.getCell(0, 1), 0, 1, new Integer(1));

    ((SheetImpl)sheet1).setCellValue(0,2,new Integer(2)); //C1
    assertCellEquals(sheet1.getCell(0, 2), 0, 2, new Integer(2));
   
    ((SheetImpl)sheet1).setCellValue(0,3,new Integer(3)); //D1
    assertCellEquals(sheet1.getCell(0, 3), 0, 3, new Integer(3));

    final Object result = cell.getResult(); //F6
    assertEquals(6d, ((Double)result).doubleValue(), 0d);
   
    //test RefCell and Function
    final SimpleSSDataListener ssl = new SimpleSSDataListener();
    _book.addSSDataListener(ssl);
View Full Code Here

   
    int[][] cells = new int[][]{{1,1},{2,1},{3,1},{4,1},{5,1},{6,1}};
    String[] colors = new String[]{"#CC0000","#CC9900","#008000","#006699","#3333FF","#FF00FF",};
   
   
    Cell cell;
    Format format;
    String color;
    for(int i=0;i<cells.length;i++){
      cell = sheet1.getCell(cells[i][0],cells[i][1]);
      assertNotNull(cell);
      format = cell.getFormat();
      assertNotNull(format);
      color = format.getFillColor();
      assertNotNull(color);
      assertEquals(colors[i],color.toUpperCase());
    }
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.