Package org.apache.poi.ss.usermodel

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


    try {
     
      InputStream input = new FileInputStream(file);
      Workbook workbook = WorkbookFactory.create(input);
      Sheet sheet = workbook.getSheetAt(testListPosition);
      Row row = sheet.createRow(assigNumber);
     
      int lastColumn = sheet.getRow(0).getPhysicalNumberOfCells();     
      for (int cn=0; cn<lastColumn; cn++) {
        Cell cell = row.getCell(cn, Row.RETURN_BLANK_AS_NULL);
        if (cell == null) {
          cell = row.createCell(cn);
          cell.setCellType(Cell.CELL_TYPE_STRING);
          cell.setCellValue(argument[cn]);
        }
      }
     
View Full Code Here


  @Override
  public void execute() {
    final Object[] values = getValues();
    final Style[] styles = getStyles();

    final Row row = getUpdateCallback().createRow(getTable().getName());

    final Column[] columns = getColumns();
    for (int i = 0; i < columns.length; i++) {
      Object value = values[i];
      if (value != null) {
        int columnNumber = columns[i].getColumnNumber();
        Cell cell = row.createCell(columnNumber);

        // use a lazyref and the isFetched method to only create style
        // if nescesary
        LazyRef<CellStyle> cellStyle = new LazyRef<CellStyle>() {
          @Override
View Full Code Here

            // no physical rows in sheet
            return table;
        }


        Row row = null;

        if (_configuration.isSkipEmptyLines()) {
            while (row == null && rowIterator.hasNext()) {
                row = rowIterator.next();
            }
        } else {
            row = rowIterator.next();
        }

        final int columnNameLineNumber = _configuration.getColumnNameLineNumber();
        if (columnNameLineNumber == ExcelConfiguration.NO_COLUMN_NAME_LINE) {

            // get to the first non-empty line (no matter if lines are skipped
            // or not we need to read ahead to figure out how many columns there
            // are!)
            while (row == null && rowIterator.hasNext()) {
                row = rowIterator.next();
            }

            // build columns by using alphabetic sequences
            // (A,B,C...)
            AlphabeticSequence sequence = new AlphabeticSequence();

            final int offset = getColumnOffset(row);
            for (int i = 0; i < offset; i++) {
                sequence.next();
            }

            for (int j = offset; j < row.getLastCellNum(); j++) {
                Column column = new MutableColumn(sequence.next(), ColumnType.STRING, table, j, true);
                table.addColumn(column);
            }
        } else {
View Full Code Here

        final Sheet sheet = workbook.getSheet(tableName);

        final Iterator<Row> rowIterator = ExcelUtils.getRowIterator(sheet, _updateCallback.getConfiguration(), true);
        final List<Row> rowsToDelete = new ArrayList<Row>();
        while (rowIterator.hasNext()) {
            final Row excelRow = rowIterator.next();
            final DefaultRow row = ExcelUtils.createRow(workbook, excelRow, header);

            final boolean deleteRow = deleteRow(row);
            if (deleteRow) {
                rowsToDelete.add(excelRow);
View Full Code Here

        final Sheet sheet = updateCallback.createSheet(table.getName());

        final int lineNumber = updateCallback.getConfiguration().getColumnNameLineNumber();
        if (lineNumber != ExcelConfiguration.NO_COLUMN_NAME_LINE) {
            final int zeroBasedLineNumber = lineNumber - 1;
            final Row row = sheet.createRow(zeroBasedLineNumber);
            final Column[] columns = table.getColumns();
            for (int i = 0; i < columns.length; i++) {
                final Column column = columns[i];
                final int columnNumber = column.getColumnNumber();
                row.createCell(columnNumber).setCellValue(column.getName());
            }
        }

        final MutableSchema schema = (MutableSchema) table.getSchema();
        schema.addTable((MutableTable) table);
View Full Code Here

            xhtml.startElement("tbody");

            // Rows and cells
            for (Object rawR : sheet) {
                xhtml.startElement("tr");
                Row row = (Row) rawR;
                for (Iterator<Cell> ri = row.cellIterator(); ri.hasNext();) {
                    xhtml.startElement("td");
                    Cell cell = ri.next();

                    int type = cell.getCellType();
                    if (type == Cell.CELL_TYPE_FORMULA) {
View Full Code Here

        );
      }

      // Rows and cells
      for (Object rawR : sheet) {
        Row row = (Row)rawR;
        for(Iterator<Cell> ri = row.cellIterator(); ri.hasNext();) {
          Cell cell = ri.next();
         
          // Is it a formula one?
          if(cell.getCellType() == Cell.CELL_TYPE_FORMULA && formulasNotResults) {
            text.append(cell.getCellFormula());
View Full Code Here

   
    assertTrue( ((XSSFSheet)sheet1).hasComments() );
    assertFalse( ((XSSFSheet)sheet2).hasComments() );
   
    // Comments should be in C5 and C7
    Row r5 = sheet1.getRow(4);
    Row r7 = sheet1.getRow(6);
    assertNotNull( r5.getCell(2).getCellComment() );
    assertNotNull( r7.getCell(2).getCellComment() );
   
    // Check they have what we expect
    // TODO: Rich text formatting
    Comment cc5 = r5.getCell(2).getCellComment();
    Comment cc7 = r7.getCell(2).getCellComment();
   
    assertEquals("Nick Burch", cc5.getAuthor());
    assertEquals("Nick Burch:\nThis is a comment", cc5.getString().getString());
    assertEquals(4, cc5.getRow());
    assertEquals(2, cc5.getColumn());
View Full Code Here

    assertTrue( ((XSSFSheet)sheet1).hasComments() );
    assertFalse( ((XSSFSheet)sheet2).hasComments() );
   
    // Change on comment on sheet 1, and add another into
    //  sheet 2
    Row r5 = sheet1.getRow(4);
    Comment cc5 = r5.getCell(2).getCellComment();
    cc5.setAuthor("Apache POI");
    cc5.setString(new XSSFRichTextString("Hello!"));
   
    Row r2s2 = sheet2.createRow(2);
    Cell c1r2s2 = r2s2.createCell(1);
    assertNull(c1r2s2.getCellComment());
   
    Comment cc2 = sheet2.createComment();
    cc2.setAuthor("Also POI");
    cc2.setString(new XSSFRichTextString("A new comment"));
View Full Code Here

            xhtml.startElement("tbody");

            // Rows and cells
            for (Object rawR : sheet) {
                xhtml.startElement("tr");
                Row row = (Row) rawR;
                for (Iterator<Cell> ri = row.cellIterator(); ri.hasNext();) {
                    xhtml.startElement("td");
                    Cell cell = ri.next();

                    int type = cell.getCellType();
                    if (type == Cell.CELL_TYPE_FORMULA) {
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.usermodel.Row

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.