フォーマッターを指定してセルの値が空かどうか判定する。
<p>ブランクセルなどの判定は優先的に行う。</p>
@param cell セル
@param cellFormatter セルのフォーマッタ
@throws IllegalArgumentException {@literal  sheet == null or cellFormatter == null.}
@return
335451
public static boolean isEmptyCellContents(final Cell cell, final CellFormatter cellFormatter) {
        ArgUtils.notNull(cell, "cell");
        ArgUtils.notNull(cellFormatter, "cellFormatter");

        return getCellContents(cell, cellFormatter).isEmpty();
    }
992945
public static Cells getCellFromJson(LinkedMapWritable jsonObject, String tableName) throws IllegalAccessException,
            InstantiationException, InvocationTargetException, NoSuchMethodException {

        Cells cells = tableName != null ? new Cells(tableName) : new Cells();

        Set<Map.Entry<Writable, Writable>> entryJson = jsonObject.entrySet();

        for (Map.Entry<Writable, Writable> entry : entryJson) {

            if (LinkedMapWritable.class.isAssignableFrom(entry.getValue().getClass())) {
                Cells innerCells = getCellFromJson((LinkedMapWritable) entry.getValue(), null);
                cells.add(Cell.create(entry.getKey().toString(), innerCells));
            } else if (ArrayWritable.class.isAssignableFrom(entry.getValue().getClass())) {
                Writable[] writetable = ((ArrayWritable) entry.getValue()).get();
                List innerCell = new ArrayList<>();
                for (int i = 0; i < writetable.length; i++) {
                    if(writetable[i] instanceof LinkedMapWritable){
                        innerCell.add(getCellFromJson((LinkedMapWritable) writetable[i], null));
                    }else{
                        innerCell.add(getObjectFromWritable(entry.getValue()));
                    }

                }
                cells.add(Cell.create(entry.getKey().toString(), innerCell));
            } else {

                cells.add(Cell.create(entry.getKey().toString(), getObjectFromWritable(entry.getValue())));
            }

        }
        return cells;
    }
79222
public void acceptCell(C cell) {
        cell.reset();
        if(cell.isReusable()) {
            pool.add(cell);
        } else {
            cell.dispose();
        }
    }
99801
public CellFinder startPosition(final Cell cell) {
        ArgUtils.notNull(cell, "cell");
        
        return startPosition(cell.getColumnIndex(), cell.getRowIndex());
    }
360715
private CellFormatResult getErrorCellValue(final Cell cell, final Locale locale, final boolean isStartDate1904) {
        
        final CellFormatResult result = new CellFormatResult();
        result.setCellType(FormatCellType.Error);
        
        final ErrorCell errorCell = (ErrorCell) cell;
        final int errorCode = errorCell.getErrorCode();
        result.setValue(errorCode);
        
        if(isErrorCellAsEmpty()) {
            result.setText("");
            
        } else {
            /*
             * エラーコードについては、POIクラスを参照。
             * ・org.apache.poi.ss.usermodel.FormulaError
             * ・org.apache.poi.ss.usermodel.ErrorConstants
             */
            switch(errorCode) {
                case 7:
                    // 0除算
                    result.setText("#DIV/0!");
                    break;
                    
                case 42:
                    // 関数や数式に使用できる値がない
                    result.setText("#N/A");
                    break;
                    
                case 29:
                    // 数式が参照している名称がない
                    result.setText("#NAME?");
                    break;
                    
                case 0:
                    // 正しくない参照演算子または正しくないセル参照を使っている
                    result.setText("#NULL!");
                    break;
                    
                case 36:
                    // 数式または関数の数値が不適切
                    result.setText("#NUM!");
                    break;
                    
                case 23:
                    // 数式が参照しているセルがない
                    result.setText("#REF!");
                    break;
                    
                case 15:
                    // 文字列が正しいデータ型に変換されない
                    result.setText("#VALUE!");
                    break;
                    
                default:
                    result.setText("");
                    break;
            }
            
        }
        
        return result;
        
    }
362179
public void addCell(String row, String col, String value) throws Exception {
		HeaderInfo rowIndex = rowLookup.get(row);
		HeaderInfo colIndex = columnLookup.get(col);
		if (rowIndex == null) {
			throw new Exception("Row " + row + " not found in worksheet");
		}
		if (colIndex == null) {
			throw new Exception("Column " + col + " not found in worksheet");
		}


		data[rowIndex.getIndex()][colIndex.getIndex()] = new CompactCharSequence(value);
	}
