aboutsummaryrefslogtreecommitdiffstats
path: root/poi-ooxml
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2022-09-02 22:54:03 +0000
committerPJ Fanning <fanningpj@apache.org>2022-09-02 22:54:03 +0000
commite485bf0b652f55764520a47d630bdbe91b080b7d (patch)
tree1f1f74d1da158b5dd55781126dfbb41134cbf8cc /poi-ooxml
parentff2e90e9a5ccc69a65733aee47c30dae32a11bee (diff)
downloadpoi-e485bf0b652f55764520a47d630bdbe91b080b7d.tar.gz
poi-e485bf0b652f55764520a47d630bdbe91b080b7d.zip
add CellUtil test
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1903837 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r--poi-ooxml/src/test/java/org/apache/poi/ss/tests/util/TestXSSFCellUtil.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/poi-ooxml/src/test/java/org/apache/poi/ss/tests/util/TestXSSFCellUtil.java b/poi-ooxml/src/test/java/org/apache/poi/ss/tests/util/TestXSSFCellUtil.java
index 8a6f85e85a..8b0547cb69 100644
--- a/poi-ooxml/src/test/java/org/apache/poi/ss/tests/util/TestXSSFCellUtil.java
+++ b/poi-ooxml/src/test/java/org/apache/poi/ss/tests/util/TestXSSFCellUtil.java
@@ -20,6 +20,7 @@ package org.apache.poi.ss.tests.util;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
@@ -31,7 +32,11 @@ import org.apache.poi.xssf.usermodel.XSSFColor;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.jupiter.api.Test;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.OutputStream;
+import java.util.LinkedHashMap;
+import java.util.Map;
import static org.junit.jupiter.api.Assertions.*;
@@ -83,4 +88,37 @@ class TestXSSFCellUtil extends BaseTestCellUtil {
assertEquals(IndexedColors.AUTOMATIC.getIndex(), cell.getCellStyle().getFillForegroundColor());
}
}
+
+ @Test
+ public void testSetForegroundColorCellStylePropertiesToNull() throws IOException, DecoderException {
+
+ try (Workbook workbook = new XSSFWorkbook()) {
+
+ final Sheet sheet = workbook.createSheet("Sheet");
+ final Row row = sheet.createRow(0);
+ final Cell cell = row.createCell(0);
+ final XSSFColor color = new XSSFColor(Hex.decodeHex("FF0000"));
+
+ {
+ final Map<String, Object> properties = new LinkedHashMap<>();
+
+ properties.put(CellUtil.FILL_FOREGROUND_COLOR_COLOR, color);
+ properties.put(CellUtil.FILL_PATTERN, FillPatternType.SOLID_FOREGROUND);
+
+ CellUtil.setCellStyleProperties(cell, properties);
+ }
+ assertEquals(color, cell.getCellStyle().getFillForegroundColorColor());
+
+ {
+ final Map<String, Object> properties = new LinkedHashMap<>();
+
+ properties.put(CellUtil.FILL_FOREGROUND_COLOR_COLOR, null);
+ properties.put(CellUtil.FILL_PATTERN, FillPatternType.NO_FILL);
+
+ CellUtil.setCellStyleProperties(cell, properties);
+ }
+ assertNull(cell.getCellStyle().getFillForegroundColorColor());
+ assertEquals(IndexedColors.AUTOMATIC.getIndex(), cell.getCellStyle().getFillForegroundColor());
+ }
+ }
} \ No newline at end of file