Package org.apache.poi.ss.usermodel

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


        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


    public String extractName(Row row) throws FormatException {
        if (row == null) {
            throw new IllegalArgumentException("row must not be null"); //$NON-NLS-1$
        }
        // strict checking for cell type
        Cell cell = row.getCell(ConditionSheetItem.COLUMN_NAME.getCol());
        if (cell == null || cell.getCellType() == Cell.CELL_TYPE_BLANK) {
            return null;
        } else if (cell.getCellType() != Cell.CELL_TYPE_STRING) {
            throw new FormatException(MessageFormat.format(
                    "{0}は文字列で指定してください: ({1}, {2})",
                    ConditionSheetItem.COLUMN_NAME.getName(),
                    cell.getRowIndex() + 1,
                    cell.getColumnIndex() + 1));
        }
        String name = cell.getStringCellValue();
        if (name.isEmpty()) {
            return null;
        }
        return name.toLowerCase();
    }
View Full Code Here

    }

    private String getStringCell(Row row, ConditionSheetItem item) throws FormatException {
        assert row != null;
        assert item != null;
        Cell cell = row.getCell(item.getCol());
        if (cell == null || cell.getCellType() == Cell.CELL_TYPE_BLANK) {
            return "";
        } else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
            return cell.getStringCellValue();
        }
        throw new FormatException(MessageFormat.format(
                "{0}は文字列で指定してください: (row={1}, col={2})",
                item.getName(),
                cell.getRowIndex() + 1,
                cell.getColumnIndex() + 1));
    }
View Full Code Here

                    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;
            }
            if (type != Cell.CELL_TYPE_STRING || cell.getStringCellValue().isEmpty()) {
                throw new IOException(MessageFormat.format(
                        "最初の行はプロパティ名を文字列で指定してください: (id={0}, column={1})",
                        id,
                        cell.getColumnIndex() + 1));
            }
            String name = cell.getStringCellValue();
            PropertyName property = toPropertyName(cell, name);
            if (definition.getType(property) == null) {
                throw new IOException(MessageFormat.format(
                        "{0}にプロパティ\"{1}\"は定義されていません: (id={2}, column={3})",
                        definition.getModelClass().getName(),
                        property,
                        id,
                        cell.getColumnIndex() + 1));
            }
            results.put(property, cell.getColumnIndex());
        }
        if (results.isEmpty()) {
            throw new IOException(MessageFormat.format(
                    "最初の行はプロパティ名の一覧でなければなりません: (id={0})",
                    id));
View Full Code Here

                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) {
View Full Code Here

        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

    public String extractName(Row row) throws FormatException {
        if (row == null) {
            throw new IllegalArgumentException("row must not be null"); //$NON-NLS-1$
        }
        // strict checking for cell type
        Cell cell = row.getCell(RuleSheetFormat.PROPERTY_NAME.getColumnIndex());
        if (cell == null || cell.getCellType() == Cell.CELL_TYPE_BLANK) {
            return null;
        } else if (cell.getCellType() != Cell.CELL_TYPE_STRING) {
            throw new FormatException(MessageFormat.format(
                    "{0}は文字列で指定してください: ({1}, {2})",
                    RuleSheetFormat.PROPERTY_NAME.getTitle(),
                    cell.getRowIndex() + 1,
                    cell.getColumnIndex() + 1));
        }
        String name = cell.getStringCellValue();
        if (name.isEmpty()) {
            return null;
        }
        return name;
    }
View Full Code Here

    }

    private String getStringCell(Row row, RuleSheetFormat item) throws FormatException {
        assert row != null;
        assert item != null;
        Cell cell = row.getCell(item.getColumnIndex());
        if (cell == null || cell.getCellType() == Cell.CELL_TYPE_BLANK) {
            return "";
        } else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
            return cell.getStringCellValue();
        }
        throw new FormatException(MessageFormat.format(
                "{0}は文字列で指定してください: (row={1}, col={2})",
                item.getTitle(),
                cell.getRowIndex() + 1,
                cell.getColumnIndex() + 1));
    }
View Full Code Here

        void createHeaderRow(Row row) {
            assert row != null;
            int columnIndex = 0;
            for (PropertyName name : properties) {
                Cell cell = row.createCell(columnIndex++);
                cell.setCellStyle(info.titleStyle);
                cell.setCellValue(name.toString());
            }
        }
View Full Code Here

            }
        }

        @Override
        public void booleanProperty(PropertyName name, Context context) {
            Cell cell = context.nextCell();
            Boolean value = (Boolean) context.getValue(name);
            if (value != null) {
                cell.setCellValue(value);
            }
        }
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.