Package org.zkoss.zss.model

Examples of org.zkoss.zss.model.Cell


          for (int col = left; left <= right; ++col) {
            final CellIndex ci = ri.getCellIndexIfExists(col);
            if (ci == null) {
              dstri.detachCellIndex(col+coloffset);
            } else {
              final Cell cell = ci.getCellIfExists();
              if (cell != null) {
                final CellIndex dstci = dstri.getCellIndex(col+coloffset);
                //get cell, create if not exists
                final Cell dstcell = dstci.getCell();
                dstcell.setValue(cell.getValue());
              }
            }
          }
        }
        detach(row);
View Full Code Here


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

    Cell cell = ((SheetImpl)_sheet).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());
   
    _sheet.copyCell(cell, 3, 0); //A4
    Cell cellA4 = ((SheetImpl)_sheet).getCell(3,0); //A4
    FormatImpl fm2 = (FormatImpl) cellA4.getFormat();
   
    assertNotSame(fm, fm2);
   
    assertEquals(fm.getFormatCodes(), fm2.getFormatCodes());
    assertEquals("0;[Red](0)", fm2.getFormatCodes());
    assertEquals(fm.getFontColor(), fm2.getFontColor());
    assertEquals("#0000FF", fm2.getFontColor());
    assertEquals("#0000FF", cellA4.getTextColor());

    cellA4.setValue(new Double(1));
    assertEquals(TextHAlign.CENTER, cellA4.getTextHAlign());
    cellA4.setValue("a string");
    assertEquals(TextHAlign.CENTER, cellA4.getTextHAlign());
   
  }
View Full Code Here

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

    Cell cell = ((SheetImpl)_sheet).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());
   
    Range rng = new RangeSimple(_sheet, null, 0, 2, 0, 2); //A3
    rng.copy(new RangeSimple(_sheet, null, 0, 3, 2, 3)); //A4:C4
   
    for (int j = 0; j < 3; ++j) {
      Cell cellA4 = ((SheetImpl)_sheet).getCell(3,j); //A4 ~ C4
      FormatImpl fm2 = (FormatImpl) cellA4.getFormat();
     
      assertNotSame(fm, fm2);
     
      assertEquals(fm.getFormatCodes(), fm2.getFormatCodes());
      assertEquals("0;[Red](0)", fm2.getFormatCodes());
      assertEquals(fm.getFontColor(), fm2.getFontColor());
      assertEquals("#0000FF", fm2.getFontColor());
      assertEquals("#0000FF", cellA4.getTextColor());
 
      cellA4.setValue(new Double(1));
      assertEquals(TextHAlign.CENTER, cellA4.getTextHAlign());
      cellA4.setValue("a string");
      assertEquals(TextHAlign.CENTER, cellA4.getTextHAlign());
    }
   
  }
View Full Code Here

    if (_cell != null) {
      final Object val = _cell.getValue();
      final Format format = _cell.getFormat();
      _cell.setValue(null); //clear the value
      //get the destination cell, create one if not exist.
      final Cell dstcell = dstci.getCell();
      dstcell.setValue(val);
      ((CellImpl)dstcell).mySetFormat(format, false);
      _cell = null; // remove cell from this CellIndex (DO NOT CALL setCell(null) which will clean up Formula)
    } else {
      dstci.setCell(null);
    }
View Full Code Here

    if(list.size()<=ss.getSelectedIndex()){
      throw new XelException("No such sheet :"+ss.getSelectedIndex());
    }*/
    Sheet sheet = ss.getSelectedSheet();
   
    Cell cell = sheet.getCell(row,column);
   
    if(cell==null) return "";
   
    Object value = cell.getText();
    String txt = value==null?"":value.toString();
   
    boolean wrap = false;
    Format format = cell.getFormat();
    if(format != null && format.isTextWrap()){
      wrap = true;
    }
   
    txt = Utils.escapeCellText(txt,wrap,wrap);
View Full Code Here

        if(row>_loadedRect.getBottom() ||
          (row <_loadedRect.getTop() && row>getRowfreeze())) continue;
        if(col>_loadedRect.getRight() ||
            (col <_loadedRect.getLeft() && row>getColumnfreeze())) continue;
       
        Cell cell = sheet.getCell(row,col);
        //if(cell==null) continue;
        String text = (cell==null)?"":cell.getText();
       
       
        JSONObj result = new JSONObj();
        result.setData("r", row);
        result.setData("c", col);
        result.setData("type", "udcell");
       
        Format format = (cell==null)?null:cell.getFormat();
        boolean wrap = false;
       
        CellFormatHelper cfh = new CellFormatHelper(sheet,row,col,getMergeMatrixHelper(sheet));
        String st = cfh.getHtmlStyle();
        String ist = cfh.getInnerHtmlStyle();
        if (st != null && !"".equals(st)){
          result.setData("st", st);// style of text cell.
        }
        if (ist != null && !"".equals(ist)){
          result.setData("ist", ist);// inner style of text cell
        }
        if (format!=null && format.isTextWrap()){
          wrap = true;
          result.setData("wrap", true);
        }
        if (cfh.hasRightBorder()){
          result.setData("rbo",true);
        }
        TextHAlign textHAlign = (cell==null)?null:cell.getTextHAlign();
        if (textHAlign != null) {
          if (textHAlign.equals(TextHAlign.RIGHT)) {
            result.setData("hal","r");
          } else if (textHAlign.equals(TextHAlign.CENTER)) {
            result.setData("hal","c");
View Full Code Here

  }
 
  /*package*/ void getCells(int left, int right, List list) {
    for (final Iterator it = getCellIndexes(left, right).iterator(); it.hasNext();) {
      final CellIndex ci = (CellIndex) it.next();
      final Cell cell = ci.getCellIfExists();
      if (cell != null) {
        list.add(cell);
      }
    }
  }
View Full Code Here

  }
 
  public Cell setCellValue(int row, int col, Object value) {
    final CellIndex ci = _matrix.getCellIndex(row, col);
    //get cell, create one if not exists
    final Cell cell = ci.getCell();
    cell.setValue(value);
    return cell;
  }
View Full Code Here

  }

  public Cell setCellEditText(int row, int col, String value) {
    final CellIndex ci = _matrix.getCellIndex(row, col);
    //get cell, create one if not exists
    final Cell cell = ci.getCell();
    cell.setEditText(value);
    return cell;
  }
View Full Code Here

    return cell;
  }
 
  public Cell removeCell(int row, int col) {
    final CellIndex ci = _matrix.getCellIndexIfExists(row, col);
    final Cell old = ci == null ? null : ci.getCellIfExists();
    if (old != null) {
      //remove the merge range if a merged cell
      final RangeMerge rm = ((CellImpl)old).getRangeMerge();
      if (rm != null) {
        final Range rng = new RangeSimple(this, null, rm.getLeft(), rm.getTop(), rm.getRight(), rm.getBottom());
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.