735859
public static Object getCellValue(int type, Cell cell) {
        switch (type) {
            case Cell.CELL_TYPE_BOOLEAN:
                return cell.getBooleanCellValue();
            case Cell.CELL_TYPE_NUMERIC:
                if (DateUtil.isCellDateFormatted(cell)) {
                    return DateUtil.getJavaDate(cell.getNumericCellValue());
                } else {
                    BigDecimal bd = new BigDecimal(cell.getNumericCellValue());
                    return bd.toString().contains(".") ? bd.setScale(2, RoundingMode.HALF_UP).toString() :
                            bd.toString();
                }
            case Cell.CELL_TYPE_STRING:
                try {
                    return DateUtils.parseDate(cell.getStringCellValue(), ReadExcelUtils.PATTERN);
                } catch (Exception e) {
                    return cell.getStringCellValue();
                }
            case Cell.CELL_TYPE_FORMULA:
                if (DateUtil.isCellDateFormatted(cell)) {
                    return cell.getDateCellValue();
                }
                break;
            default:
                break;
        }
        return null;
    }
995375
public boolean mapsCell(String cell) {
        return mappedCells.stream().anyMatch(x -> x.equals(cell));
    }
340975
private <P> SheetBindingErrors<P> loadSheet(final Sheet sheet, final Class<P> clazz, final AnnotationReader annoReader)
            throws XlsMapperException {

        // 値の読み込み対象のJavaBeanオブジェクトの作成
        final P beanObj = configuration.createBean(clazz);

        final SheetBindingErrors<P> errors =  configuration.getBindingErrorsFactory().create(beanObj);
        errors.setSheetName(sheet.getSheetName());
        errors.setSheetIndex(sheet.getWorkbook().getSheetIndex(sheet));

        final LoadingWorkObject work = new LoadingWorkObject();
        work.setAnnoReader(annoReader);
        work.setErrors(errors);

        // セルのキャッシュ情報の初期化
        configuration.getCellFormatter().init(configuration.isCacheCellValueOnLoad());

        final FieldAccessorFactory adpterFactory = new FieldAccessorFactory(annoReader);

        // リスナークラスの@PreLoad用メソッドの実行
        final XlsListener listenerAnno = annoReader.getAnnotation(beanObj.getClass(), XlsListener.class);
        if(listenerAnno != null) {
            for(Class<?> listenerClass : listenerAnno.value()) {
                final Object listenerObj = configuration.createBean(listenerClass);

                for(Method method : listenerObj.getClass().getMethods()) {
                    if(annoReader.hasAnnotation(method, XlsPreLoad.class)) {
                        Utils.invokeNeedProcessMethod(listenerObj, method, beanObj, sheet, configuration, work.getErrors(), ProcessCase.Load);
                    }
                }
            }

        }

        // @PreLoad用のメソッドの実行
        for(Method method : clazz.getMethods()) {

            if(annoReader.hasAnnotation(method, XlsPreLoad.class)) {
                Utils.invokeNeedProcessMethod(beanObj, method, beanObj, sheet, configuration, work.getErrors(), ProcessCase.Load);
            }
        }

        final List<FieldAccessorProxy> accessorProxies = new ArrayList<>();

        // public メソッドの処理
        for(Method method : clazz.getMethods()) {
            method.setAccessible(true);
            for(Annotation anno : annoReader.getAnnotations(method)) {
                final XlsFieldProcessor annoFieldProcessor = anno.annotationType().getAnnotation(XlsFieldProcessor.class);
                if(ClassUtils.isAccessorMethod(method) && annoFieldProcessor != null) {
                    // 登録済みのFieldProcessorの取得
                    FieldProcessor<?> processor = configuration.getFieldProcessorRegistry().getProcessor(anno.annotationType());

                    // アノテーションに指定されているFieldProcessorの場合
                    if(processor == null && annoFieldProcessor.value().length > 0) {
                        processor = configuration.createBean(annoFieldProcessor.value()[0]);

                    }

                    if(processor != null) {
                        final FieldAccessor accessor = adpterFactory.create(method);
                        final FieldAccessorProxy accessorProxy = new FieldAccessorProxy(anno, processor, accessor);
                        if(!accessorProxies.contains(accessorProxy)) {
                            accessorProxies.add(accessorProxy);
                        }

                    } else {
                        // FieldProcessorが見つからない場合
                        throw new AnnotationInvalidException(anno, MessageBuilder.create("anno.XlsFieldProcessor.notResolve")
                                .varWithAnno("anno", anno.annotationType())
                                .format());
                    }

                }

                if(anno instanceof XlsPostLoad) {
                    work.addNeedPostProcess(new NeedProcess(beanObj, beanObj, method));
                }
            }

        }

        // フィールドの処理
        for(Field field : clazz.getDeclaredFields()) {

            field.setAccessible(true);
            for(Annotation anno : annoReader.getAnnotations(field)) {

                final XlsFieldProcessor annoFieldProcessor = anno.annotationType().getAnnotation(XlsFieldProcessor.class);
                if(annoFieldProcessor != null) {

                    // 登録済みのFieldProcessorの取得
                    FieldProcessor<?> processor = configuration.getFieldProcessorRegistry().getProcessor(anno.annotationType());

                    // アノテーションに指定されているFieldProcessorの場合
                    if(processor == null && annoFieldProcessor.value().length > 0) {
                        processor = configuration.createBean(annoFieldProcessor.value()[0]);

                    }

                    if(processor != null) {
                        final FieldAccessor accessor = adpterFactory.create(field);
                        final FieldAccessorProxy accessorProxy = new FieldAccessorProxy(anno, processor, accessor);
                        if(!accessorProxies.contains(accessorProxy)) {
                            accessorProxies.add(accessorProxy);
                        }

                    } else {
                        // FieldProcessorが見つからない場合
                        throw new AnnotationInvalidException(anno, MessageBuilder.create("anno.XlsFieldProcessor.notResolve")
                                .varWithAnno("anno", anno.annotationType())
                                .format());
                    }

                }


            }
        }

        // 順番を並び替えて保存処理を実行する
        Collections.sort(accessorProxies, new FieldAccessorProxyComparator());
        for(FieldAccessorProxy accessorProxy : accessorProxies) {
            accessorProxy.loadProcess(sheet, beanObj, configuration, work);
        }

        // リスナークラスの@PostLoadの取得
        if(listenerAnno != null) {
            for(Class<?> listenerClass : listenerAnno.value()) {
                Object listenerObj = configuration.createBean(listenerClass);
                for(Method method : listenerObj.getClass().getMethods()) {
                    if(annoReader.hasAnnotation(method, XlsPostLoad.class)) {
                        work.addNeedPostProcess(new NeedProcess(beanObj, listenerObj, method));
                    }
                }
            }

        }

        //@PostLoadが付与されているメソッドの実行
        for(NeedProcess need : work.getNeedPostProcesses()) {
            Utils.invokeNeedProcessMethod(need.getProcess(), need.getMethod(), need.getTarget(), sheet, configuration, work.getErrors(), ProcessCase.Load);
        }

        // セルのキャッシュ情報の初期化
        configuration.getCellFormatter().init(configuration.isCacheCellValueOnLoad());

        return errors;
    }
