Package jxl

Examples of jxl.Cell


    Range getRangeIfMerged(Cell cell,
                           Range[] mergedRanges) {
        for ( int i = 0; i < mergedRanges.length; i++ ) {
            Range r = mergedRanges[i];
            Cell topLeft = r.getTopLeft();
            Cell bottomRight = r.getBottomRight();
            if ( cell.getRow() >= topLeft.getRow() && cell.getRow() <= bottomRight.getRow() && cell.getColumn() >= topLeft.getColumn() && cell.getColumn() <= bottomRight.getColumn() ) {
                return r;
            }
        }
        return null;
    }
View Full Code Here


            Cell[] row = sheet.getRow( i );
            newRow( listeners,
                    i,
                    row.length );
            for ( int cellNum = 0; cellNum < row.length; cellNum++ ) {
                Cell cell = row[cellNum];
                double num = 0;

                Range merged = getRangeIfMerged( cell,
                                                 mergedRanges );

                if ( merged != null ) {
                    Cell topLeft = merged.getTopLeft();
                    newCell( listeners,
                             i,
                             cellNum,
                             topLeft.getContents(),
                             topLeft.getColumn() );                   
                } else {
                  if (cell.getType() == CellType.NUMBER) {
                    NumberCell nc = (NumberCell) cell;
                    num = nc.getValue();
                  }                 
View Full Code Here

    Range getRangeIfMerged(Cell cell,
                           Range[] mergedRanges) {
        for ( int i = 0; i < mergedRanges.length; i++ ) {
            Range r = mergedRanges[i];
            Cell topLeft = r.getTopLeft();
            Cell bottomRight = r.getBottomRight();
            if ( cell.getRow() >= topLeft.getRow() && cell.getRow() <= bottomRight.getRow() && cell.getColumn() >= topLeft.getColumn() && cell.getColumn() <= bottomRight.getColumn() ) {
                return r;
            }
        }
        return null;
    }
View Full Code Here

        bw.write(s.getName());
        bw.newLine();
     
        Cell[] row = null;
        Cell c = null;
     
        for (int i = 0 ; i < s.getRows() ; i++)
        {
          row = s.getRow(i);

          for (int j = 0; j < row.length; j++)
          {
            c = row[j];
            if (c.getType() == CellType.NUMBER_FORMULA ||
                c.getType() == CellType.STRING_FORMULA ||
                c.getType() == CellType.BOOLEAN_FORMULA ||
                c.getType() == CellType.DATE_FORMULA ||
                c.getType() == CellType.FORMULA_ERROR)
            {
              FormulaCell nfc = (FormulaCell) c;
              StringBuffer sb = new StringBuffer();
              CellReferenceHelper.getCellReference
                 (c.getColumn(), c.getRow(), sb);

              try
              {
                bw.write("Formula in "  + sb.toString() +
                         " value:  " + c.getContents());
                bw.flush();
                bw.write(" formula: " + nfc.getFormula());
                bw.flush();
                bw.newLine();
              }
View Full Code Here

                       int firstRow,
                       int lastCol, 
                       int lastRow,
                       boolean reverse)
  {
    Cell cell = null;
    boolean found = false;
   
    int numCols = lastCol - firstCol;
    int numRows = lastRow - firstRow;

    int row1 = reverse ? lastRow : firstRow;
    int row2 = reverse ? firstRow : lastRow;
    int col1 = reverse ? lastCol : firstCol;
    int col2 = reverse ? firstCol : lastCol;
    int inc = reverse ? -1 : 1;

    for (int i = 0; i <= numCols && found == false; i++)
    {
      for (int j = 0; j <= numRows && found == false; j++)
      {
        int curCol = col1 + i * inc;
        int curRow = row1 + j * inc;
        if (curCol < sheet.getColumns() && curRow <  sheet.getRows())
        {
          Cell c = sheet.getCell(curCol, curRow);
          if (c.getType() != CellType.EMPTY)
          {
            if (c.getContents().equals(contents))
            {
              cell = c;
              found = true;
            }
          }
View Full Code Here

   * @param contents the string to match
   * @return the Cell whose contents match the parameter, null if not found
   */
  public Cell findCell(String contents)
  {
    Cell cell = null;
    boolean found = false;
   
    for (int i = 0 ; i < sheet.getRows() && found == false; i++)
    {
      Cell[] row = sheet.getRow(i);
View Full Code Here

                       int firstRow,
                       int lastCol,
                       int lastRow, 
                       boolean reverse)
  {
    Cell cell = null;
    boolean found = false;
   
    int numCols = lastCol - firstCol;
    int numRows = lastRow - firstRow;

    int row1 = reverse ? lastRow : firstRow;
    int row2 = reverse ? firstRow : lastRow;
    int col1 = reverse ? lastCol : firstCol;
    int col2 = reverse ? firstCol : lastCol;
    int inc = reverse ? -1 : 1;

    for (int i = 0; i <= numCols && found == false; i++)
    {
      for (int j = 0; j <= numRows && found == false; j++)
      {
        int curCol = col1 + i * inc;
        int curRow = row1 + j * inc;
        if (curCol < sheet.getColumns() && curRow <  sheet.getRows())
        {
          Cell c = sheet.getCell(curCol, curRow);
          if (c.getType() != CellType.EMPTY)
          {
            Matcher m = pattern.matcher(c.getContents());
            if (m.matches())
            {
              cell = c;
              found = true;
            }
View Full Code Here

        bw.write(s.getName());
        bw.newLine();
     
        Cell[] row = null;
        Cell c = null;
     
        for (int i = 0 ; i < s.getRows() ; i++)
        {
          row = s.getRow(i);

          for (int j = 0; j < row.length; j++)
          {
            c = row[j];
            if (c.getCellFeatures() != null)
            {
              CellFeatures features = c.getCellFeatures();
              StringBuffer sb = new StringBuffer();
              CellReferenceHelper.getCellReference
                 (c.getColumn(), c.getRow(), sb);

              bw.write("Cell "  + sb.toString() +
                       " contents:  " + c.getContents());
              bw.flush();
              bw.write(" comment: " + features.getComment());
              bw.flush();
              bw.newLine();
            }
View Full Code Here

   */
  private static void findTest(Workbook w)
  {
    logger.info("Find test");

    Cell c = w.findCellByName("named1");
    if (c != null)
    {
      logger.info("named1 contents:  " + c.getContents());
    }

    c = w.findCellByName("named2");
    if (c != null)
    {
      logger.info("named2 contents:  " + c.getContents());
    }

    c = w.findCellByName("namedrange");
    if (c != null)
    {
      logger.info("named2 contents:  " + c.getContents());
    }

    Range[] range = w.findByName("namedrange");
    if (range != null)
    {
      c = range[0].getTopLeft();
      logger.info("namedrange top left contents:  " + c.getContents());

      c = range[0].getBottomRight();
      logger.info("namedrange bottom right contents:  " + c.getContents());
    }

    range = w.findByName("nonadjacentrange");
    if (range != null)
    {
      for (int i = 0; i < range.length; i++)
      {
        c = range[i].getTopLeft();
        logger.info("nonadjacent top left contents:  " + c.getContents());
       
        c = range[i].getBottomRight();
        logger.info("nonadjacent bottom right contents:  " + c.getContents());
      }
    }

    range = w.findByName("horizontalnonadjacentrange");
    if (range != null)
    {
      for (int i = 0; i < range.length; i++)
      {
        c = range[i].getTopLeft();
        logger.info("horizontalnonadjacent top left contents:  " +
                           c.getContents());
       
        c = range[i].getBottomRight();
        logger.info("horizontalnonadjacent bottom right contents:  " +
                 c.getContents());
      }
    }

  }
View Full Code Here

        Cell[] headerCells = sheet.getRow(0);

        StructModel s = new StructModel("A");

        for (int i = 0; i < headerCells.length; i++) {
            Cell headerCell = headerCells[i];

            s.append(new StringModel("", headerCell.getContents()));
        }

        ArrayModel arr = new ArrayModel(s.getFullFieldName());

        int rows = sheet.getRows();

        for (int i = 1; i < rows; ++i) {
            Cell[] cells = sheet.getRow(i);

            s = new StructModel("A");

            for (int j = 0; j < cells.length; j++) {
                Cell cell = cells[j];

                s.append(new StringModel(cell.getContents(), headerCells[j].getContents()));
            }

            arr.append(s);
        }
View Full Code Here

TOP

Related Classes of jxl.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.