|
|
|
@ -38,6 +38,7 @@ import java.util.Observer;
|
|
|
|
|
import java.util.regex.Matcher; |
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.analysis.ExcelAnalyserImpl; |
|
|
|
|
import org.apache.poi.ss.format.CellFormat; |
|
|
|
|
import org.apache.poi.ss.format.CellFormatResult; |
|
|
|
|
import org.apache.poi.ss.formula.ConditionalFormattingEvaluator; |
|
|
|
@ -54,8 +55,8 @@ import org.apache.poi.ss.usermodel.FractionFormat;
|
|
|
|
|
import org.apache.poi.ss.util.DateFormatConverter; |
|
|
|
|
import org.apache.poi.ss.util.NumberToTextConverter; |
|
|
|
|
import org.apache.poi.util.LocaleUtil; |
|
|
|
|
import org.apache.poi.util.POILogFactory; |
|
|
|
|
import org.apache.poi.util.POILogger; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* DataFormatter contains methods for formatting the value stored in an Cell. This can be useful for reports and GUI |
|
|
|
@ -227,7 +228,7 @@ public class DataFormatter1 implements Observer {
|
|
|
|
|
private final LocaleChangeObservable localeChangedObservable = new LocaleChangeObservable(); |
|
|
|
|
|
|
|
|
|
/** For logging any problems we find */ |
|
|
|
|
private static POILogger logger = POILogFactory.getLogger(DataFormatter.class); |
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ExcelAnalyserImpl.class); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Creates a formatter using the {@link Locale#getDefault() default locale}. |
|
|
|
@ -346,7 +347,7 @@ public class DataFormatter1 implements Observer {
|
|
|
|
|
// Wrap and return (non-cachable - CellFormat does that)
|
|
|
|
|
return new CellFormatResultWrapper(cfmt.apply(cellValueO)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
logger.log(POILogger.WARN, "Formatting failed for format " + formatStr + ", falling back", e); |
|
|
|
|
logger.warn("Formatting failed for format {}, falling back", formatStr, e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -589,7 +590,7 @@ public class DataFormatter1 implements Observer {
|
|
|
|
|
try { |
|
|
|
|
return new ExcelStyleDateFormatter(formatStr, dateSymbols); |
|
|
|
|
} catch (IllegalArgumentException iae) { |
|
|
|
|
logger.log(POILogger.DEBUG, "Formatting failed for format " + formatStr + ", falling back", iae); |
|
|
|
|
logger.debug("Formatting failed for format {}, falling back", formatStr, iae); |
|
|
|
|
// the pattern could not be parsed correctly,
|
|
|
|
|
// so fall back to the default number format
|
|
|
|
|
return getDefaultFormat(cellValue); |
|
|
|
@ -750,7 +751,7 @@ public class DataFormatter1 implements Observer {
|
|
|
|
|
try { |
|
|
|
|
return new InternalDecimalFormatWithScale(format, symbols); |
|
|
|
|
} catch (IllegalArgumentException iae) { |
|
|
|
|
logger.log(POILogger.DEBUG, "Formatting failed for format " + formatStr + ", falling back", iae); |
|
|
|
|
logger.debug("Formatting failed for format {}, falling back", formatStr, iae); |
|
|
|
|
// the pattern could not be parsed correctly,
|
|
|
|
|
// so fall back to the default number format
|
|
|
|
|
return getDefaultFormat(cellValue); |
|
|
|
|