Package org.zkoss.zss.model

Examples of org.zkoss.zss.model.Cell


    boolean hitRight = false;
    MergedRect rect=null;
    boolean hitMerge = false;
    //find right border of target cell
    if (_cell != null) {
      Cell right = _cell;
      rect = _mmHelper.getMergeRange(_row, _col);
      if(rect!=null){
        hitMerge = true;
        right = _sheet.getCell(_row,rect.getRight());
      }
      Format format = right.getFormat();
      if (format != null){
        BorderStyle bb = format.getBorderRight();
        if (bb != null) {
          hitRight = appendBorderStyle(sb, "right", bb);
        }
      }
    }

    Cell next = null;
    //if no border for target cell,then check is this cell in a merge range
    //if(true) then try to get next cell after this merge range
    //else get next cell of this cell
    if(!hitRight){
      int c = hitMerge?rect.getRight()+1:_col+1;
      next = _sheet.getCell(_row,c);
      //find the right cell of merge range.
      if(next!=null){
        Format format = next.getFormat();
        if (format != null){
          BorderStyle bb = format.getBorderLeft();//get left here
          if (bb != null) {
            hitRight = appendBorderStyle(sb, "right", bb);
          }
        }
      }
    }

    //border depends on next cell's background color
    if(!hitRight && next !=null){
      Format format = next.getFormat();
      if (format != null){
        String bgColor = format.getFillColor();
        if (AUTO_COLOR.equals(bgColor)) {
          bgColor = null;
        }
View Full Code Here


      StringBuffer sb = new StringBuffer();
      Sheet sheet = getSelectedSheet();
      MergeMatrixHelper matrix = getMergeMatrixHelper(sheet);
      HeaderPositionHelper rowHelper = Spreadsheet.this.getRowPositionHelper(sheet);
      HeaderPositionHelper colHelper = Spreadsheet.this.getColumnPositionHelper(sheet);
      Cell cell = sheet.getCell(row,col);
     
     
      //class="zscell zscw${cstatus.index} zsrhi${rstatus.index} ${s:getCellSClass(self,rstatus.index,cstatus.index)}"
      sb.append("class=\"zscell");
      int zsh = -1;
      int zsw = -1;
      int[] meta = colHelper.getMeta(col);
      if(meta!=null){
        zsw = meta[2];
        sb.append(" zsw").append(zsw);
      }
      meta = rowHelper.getMeta(row);
      if(meta!=null){
        zsh = meta[2];
        sb.append(" zshi").append(zsh);
      }
      appendMergeSClass(sb,row,col);
      sb.append("\" ");
     
     
     
      CellFormatHelper cfh = new CellFormatHelper(sheet,row,col,getMergeMatrixHelper(sheet));
      HTMLs.appendAttribute(sb, "style", cfh.getHtmlStyle());
     
      HTMLs.appendAttribute(sb, "z.r",row);
      HTMLs.appendAttribute(sb, "z.c", col);
      if(zsw>=0){
        HTMLs.appendAttribute(sb, "z.zsw",zsw);
      }
      if(zsh>=0){
        HTMLs.appendAttribute(sb, "z.zsh",zsh);
      }
       
     
      if(cell!=null){
        Format format = cell.getFormat();
        if(format != null && format.isTextWrap()){
          HTMLs.appendAttribute(sb, "z.wrap", "t");
        }
       
        TextHAlign textHAlign = cell.getTextHAlign();
        if (textHAlign != null) {
          if (textHAlign.equals(TextHAlign.RIGHT)) {
            HTMLs.appendAttribute(sb, "z.hal", "r");
          } else if (textHAlign.equals(TextHAlign.CENTER)) {
            HTMLs.appendAttribute(sb, "z.hal", "c");
View Full Code Here

      return sb.toString();
    }
   
    public String getCellInnerAttrs(int row,int col){
      Sheet sheet = getSelectedSheet();
      Cell cell = sheet.getCell(row,col);
      StringBuffer sb = new StringBuffer();
      HeaderPositionHelper rowHelper = Spreadsheet.this.getRowPositionHelper(sheet);
      HeaderPositionHelper colHelper = Spreadsheet.this.getColumnPositionHelper(sheet);
     
      //class="zscelltxt zscwi${cstatus.index} zsrhi${rstatus.index}"
View Full Code Here

    System.out.println("names="+Objects.toString(names));
    Sheet sheet = (Sheet) book.getSheets().get(0);

    //test single column range
    for (int j = 1; j < 8; ++j) { //A1 ~ A7
      Cell cell = sheet.getCell(j-1,0);
      assertEquals(""+j, cell.getText());
    }
    {
      Cell cell = sheet.getCell(7,0); //A8
      assertEquals("#VALUE!", cell.getText());
    }

    //test single row range
    for (int j = 1; j < 7; ++j) { //A9 ~ F9
      Cell cell = sheet.getCell(8, j-1);
      assertEquals(""+(j*10), cell.getText());
    }
    {
      Cell cell = sheet.getCell(8,6); //G9
      assertEquals("#VALUE!", cell.getText());
    }
   
    //test multiple row and column range
    {
      Cell cell = sheet.getCell(11,0); //A12
      assertEquals("#VALUE!", cell.getText());
    }
   
    //test single cell range
    {
      Cell cell = sheet.getCell(12,0); //A13
      assertEquals("100", cell.getText());
    }
  }
View Full Code Here

    Book book = new ExcelImporter().imports(getClass().getResource("/"+nm));
    Sheet sheet1 = (Sheet) book.getSheets().get(0);
    assertEquals("#ff0000", ((SheetImpl)sheet1).getCell(1, 2).getFormat().getFontColor()); //C2
    assertEquals("#ff0000", ((SheetImpl)sheet1).getCell(1, 2).getTextColor()); //C2
   
    final Cell cell = sheet1.getCell(1,2);
    FormatImpl newFormat;
    try {
      newFormat = (FormatImpl) ((FormatImpl) cell.getFormat()).clone();
      newFormat.setFontColor("green");
      cell.setFormat( newFormat );
      assertEquals("green", ((SheetImpl)sheet1).getCell(1, 2).getFormat().getFontColor()); //C2
      assertEquals("green", ((SheetImpl)sheet1).getCell(1, 2).getTextColor()); //C2
    } catch (CloneNotSupportedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here

 
  public void test1991731() {
    BookImpl book = new BookImpl("Book1");
    SheetImpl sheet1 = (SheetImpl)((BookImpl)book).addSheet("sheet1", 256, 64*1024);
    assertEquals(sheet1, book.lookupSheet("sheet1"));
    Cell cell = ((SheetImpl)sheet1).setCellEditText(2,0,"=SUM(A1:B2)"); //A3
    assertEquals("=SUM(A1:B2)", cell.getEditText());
    cell = ((SheetImpl)sheet1).setCellEditText(2,0,"=SUM(A2:B1)"); //A3
    assertEquals("=SUM(A1:B2)", cell.getEditText());
    ((SheetImpl)sheet1).setCellEditText(2,0,"=SUM(B1:A2)"); //A3
    assertEquals("=SUM(A1:B2)", cell.getEditText());
    ((SheetImpl)sheet1).setCellEditText(2,0,"=SUM(B2:A1)"); //A3
    assertEquals("=SUM(A1:B2)", cell.getEditText());
  }
View Full Code Here

   
    final SimpleSSDataListener ssl = new SimpleSSDataListener();
    _book.addSSDataListener(ssl);
   
    _sheet.mergeCells(1, 2, 3, 4); //B3:D5
    Cell cell = _sheet.getCell(2, 1);
    assertEquals("50", cell.getText());
    assertTrue(cell.isMerged());
   
    for(Iterator it = ssl.getList().iterator(); it.hasNext();) {
      System.out.println("testMergeCell2:"+it.next());
    }
View Full Code Here

   
    final SimpleSSDataListener ssl = new SimpleSSDataListener();
    _book.addSSDataListener(ssl);
   
    _sheet.mergeCells(1, 2, 3, 4); //B3:D5
    Cell cell = _sheet.getCell(2, 1);
    assertEquals("50", cell.getText());
    assertTrue(cell.isMerged());
   
    for(Iterator it = ssl.getList().iterator(); it.hasNext();) {
      System.out.println("testMergeCell3:"+it.next());
    }
View Full Code Here

   
    final SimpleSSDataListener ssl = new SimpleSSDataListener();
    _book.addSSDataListener(ssl);
   
    _sheet.mergeCells(1, 2, 3, 4); //B3:D5
    Cell cell = _sheet.getCell(2, 1);
    assertEquals("50", cell.getText());
    assertTrue(cell.isMerged());

    assertEquals(fml, _sheet.getCell(0, 0).getValue());
    assertEquals("50", _sheet.getCell(0, 0).getText());
    assertEquals("=B3", _sheet.getCell(0, 0).getEditText());
View Full Code Here

    } else if (arg instanceof Range) { // a range, iterator thru available
                      // cells
      final Range rng = (Range) arg;
      final Collection cells = rng.getCells();
      for(final Iterator it = cells.iterator(); it.hasNext();) {
        final Cell cell = (Cell) it.next();
        total = addsq(total, cell.getResult(), (XelContext) cell); // recursive
      }
      return total;
    } else if (arg == null) {
      return total;
    } else {
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.