Package org.zkoss.zss.model

Examples of org.zkoss.zss.model.Cell


 
  public void testFormula() {
    Sheet sheet1 = ((BookImpl)_book).addSheet("sheet1", 256, 64*1024);
    assertEquals(sheet1, _book.lookupSheet("sheet1"));
   
    Cell cell = ((SheetImpl)sheet1).setCellEditText(2,0,"="); //A3
    assertCellEquals(cell, 2, 0, "=");
  }
View Full Code Here


  private static final DateFormat TF = new SimpleDateFormat("HH:mm:ss");
  public void testGetTextHAlign() {
    Sheet sheet1 = ((BookImpl)_book).addSheet("sheet1", 256, 64*1024);
    assertEquals(sheet1, _book.lookupSheet("sheet1"));
   
    Cell cell = ((SheetImpl)sheet1).setCellEditText(2,0,"123"); //A3
    FormatImpl fm = new FormatImpl();
    cell.setFormat(fm);
    fm.setFormatCodes("0;[Red](0)");
    fm.setFontColor("#0000FF");
   
    assertEquals("#0000FF", cell.getTextColor());

    cell.setValue(new Double(1));
    assertEquals(TextHAlign.RIGHT, cell.getTextHAlign());
    cell.setValue("A String");
    assertEquals(TextHAlign.LEFT, cell.getTextHAlign());
   
    fm.setTextHAlign(TextHAlign.CENTER);
    cell.setValue(new Double(1));
    assertEquals(TextHAlign.CENTER, cell.getTextHAlign());
    cell.setValue("a string");
    assertEquals(TextHAlign.CENTER, cell.getTextHAlign());
  }
View Full Code Here

  }
  public void testGetTextColor() {
    Sheet sheet1 = ((BookImpl)_book).addSheet("sheet1", 256, 64*1024);
    assertEquals(sheet1, _book.lookupSheet("sheet1"));
   
    Cell cell = ((SheetImpl)sheet1).setCellEditText(2,0,"123"); //A3
    FormatImpl fm = new FormatImpl();
    cell.setFormat(fm);
    fm.setFormatCodes("0;[Red](0)");
    fm.setFontColor("#0000FF");
   
    assertEquals("#0000FF", cell.getTextColor());
  }
View Full Code Here

 
  public void testFormulaParms() {
    Sheet sheet1 = ((BookImpl)_book).addSheet("sheet1", 256, 64*1024);
    assertEquals(sheet1, _book.lookupSheet("sheet1"));
   
    Cell cell = ((SheetImpl)sheet1).setCellEditText(2,0,"=SUM(1,2,3)"); //A3
    assertEquals(1+2+3, ((Double)cell.getResult()).doubleValue(), 0d);
   
    cell = ((SheetImpl)sheet1).setCellEditText(2,0,"=SUM(1,,3)"); //A3
    assertEquals(1+3, ((Double)cell.getResult()).doubleValue(), 0d);

    cell = ((SheetImpl)sheet1).setCellEditText(2,0,"=SUM(1,3,)"); //A3
    assertEquals(1+3, ((Double)cell.getResult()).doubleValue(), 0d);

    cell = ((SheetImpl)sheet1).setCellEditText(2,0,"=SUM(,1,3)"); //A3
    assertEquals(1+3, ((Double)cell.getResult()).doubleValue(), 0d);
  }
View Full Code Here

      final Range rng = (Range) result;
      final Cell[][][] rngcella = rng.getCellsArray();
      final int colsz = rng.getColumnSize();
      final int rowsz = rng.getRowSize();
      if (colsz == 1 && rowsz == 1) { //single cell range
        final Cell rngcell = rngcella[0][0][0];
        if (rngcell == null) {
          result = Objects.ZERO_DOUBLE;
        } else {
          result = rngcell.getResult();
        }
      } else if (colsz > 1 && rowsz > 1) {
        result = SSError.VALUE;
      } else if (colsz == 1) {
        final int row = getRow();
        final int rngtop = rng.getTop();
        final int rngbottom = rng.getBottom();
        if (row >= rngtop && row <= rngbottom) {
          final int rowidx = row - rngtop;
          final Cell rngcell = rngcella[0][rowidx][0];
          if (rngcell == null) {
            result = Objects.ZERO_DOUBLE;
          } else {
            result = rngcell.getResult();
          }
        } else {
          result = SSError.VALUE;
        }
      } else { //rowsz == 1
        final int col = getColumn();
        final int rngleft = rng.getLeft();
        final int rngright = rng.getRight();
        if (col >= rngleft && col <= rngright) {
          final int colidx = col - rngleft;
          final Cell rngcell = rngcella[0][0][colidx];
          if (rngcell == null) {
            result = Objects.ZERO_DOUBLE;
          } else {
            result = rngcell.getResult();
          }
        } else {
          result = SSError.VALUE;
        }
      }
View Full Code Here

    return _lt == _rb ? 1 : 2;
  }
 
  public void update() {
    final Iterator it = getCells().iterator();
    final Cell cell = it.hasNext() ? (Cell) it.next() : null;
    if (cell != null) {
      ((CellImpl)cell).reset();
      final Sheet sheet = cell.getSheet();
      final BookImpl book = (BookImpl) sheet.getBook();
      book.fireSSDataEvent(this, SSDataEvent.CONTENTS_CHANGE, 0);
    }
  }
View Full Code Here

  /*
   * Export each cell from sheet
   */
  private void exportEachCell(Sheet sheet, WritableSheet workSheet, int row,
      int col) {
    Cell zkCell = sheet.getCell(row, col);
    try {
      if (zkCell != null) { // if cell is not empy, export
        workSheet.addCell(exportCell(zkCell, row, col));
      } //Else do nothing
    } catch (Exception e) {
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.