644670
public static BorderStyle getBorderLeft(final Cell cell) {

        ArgUtils.notNull(cell, "cell");

        final Sheet sheet = cell.getSheet();
        CellRangeAddress mergedRegion = getMergedRegion(sheet, cell.getRowIndex(), cell.getColumnIndex());

        final Cell target;
        if(mergedRegion == null) {
            // 結合されていない場合
            target = cell;

        } else {
            if(mergedRegion.getFirstColumn() == cell.getColumnIndex()) {
                // 引数のCellが左部のセルの場合
                target = cell;
            } else {
                target = getCell(sheet, mergedRegion.getFirstColumn(), cell.getRowIndex());
            }

        }

        final CellStyle style = target.getCellStyle();
        if(style == null) {
            return BorderStyle.NONE;
        } else {
            return style.getBorderLeftEnum();
        }

    }
842372
public static CellFinder query(final Sheet sheet, final String label, final Configuration config) {
        return new CellFinder(sheet, label, config);
    }
803137
public String getCellValue(int rowNumber, int cellNumber) {
        String result;
        checkRowAndCell(rowNumber, cellNumber);
        Sheet sheet = this.workbook.getSheet(this.sheetName);
        Row row = sheet.getRow(--rowNumber);
        Cell cell = row.getCell(--cellNumber);
        switch (cell.getCellTypeEnum()) {
            case BLANK:
                result = cell.getStringCellValue();
                break;
            case BOOLEAN:
                result = String.valueOf(cell.getBooleanCellValue());
                break;
            case ERROR:
                result = String.valueOf(cell.getErrorCellValue());
                break;
            case FORMULA:
                result = cell.getCellFormula();
                break;
            case NUMERIC:
                if (DateUtil.isCellDateFormatted(cell)) {
                    result = format.format(cell.getDateCellValue());
                } else {
                    result = String.valueOf(cell.getNumericCellValue());
                }
                break;
            case STRING:
                result = cell.getRichStringCellValue().getString();
                break;
            default:
                result = cell.getStringCellValue();
                break;
        }
        return result;
    }
