aboutsummaryrefslogtreecommitdiffstats
path: root/poi
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-12-08 18:28:14 +0000
committerPJ Fanning <fanningpj@apache.org>2021-12-08 18:28:14 +0000
commit548dfb37f5ef1e3bc770e47cb10e0206daea9c09 (patch)
tree8ac23f26058cc513e8f70d885c4b75a10e89e41c /poi
parentb174eb57703f417cad0e8f52e7f7003ca2e81f74 (diff)
downloadpoi-548dfb37f5ef1e3bc770e47cb10e0206daea9c09.tar.gz
poi-548dfb37f5ef1e3bc770e47cb10e0206daea9c09.zip
update tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895703 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi')
-rw-r--r--poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java18
-rw-r--r--poi/src/test/java/org/apache/poi/ss/usermodel/TestDataFormatter.java30
2 files changed, 47 insertions, 1 deletions
diff --git a/poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java b/poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java
index f9a1fedc5f..7a18d30e68 100644
--- a/poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java
+++ b/poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java
@@ -204,7 +204,7 @@ public class DataFormatter {
private final Map<String,Format> formats = new HashMap<>();
/** whether CSV friendly adjustments should be made to the formatted text **/
- private final boolean emulateCSV;
+ private boolean emulateCSV = false;
/** whether years in dates should be displayed with 4 digits even if the formatString specifies only 2 **/
private boolean use4DigitYearsInAllDateFormats = false;
@@ -276,6 +276,22 @@ public class DataFormatter {
}
/**
+ * @param emulateCSV whether to emulate CSV output (default false).
+ * @since POI 5.2.0
+ */
+ public void setEmulateCSV(boolean emulateCSV) {
+ this.emulateCSV = emulateCSV;
+ }
+
+ /**
+ * @return whether to emulate CSV output (default false).
+ * @since POI 5.2.0
+ */
+ public boolean isEmulateCSV() {
+ return emulateCSV;
+ }
+
+ /**
* @param useCachedValuesForFormulaCells if set to true, when you do not provide a {@link FormulaEvaluator},
* for cells with formulas, we will return the cached value for the cell (if available),
* otherwise - we return the formula itself.
diff --git a/poi/src/test/java/org/apache/poi/ss/usermodel/TestDataFormatter.java b/poi/src/test/java/org/apache/poi/ss/usermodel/TestDataFormatter.java
index ebc657bac7..21744b9b88 100644
--- a/poi/src/test/java/org/apache/poi/ss/usermodel/TestDataFormatter.java
+++ b/poi/src/test/java/org/apache/poi/ss/usermodel/TestDataFormatter.java
@@ -83,6 +83,36 @@ class TestDataFormatter {
+ "Having: " + System.getProperty("user.language") + "/" + System.getProperty("user.country"));
}
+ @Test
+ void setEmulateCSV() {
+ DataFormatter dataFormatter = new DataFormatter();
+ assertFalse(dataFormatter.isEmulateCSV());
+ dataFormatter.setEmulateCSV(true);
+ assertTrue(dataFormatter.isEmulateCSV());
+ dataFormatter.setEmulateCSV(false);
+ assertFalse(dataFormatter.isEmulateCSV());
+ }
+
+ @Test
+ void setUse4DigitYearsInAllDateFormats() {
+ DataFormatter dataFormatter = new DataFormatter();
+ assertFalse(dataFormatter.use4DigitYearsInAllDateFormats());
+ dataFormatter.setUse4DigitYearsInAllDateFormats(true);
+ assertTrue(dataFormatter.use4DigitYearsInAllDateFormats());
+ dataFormatter.setUse4DigitYearsInAllDateFormats(false);
+ assertFalse(dataFormatter.use4DigitYearsInAllDateFormats());
+ }
+
+ @Test
+ void useCachedValuesForFormulaCells() {
+ DataFormatter dataFormatter = new DataFormatter();
+ assertFalse(dataFormatter.useCachedValuesForFormulaCells());
+ dataFormatter.setUseCachedValuesForFormulaCells(true);
+ assertTrue(dataFormatter.useCachedValuesForFormulaCells());
+ dataFormatter.setUseCachedValuesForFormulaCells(false);
+ assertFalse(dataFormatter.useCachedValuesForFormulaCells());
+ }
+
/**
* Test that we use the specified locale when deciding
* how to format normal numbers