diff -r 9e6f7cda68d1 poi-3.15/src/main/java/org/apache/poi/ss/format/CellNumberFormatter.java --- a/poi-3.15/src/main/java/org/apache/poi/ss/format/CellNumberFormatter.java Thu Mar 09 15:46:04 2017 +0100 +++ b/poi-3.15/src/main/java/org/apache/poi/ss/format/CellNumberFormatter.java Thu Mar 09 16:06:27 2017 +0100 @@ -26,6 +26,7 @@ import java.util.Iterator; import java.util.List; import java.util.ListIterator; +import java.util.Locale; import java.util.Set; import java.util.TreeSet; @@ -259,8 +260,7 @@ } fmtBuf.append('E'); placeZeros(fmtBuf, exponentSpecials.subList(2, exponentSpecials.size())); - DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(LocaleUtil.getUserLocale()); - decimalFmt = new DecimalFormat(fmtBuf.toString(), dfs); + decimalFmt = new DecimalFormat(fmtBuf.toString(), DecimalFormatSymbols.getInstance(Locale.US)); printfFmt = null; } @@ -444,9 +444,9 @@ writeFraction(value, null, fractional, output, mods); } else { StringBuffer result = new StringBuffer(); - Formatter f = new Formatter(result, LocaleUtil.getUserLocale()); + Formatter f = new Formatter(result); try { - f.format(LocaleUtil.getUserLocale(), printfFmt, value); + f.format(Locale.US, printfFmt, value); } finally { f.close(); } @@ -538,6 +538,13 @@ toAppendTo.append('-'); } toAppendTo.append(output); + final DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(LocaleUtil.getUserLocale()); + final String finalized = toAppendTo.toString() + .replaceAll("[.]", "!") + .replaceAll(",", String.valueOf(dfs.getGroupingSeparator())) + .replaceAll("!", String.valueOf(dfs.getDecimalSeparator())); + toAppendTo.setLength(0); + toAppendTo.append(finalized); } private void writeScientific(double value, StringBuffer output, Set mods) { @@ -698,9 +705,9 @@ private void writeSingleInteger(String fmt, int num, StringBuffer output, List numSpecials, Set mods) { StringBuffer sb = new StringBuffer(); - Formatter formatter = new Formatter(sb, LocaleUtil.getUserLocale()); + Formatter formatter = new Formatter(sb); try { - formatter.format(LocaleUtil.getUserLocale(), fmt, num); + formatter.format(Locale.US, fmt, num); } finally { formatter.close(); } @@ -811,6 +818,13 @@ */ public void simpleValue(StringBuffer toAppendTo, Object value) { SIMPLE_NUMBER.formatValue(toAppendTo, value); + final DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(LocaleUtil.getUserLocale()); + final String finalized = toAppendTo.toString() + .replaceAll("[.]", "!") + .replaceAll(",", String.valueOf(dfs.getGroupingSeparator())) + .replaceAll("!", String.valueOf(dfs.getDecimalSeparator())); + toAppendTo.setLength(0); + toAppendTo.append(finalized); } private static Special lastSpecial(List s) {