720116
private CellFormatResult getMergedCellValue(final Cell cell, final Locale locale) {

        final Sheet sheet = cell.getSheet();
        final int size = sheet.getNumMergedRegions();

        for(int i=0; i < size; i++) {
            final CellRangeAddress range = sheet.getMergedRegion(i);
            if(!range.isInRange(cell.getRowIndex(), cell.getColumnIndex())) {
                continue;
            }

            // 非BLANKまたはnullでないセルを取得する。
            for(int rowIdx=range.getFirstRow(); rowIdx <= range.getLastRow(); rowIdx++) {
                final Row row = sheet.getRow(rowIdx);
                if(row == null) {
                    continue;
                }

                for(int colIdx=range.getFirstColumn(); colIdx <= range.getLastColumn(); colIdx++) {
                    final Cell valueCell = row.getCell(colIdx);
                    if(valueCell == null || valueCell.getCellTypeEnum() == CellType.BLANK) {
                        continue;
                    }

                    return format(valueCell, locale);
                }
            }

        }

        return createBlankCellResult();
    }
1144534
public static Object getCellValue(Cell cell, boolean isTrimCellValue) {
		if (null == cell) {
			return null;
		}
		return getCellValue(cell, cell.getCellTypeEnum(), isTrimCellValue);
	}
331273
public static CellPosition of(final Cell cell) {
        ArgUtils.notNull(cell, "cell");

        return of(cell.getRowIndex(), cell.getColumnIndex());
    }
623231
private void copyCellStyle(final Cell fromCell, final Cell toCell) {

        final CellStyle style = fromCell.getCellStyle();
        toCell.setCellStyle(style);
        toCell.setCellType(CellType.BLANK);

        // 横方向に結合されている場合、結合情報のコピーする。（XlsArrayColumns用）
        final Sheet sheet = fromCell.getSheet();
        final CellRangeAddress mergedRegion = POIUtils.getMergedRegion(sheet, fromCell.getRowIndex(), fromCell.getColumnIndex());
        final int mergedSize = POIUtils.getColumnSize(mergedRegion);

        if(POIUtils.getColumnSize(mergedRegion) >= 2) {
            CellRangeAddress newMergedRegion = POIUtils.getMergedRegion(sheet, toCell.getRowIndex(), toCell.getColumnIndex());
            if(newMergedRegion != null) {
                // 既に結合している場合 - 通常はありえない。
                return;
            }

            newMergedRegion = POIUtils.mergeCells(sheet,
                    mergedRegion.getFirstColumn(), toCell.getRowIndex(), mergedRegion.getLastColumn(), toCell.getRowIndex());

            // 結合先のセルの書式も設定する
            // 中間のセルの設定
            for(int i=1; i < mergedSize; i++) {
                Cell mergedFromCell = POIUtils.getCell(sheet, toCell.getColumnIndex()+i, fromCell.getRowIndex());

                Cell mergedToCell = POIUtils.getCell(sheet, toCell.getColumnIndex()+i, toCell.getRowIndex());
                mergedToCell.setCellStyle(mergedFromCell.getCellStyle());
                mergedToCell.setCellType(CellType.BLANK);
            }

        }

    }
727520
public CellFormatter getFormatter(final String formatPattern) {
        
        final String key = (formatPattern == null ? "" : formatPattern);
        return patternFormatterMap.get(key);
    }