Package org.apache.poi.ss.usermodel

Examples of org.apache.poi.ss.usermodel.Cell


    for (int spannedRow = 0; spannedRow < rowSpan; spannedRow += 1)
    {
      for (int spannedCol = 0; spannedCol < columnSpan; spannedCol += 1)
      {
        final Cell regionCell = getCellAt((col + spannedCol), row + spannedRow);
        if (spannedStyle != null)
        {
          regionCell.setCellStyle(spannedStyle);
        }
      }
    }
  }
View Full Code Here


            Row row = sheet.getRow( i );
            int lastCellNum = row != null ? row.getLastCellNum() : 0;
            newRow( listeners, i, lastCellNum );

            for ( int cellNum = 0; cellNum < lastCellNum; cellNum++ ) {
                Cell cell = row.getCell( cellNum );
                if ( cell == null ) {
                    continue;
                }
                double num = 0;

                CellRangeAddress merged = getRangeIfMerged( cell,
                                                            mergedRanges );

                int mergedColStart = DataListener.NON_MERGED;
                if ( merged != null ) {
                    cell = sheet.getRow(merged.getFirstRow()).getCell(merged.getFirstColumn());
                    mergedColStart = cell.getColumnIndex();
                }

                switch ( cell.getCellType() ) {
                    case Cell.CELL_TYPE_FORMULA:
                        String cellValue = null;
                        try {
                            newCell(listeners,
                                    i,
                                    cellNum,
                                    formatter.formatCellValue(cell, formulaEvaluator),
                                    mergedColStart);
                        } catch (RuntimeException e) {
                            // This is thrown if an external link cannot be resolved, so try the cached value
                            log.warn("Cannot resolve externally linked value: " + formatter.formatCellValue(cell));
                            String cachedValue = tryToReadCachedValue(cell);
                            newCell(listeners,
                                    i,
                                    cellNum,
                                    cachedValue,
                                    mergedColStart);
                        }
                        break;
                    case Cell.CELL_TYPE_NUMERIC:
                        num = cell.getNumericCellValue();
                    default:
                        if (num - Math.round(num) != 0) {
                            newCell(listeners,
                                    i,
                                    cellNum,
View Full Code Here

            Iterator<Cell> cellIt = row.cellIterator();
           
            fields = new LinkedHashMap();
           
            while( cellIt.hasNext() ) {
                Cell currCell = cellIt.next();
               
                // Ignore any non-string cells (because they are not suitable as headers)
                if( currCell.getCellType() != Cell.CELL_TYPE_STRING ) continue;

                LinkedHashMap fieldInfo = new LinkedHashMap();
                fieldInfo.put( "name", currCell.getStringCellValue() );
                fieldInfo.put( "subfields", null );

                fields.put( currCell.getStringCellValue(), fieldInfo );
            }
           
        }
        catch( Exception e ) {
            e.printStackTrace();
View Full Code Here

        this.readBook = new XSSFWorkbook( new FileInputStream( this.operateFile ) );
        this.readSheet = this.readBook.getSheetAt( 0 );
       
        Iterator<Cell> cellIt = this.readSheet.getRow( 0 ).cellIterator();
        while( cellIt.hasNext() ) {
            Cell currCell = cellIt.next();
           
            if( currCell.getCellType() != Cell.CELL_TYPE_STRING ) continue;
           
            this.fieldNames.put( currCell.getStringCellValue(), currCell.getColumnIndex() );
        }
       
        this.currRow = 1;
    }
View Full Code Here

   *@param row The row that the cell is part of
   *@param columnIndex The column index that the cell is in.
   *@return The cell indicated by the column.
   */
  public static Cell getCell(Row row, int columnIndex) {
    Cell cell = row.getCell(columnIndex);

    if (cell == null) {
      cell = row.createCell(columnIndex);
    }
    return cell;
View Full Code Here

   * @param  value   The value of the cell
   * @param  style   If the style is not null, then set
   * @return         A new Cell
   */
  public static Cell createCell(Row row, int column, String value, CellStyle style) {
    Cell cell = getCell(row, column);

    cell.setCellValue(cell.getRow().getSheet().getWorkbook().getCreationHelper()
        .createRichTextString(value));
    if (style != null) {
      cell.setCellStyle(style);
    }
    return cell;
  }
View Full Code Here

     
      //
      int cellIndex = 0;
      for ( String iCellText : iLine )
      {
        Cell cell = row.createCell( cellIndex++ );
        cell.setCellValue( createHelper.createRichTextString( iCellText ) );
      }
    }
   
    try
    {
View Full Code Here

      for (Iterator<Row> rit = sheet.rowIterator(); rit.hasNext();) {
        Row r = rit.next();

        for (Iterator<Cell> cit = r.cellIterator(); cit.hasNext();) {
          Cell c = cit.next();
          if (c.getCellType() == HSSFCell.CELL_TYPE_FORMULA)
            evaluator.evaluateFormulaCell(c);
        }
      }
    }
  }
View Full Code Here

      // create 5x the amound of rows as the streaming sheet will hold in
      // memory
      for (int i = 0; i < windowSize * 5; i++) {
        Row row = sheet.createRow(i);
        Cell cell = row.createCell(0);
        cell.setCellValue("value" + i);

        assertTrue(rows.size() <= 1000);
      }

      assertEquals(1000, rows.size());
View Full Code Here

     */
    public void test49524() throws Exception {
       HSSFWorkbook wb = openSample("49524.xls");
       Sheet s = wb.getSheetAt(0);
       Row r = s.getRow(0);
       Cell rotated = r.getCell(0);
       Cell normal = r.getCell(1);
      
       // Check the current ones
       assertEquals(0, normal.getCellStyle().getRotation());
       assertEquals(0xff, rotated.getCellStyle().getRotation());
      
       // Add a new style, also rotated
       CellStyle cs = wb.createCellStyle();
       cs.setRotation((short)0xff);
       Cell nc = r.createCell(2);
       nc.setCellValue("New Rotated Text");
       nc.setCellStyle(cs);
       assertEquals(0xff, nc.getCellStyle().getRotation());
      
       // Write out and read back
       wb = writeOutAndReadBack(wb);
      
       // Re-check
       s = wb.getSheetAt(0);
       r = s.getRow(0);
       rotated = r.getCell(0);
       normal = r.getCell(1);
       nc = r.getCell(2);
      
       assertEquals(0, normal.getCellStyle().getRotation());
       assertEquals(0xff, rotated.getCellStyle().getRotation());
       assertEquals(0xff, nc.getCellStyle().getRotation());
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.usermodel.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.