package com.poiji.bind.mapping;

import com.poiji.option.PoijiOptions;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.util.NumberToTextConverter;

/**
 * Created by hakan on 16.05.2021
 */
public class PoijiDataFormatter extends DataFormatter {

    PoijiOptions options;

    public PoijiDataFormatter(PoijiOptions options) {
        super();
        this.options = options;
    }

    @Override
    public String formatRawCellContents(double value, int formatIndex, String formatString, boolean use1904Windowing) {
        String cellContents = super.formatRawCellContents(value, formatIndex, formatString, use1904Windowing);

        if (options.isReturnRawValues()) {
            return NumberToTextConverter.toText(value);
        } else {
            return cellContents;
        }
    }
}

@@ -114,16 +114,61 @@
 matter;%0A
+import org.apache.poi.ss.usermodel.DateUtil;%0A
 import o
@@ -595,124 +595,66 @@
     
-String cellContents = super.formatRawCellContents(value, formatIndex, formatString, use1904Windowing);%0A%0A        if (
+if (!DateUtil.isADateFormat(formatIndex, formatString) && 
 opti
@@ -776,20 +776,87 @@
 urn 
-cellContents
+super.formatRawCellContents(value, formatIndex, formatString, use1904Windowing)
 ;%0A  

use new option if the value is not a date format