Package org.apache.poi.ss.usermodel

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


        return getCell(sheet, item.getRowIndex() + rowOffset, item.getColumnIndex() + columnOffset);
    }

    private Cell getCell(Sheet sheet, int rowIndex, int columnIndex) {
        assert sheet != null;
        Row row = sheet.getRow(rowIndex);
        if (row == null) {
            row = sheet.createRow(rowIndex);
        }
        Cell cell = row.getCell(columnIndex, Row.CREATE_NULL_AS_BLANK);
        return cell;
    }
View Full Code Here


        InputStream in = new FileInputStream(file);
        try {
            Workbook workbook = Util.openWorkbookFor(file.getPath(), in);
            Sheet sheet = workbook.getSheetAt(0);
            Row title = sheet.getRow(0);
            assertThat(title.getLastCellNum(), is((short) 256));

            Row content = sheet.getRow(1);
            for (int i = 0; i < title.getLastCellNum(); i++) {
                assertThat(content.getCell(i).getNumericCellValue(), is((double) (Integer) value[i]));
            }
        } finally {
            in.close();
        }
    }
View Full Code Here

     * @param rowIndex row index
     * @param columnIndex column index
     * @return cell string
     */
    protected String cell(Sheet sheet, int rowIndex, int columnIndex) {
        Row row = sheet.getRow(rowIndex);
        assertThat(row, not(nullValue()));
        Cell cell = row.getCell(columnIndex);
        if (cell == null || cell.getCellType() == Cell.CELL_TYPE_BLANK) {
            return null;
        }
        assertThat(cell.getCellType(), is(Cell.CELL_TYPE_STRING));
        return cell.getStringCellValue();
View Full Code Here

        return ConditionSheetItem.COLUMN_NAME.getRow() + 1;
    }

    private String getStringCell(Sheet sheet, int rowIndex, int colIndex) {
        assert sheet != null;
        Row row = sheet.getRow(rowIndex);
        if (row == null) {
            return null;
        }
        Cell cell = row.getCell(colIndex);
        if (cell == null || cell.getCellType() != Cell.CELL_TYPE_STRING) {
            return null;
        }
        return cell.getStringCellValue();
    }
View Full Code Here

        }
        if (modelPredicates.contains(DataModelCondition.IGNORE_MATCHED) == false) {
            int start = extractor.extractPropertyRowStartIndex(sheet);
            int end = sheet.getLastRowNum() + 1;
            for (int i = start; i < end; i++) {
                Row row = sheet.getRow(i);
                if (row == null) {
                    continue;
                }
                resolveRow(builder, definition, context, row, extractor);
            }
View Full Code Here

        this.names = extractProperties();
    }

    private Map<PropertyName, Integer> extractProperties() throws IOException {
        // first row must be property names
        Row row = sheet.getRow(0);
        if (row == null) {
            throw new IOException(MessageFormat.format(
                    "最初の行はプロパティ名の一覧でなければなりません: (id={0})",
                    id));
        }
        nextRowNumber = 1;
        Map<PropertyName, Integer> results = new LinkedHashMap<PropertyName, Integer>();
        for (Iterator<Cell> iter = row.cellIterator(); iter.hasNext();) {
            Cell cell = iter.next();
            int type = cell.getCellType();
            if (type == Cell.CELL_TYPE_BLANK) {
                continue;
            }
View Full Code Here

    }

    @Override
    public DataModelReflection next() throws IOException {
        while (nextRowNumber <= sheet.getLastRowNum()) {
            Row row = sheet.getRow(nextRowNumber++);
            if (row == null) {
                LOG.warn(MessageFormat.format(
                        "有効な値を含まない行はスキップします: (row={1}, id={0})",
                        id,
                        nextRowNumber));
                continue;
            }
            boolean sawFilled = false;
            ExcelDataDriver driver = new ExcelDataDriver(definition, id);
            for (Map.Entry<PropertyName, Integer> entry : names.entrySet()) {
                Cell cell = row.getCell(entry.getValue(), Row.CREATE_NULL_AS_BLANK);
                int type = cell.getCellType();
                if (type == Cell.CELL_TYPE_FORMULA) {
                    evaluateInCell(cell);
                    type = cell.getCellType();
                }
                if (type == Cell.CELL_TYPE_ERROR) {
                    throw new IOException(MessageFormat.format(
                            "セルの値にエラーがあります: (pos=({1}, {2}), id={0})",
                            id,
                            row.getRowNum() + 1,
                            cell.getColumnIndex() + 1));
                }
                sawFilled |= (type != Cell.CELL_TYPE_BLANK);
                driver.process(entry.getKey(), cell);
            }
            if (sawFilled) {
                return driver.getReflection();
            } else {
                LOG.warn(MessageFormat.format(
                        "有効な値を含まない行はスキップします: (row={1}, id={0})",
                        id,
                        row.getRowNum() + 1));
            }
        }
        return null;
    }
View Full Code Here

        return RuleSheetFormat.PROPERTY_NAME.getRowIndex() + 1;
    }

    private String getStringCell(Sheet sheet, int rowIndex, int colIndex) {
        assert sheet != null;
        Row row = sheet.getRow(rowIndex);
        if (row == null) {
            return "?";
        }
        Cell cell = row.getCell(colIndex);
        if (cell == null || cell.getCellType() != Cell.CELL_TYPE_STRING) {
            return "?";
        }
        return cell.getStringCellValue();
    }
View Full Code Here

    @Override
    public void put(DataModelReflection model) {
        if (model == null) {
            throw new IllegalArgumentException("model must not be null"); //$NON-NLS-1$
        }
        Row row = sheet.createRow(rowIndex++);
        engine.process(model, row);
    }
View Full Code Here

    Workbook workbook = new HSSFWorkbook();
     
    for (int cnt=0; cnt<tests.size(); cnt++) {
      setColumns(tests.get(cnt));
      Sheet sheet = workbook.createSheet("Test " + cnt);
      Row row = sheet.createRow(0);

      int counter = 2; //A counter which is used to determine how many additional columns are needed.
      createCell(workbook, row, 0, "Grupa", CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);
      createCell(workbook, row, 1, "Indeks", CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);
      createCell(workbook, row, 2, "Naziv Fajla", CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);     
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.