Examples of HSSFCell


Examples of org.apache.poi.hssf.usermodel.HSSFCell

        testConditionSheet = workbook.getSheet(Constants.TEST_CONDITION_SHEET_NAME);
        if (testConditionSheet == null) {
            throw new IOException("Excelファイル: " + filename + "にテスト条件データのシートが存在しません");
        }

        HSSFCell tableNameCell = getCell(testConditionSheet,
                ConditionSheetItem.TABLE_NAME.getRow(),
                ConditionSheetItem.TABLE_NAME.getCol() + 1);
        tablename = tableNameCell.getStringCellValue();
        if (tablename == null || tablename.length() == 0) {
            throw new IOException("Excelファイル: " + filename + "にテーブル名が定義されていません");
        }

        HSSFCell rowMatchingConditionCell = getCell(testConditionSheet,
                ConditionSheetItem.ROW_MATCHING_CONDITION.getRow(),
                ConditionSheetItem.ROW_MATCHING_CONDITION.getCol() + 1);
        String rowMatchingConditionStr = rowMatchingConditionCell.getStringCellValue();
        if (rowMatchingConditionStr == null || rowMatchingConditionStr.length() == 0) {
            throw new IOException("Excelファイル: " + filename + "にテーブルの比較条件が定義されていません");
        }
        rowMatchingCondition = RowMatchingCondition.getConditonByJapanseName(rowMatchingConditionStr);
        if (rowMatchingCondition == null) {
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFCell

     * @param row 対象の行
     * @param col 対象のカラム番号
     * @return 対応するセルの内容
     */
    private HSSFCell getCell(HSSFSheet sheet, HSSFRow row, int col) {
        HSSFCell cell = row.getCell(col);
        if (cell == null) {
            String fmt = "Excelファイルが異常です(空セル), file = %s, sheet = %s, row = %d, col = %d";
            String msg = String.format(fmt, filename, sheet.getSheetName(), row.getRowNum() + 1, col + 1);
            throw new InvalidExcelBookException(msg);
        }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFCell

        if (isEmpty(row)) {
            String fmt = "Excelファイルが異常です(空行), file = %s, sheet = %s, row = %d";
            String msg = String.format(fmt, filename, sheet.getSheetName(), rownum);
            throw new InvalidExcelBookException(msg);
        }
        HSSFCell cell = getCell(sheet, row, col);
        return cell;
    }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFCell

     * @param row 対象の行
     * @return 対応するセルの内容
     */
    private HSSFCell getCell(ConditionSheetItem item, HSSFRow row) {
        int col = item.getCol();
        HSSFCell cell = getCell(testConditionSheet, row, col);
        return cell;
    }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFCell

     * @param item テスト条件の項目
     * @param row 対象の行
     * @return 対応するセルの内容
     */
    private String getStringCellValue(HSSFSheet sheet, ConditionSheetItem item, HSSFRow row) {
        HSSFCell cell = getCell(item, row);
        String ret;
        if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
            double dval = cell.getNumericCellValue();
            ret = Double.toString(dval);
            ret = ret.replaceAll("\\.0*$", "");
        } else if (cell.getCellType() == Cell.CELL_TYPE_BLANK) {
            ret = "";
        } else if (cell.getCellType() != Cell.CELL_TYPE_STRING) {
            String fmt = "Excelファイルが異常です。文字列のセルに文字列以外の値が設定されています。 file = %s, sheet = %s, row = %d, col = %d";
            int rownum = row.getRowNum() + 1;
            int col = item.getCol() + 1;
            String msg = String.format(fmt, filename, sheet.getSheetName(), rownum, col);
            throw new InvalidExcelBookException(msg);
        } else {
            ret = cell.getStringCellValue();
        }
        return ret;
    }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFCell

        }
        return ret;
    }

    private Double getDubleCellValue(HSSFSheet sheet, ConditionSheetItem item, HSSFRow row) {
        HSSFCell cell = getCell(item, row);
        Double ret;
        if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
            String str = cell.getStringCellValue();
            if (str == null || str.length() == 0) {
                ret = null;
            } else {
                try {
                    ret = Double.parseDouble(str);
                } catch (NumberFormatException e) {
                    String fmt = "Excelファイルが異常です。数値のセルに数値以外の値が設定されています。 file = %s, sheet = %s, row = %d, col = %d";
                    int rownum = row.getRowNum() + 1;
                    int col = item.getCol() + 1;
                    String msg = String.format(fmt, filename, sheet.getSheetName(), rownum, col);
                    throw new InvalidExcelBookException(msg);
                }
            }
        } else if (cell.getCellType() == Cell.CELL_TYPE_BLANK) {
            ret = null;
        } else if (cell.getCellType() != Cell.CELL_TYPE_NUMERIC) {
            String fmt = "Excelファイルが異常です。数値のセルに数値以外の値が設定されています。 file = %s, sheet = %s, row = %d, col = %d";
            int rownum = row.getRowNum() + 1;
            int col = item.getCol() + 1;
            String msg = String.format(fmt, filename, sheet.getSheetName(), rownum, col);
            throw new InvalidExcelBookException(msg);
        } else {
            ret =  cell.getNumericCellValue();
        }
        return ret;
    }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFCell

                throw new RuntimeException(e);
            } catch (IllegalAccessException e) {
                throw new RuntimeException(e);
            }
            for (int col = 0; col < columnInfos.size(); col++) {
                HSSFCell cell = row.getCell(col, Row.CREATE_NULL_AS_BLANK);
                MySqlDataType type = columnInfos.get(col).getDataType();
                ValueOption<?> vo;
                switch (type) {
                case CHAR:
                case VARCHAR:
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFCell

    private HSSFSheet createTestConditionSheet(String sheetName) {
        // タイトルのセルを作成, 同時にカラム位置の最大値を取得
        int maxColumn = 0;
        HSSFSheet sheet = workbook.createSheet(sheetName);
        for (ConditionSheetItem item : ConditionSheetItem.values()) {
            HSSFCell cell = getCell(sheet, item.getRow(), item.getCol());
            cell.setCellValue(item.getName());
            cell.setCellStyle(titleStyle);
            if (maxColumn < item.getCol()) {
                maxColumn = item.getCol();
            }
        }

        // テーブル名とテーブルのマッチング条件を設定
        HSSFCell tableNameCell = getCell(sheet, ConditionSheetItem.TABLE_NAME
                .getRow(), ConditionSheetItem.TABLE_NAME.getCol() + 1);
        tableNameCell.setCellStyle(fixedValueStyle);
        tableNameCell.setCellValue(tableName);

        HSSFCell rowMatichingConditionCell = getCell(sheet,
                ConditionSheetItem.ROW_MATCHING_CONDITION.getRow(),
                ConditionSheetItem.ROW_MATCHING_CONDITION.getCol() + 1);
        rowMatichingConditionCell.setCellValue(RowMatchingCondition.NONE.getJapaneseName());

        // 各カラムの情報を設定
        int startRow = ConditionSheetItem.NO.getRow();
        int endRow = configureColumns(sheet, startRow);
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFCell

        int no = 0;
        for (ColumnInfo info : columnInfos) {
            row++;
            no++;

            HSSFCell noCell = getCell(sheet, row, ConditionSheetItem.NO.getCol());
            noCell.setCellStyle(centerAlignFixedValueStyle);
            noCell.setCellValue(no);

            HSSFCell columnNameCell = getCell(sheet, row, ConditionSheetItem.COLUMN_NAME.getCol());
            columnNameCell.setCellStyle(fixedValueStyle);
            columnNameCell.setCellValue(info.getColumnName());

            HSSFCell columnCommentCell = getCell(sheet, row, ConditionSheetItem.COLUMN_COMMENT.getCol());
            columnCommentCell.setCellStyle(fixedValueStyle);
            columnCommentCell.setCellValue(info.getColumnComment());

            HSSFCell dataTypeCell = getCell(sheet, row, ConditionSheetItem.DATA_TYPE.getCol());
            dataTypeCell.setCellStyle(centerAlignFixedValueStyle);
            dataTypeCell.setCellValue(info.getDataType().getDataTypeString());

            HSSFCell widthCell = getCell(sheet, row, ConditionSheetItem.WIDTH.getCol());
            widthCell.setCellStyle(centerAlignFixedValueStyle);
            switch (info.getDataType()) {
            case CHAR:
            case VARCHAR:
                widthCell.setCellValue(info.getCharacterMaximumLength());
                break;
            case DECIMAL:
                widthCell.setCellValue(info.getNumericPrecision());
                break;
            case DATE:
            case DATETIME:
            case INT:
            case LONG:
            case SMALL_INT:
            case TIMESTAMP:
            case TINY_INT:
                widthCell.setCellValue(CELL_EMPTY);
                break;
            default:
                throw new RuntimeException(MessageFormat.format(
                        "Unkonwn data type: {0}",
                        info.getDataType().name()));
            }

            HSSFCell scaleCell = getCell(sheet, row, ConditionSheetItem.SCALE.getCol());
            scaleCell.setCellStyle(centerAlignFixedValueStyle);
            switch (info.getDataType()) {
            case DECIMAL:
                scaleCell.setCellValue(info.getNumericScale());
                break;
            case CHAR:
            case DATE:
            case DATETIME:
            case INT:
            case LONG:
            case SMALL_INT:
            case TIMESTAMP:
            case TINY_INT:
            case VARCHAR:
                scaleCell.setCellValue(CELL_EMPTY);
                break;
            default:
                throw new RuntimeException(MessageFormat.format(
                        "Unkonwn data type: {0}",
                        info.getDataType().name()));
            }

            HSSFCell nullableCell = getCell(sheet, row, ConditionSheetItem.NULLABLE.getCol());
            nullableCell.setCellStyle(centerAlignFixedValueStyle);
            if (info.isNullable()) {
                nullableCell.setCellValue(CELL_TRUE);
            } else {
                nullableCell.setCellValue(CELL_FALSE);
            }

            HSSFCell pkCell = getCell(sheet, row, ConditionSheetItem.KEY_FLAG.getCol());
            pkCell.setCellStyle(centerAlignStyle);
            if (info.isKey()) {
                pkCell.setCellValue(CELL_TRUE);
            } else {
                pkCell.setCellValue(CELL_FALSE);
            }

            HSSFCell machingCondtionCell = getCell(sheet, row, ConditionSheetItem.MATCHING_CONDITION.getCol());
            machingCondtionCell.setCellStyle(centerAlignStyle);
            machingCondtionCell.setCellValue(ColumnMatchingCondition.NONE.getJapaneseName());

            HSSFCell nullValueConditionCell = getCell(sheet, row, ConditionSheetItem.NULL_VALUE_CONDITION.getCol());
            nullValueConditionCell.setCellStyle(centerAlignStyle);
            nullValueConditionCell.setCellValue(NullValueCondition.NORMAL.getJapaneseName());

        }
        int endRow = row;
        return endRow;
    }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFCell


    public void testGetXXXOptionDo(ExcelUtils excelUtils, HSSFSheet sheet, DATA data, TYPES types, Object expected) throws Exception {
        int rownum = data.getRownum();
        int colpos = types.getColpos();
        HSSFCell cell = getCell(sheet, rownum, colpos);
        String methodName = types.getMethodName();
        Method method = excelUtils.getClass().getDeclaredMethod(methodName, HSSFCell.class);
        method.setAccessible(true);

        Throwable t = null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.