mirror of
https://github.com/apache/poi.git
synced 2025-02-08 11:04:53 +00:00
forbidden apis fixes
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1700076 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a9f220d154
commit
72433ac405
@ -440,8 +440,8 @@ public class DataFormatter {
|
|||||||
|
|
||||||
Matcher dateMatcher = daysAsText.matcher(formatStr);
|
Matcher dateMatcher = daysAsText.matcher(formatStr);
|
||||||
if (dateMatcher.find()) {
|
if (dateMatcher.find()) {
|
||||||
String match = dateMatcher.group(0);
|
String match = dateMatcher.group(0).toUpperCase(Locale.ROOT).replaceAll("D", "E");
|
||||||
formatStr = dateMatcher.replaceAll(match.toUpperCase().replaceAll("D", "E"));
|
formatStr = dateMatcher.replaceAll(match);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert excel date format to SimpleDateFormat.
|
// Convert excel date format to SimpleDateFormat.
|
||||||
@ -903,8 +903,9 @@ public class DataFormatter {
|
|||||||
/**
|
/**
|
||||||
* @return a <tt>DecimalFormat</tt> with parseIntegerOnly set <code>true</code>
|
* @return a <tt>DecimalFormat</tt> with parseIntegerOnly set <code>true</code>
|
||||||
*/
|
*/
|
||||||
/* package */ static DecimalFormat createIntegerOnlyFormat(String fmt) {
|
private static DecimalFormat createIntegerOnlyFormat(String fmt) {
|
||||||
DecimalFormat result = new DecimalFormat(fmt);
|
DecimalFormatSymbols dsf = DecimalFormatSymbols.getInstance(Locale.ROOT);
|
||||||
|
DecimalFormat result = new DecimalFormat(fmt, dsf);
|
||||||
result.setParseIntegerOnly(true);
|
result.setParseIntegerOnly(true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -40,13 +40,18 @@ public class ExcelStyleDateFormatter extends SimpleDateFormat {
|
|||||||
public static final char L_BRACKET_SYMBOL = '\ue016';
|
public static final char L_BRACKET_SYMBOL = '\ue016';
|
||||||
public static final char LL_BRACKET_SYMBOL = '\ue017';
|
public static final char LL_BRACKET_SYMBOL = '\ue017';
|
||||||
|
|
||||||
private DecimalFormat format1digit = new DecimalFormat("0");
|
private final DecimalFormat format1digit;
|
||||||
private DecimalFormat format2digits = new DecimalFormat("00");
|
private final DecimalFormat format2digits;
|
||||||
|
|
||||||
private DecimalFormat format3digit = new DecimalFormat("0");
|
private final DecimalFormat format3digit;
|
||||||
private DecimalFormat format4digits = new DecimalFormat("00");
|
private final DecimalFormat format4digits;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(Locale.ROOT);
|
||||||
|
format1digit = new DecimalFormat("0", dfs);
|
||||||
|
format2digits = new DecimalFormat("00", dfs);
|
||||||
|
format3digit = new DecimalFormat("0", dfs);
|
||||||
|
format4digits = new DecimalFormat("00", dfs);
|
||||||
DataFormatter.setExcelStyleRoundingMode(format1digit, RoundingMode.DOWN);
|
DataFormatter.setExcelStyleRoundingMode(format1digit, RoundingMode.DOWN);
|
||||||
DataFormatter.setExcelStyleRoundingMode(format2digits, RoundingMode.DOWN);
|
DataFormatter.setExcelStyleRoundingMode(format2digits, RoundingMode.DOWN);
|
||||||
DataFormatter.setExcelStyleRoundingMode(format3digit);
|
DataFormatter.setExcelStyleRoundingMode(format3digit);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package org.apache.poi.ss.util;
|
package org.apache.poi.ss.util;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -86,7 +87,7 @@ public class CellReference {
|
|||||||
* delimited and escaped as per normal syntax rules for formulas.
|
* delimited and escaped as per normal syntax rules for formulas.
|
||||||
*/
|
*/
|
||||||
public CellReference(String cellRef) {
|
public CellReference(String cellRef) {
|
||||||
if(cellRef.toUpperCase().endsWith("#REF!")) {
|
if(cellRef.toUpperCase(Locale.ROOT).endsWith("#REF!")) {
|
||||||
throw new IllegalArgumentException("Cell reference invalid: " + cellRef);
|
throw new IllegalArgumentException("Cell reference invalid: " + cellRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,12 +26,17 @@ import org.junit.runners.Suite;
|
|||||||
*/
|
*/
|
||||||
@RunWith(Suite.class)
|
@RunWith(Suite.class)
|
||||||
@Suite.SuiteClasses({
|
@Suite.SuiteClasses({
|
||||||
|
TestAreaReference.class,
|
||||||
TestCellRangeAddress.class,
|
TestCellRangeAddress.class,
|
||||||
TestCellReference.class,
|
TestCellReference.class,
|
||||||
|
TestDateFormatConverter.class,
|
||||||
TestExpandedDouble.class,
|
TestExpandedDouble.class,
|
||||||
TestNumberComparer.class,
|
TestNumberComparer.class,
|
||||||
TestNumberToTextConverter.class,
|
TestNumberToTextConverter.class,
|
||||||
TestRegion.class
|
TestRegion.class,
|
||||||
|
TestSheetBuilder.class,
|
||||||
|
TestSheetUtil.class,
|
||||||
|
TestWorkbookUtil.class
|
||||||
})
|
})
|
||||||
public class AllSSUtilTests {
|
public class AllSSUtilTests {
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ public final class TestDateFormatConverter extends TestCase {
|
|||||||
private void outputLocaleDataFormats( Date date, boolean dates, boolean times, int style, String styleName ) throws Exception {
|
private void outputLocaleDataFormats( Date date, boolean dates, boolean times, int style, String styleName ) throws Exception {
|
||||||
|
|
||||||
Workbook workbook = new HSSFWorkbook();
|
Workbook workbook = new HSSFWorkbook();
|
||||||
|
try {
|
||||||
String sheetName;
|
String sheetName;
|
||||||
if( dates ) {
|
if( dates ) {
|
||||||
if( times ) {
|
if( times ) {
|
||||||
@ -114,6 +115,9 @@ public final class TestDateFormatConverter extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Open " + outputFile.getAbsolutePath()+" in Excel");
|
System.out.println("Open " + outputFile.getAbsolutePath()+" in Excel");
|
||||||
|
} finally {
|
||||||
|
workbook.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testJavaDateFormatsInExcel() throws Exception {
|
public void testJavaDateFormatsInExcel() throws Exception {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user