This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git


The following commit(s) were added to refs/heads/trunk by this push:
     new e4e4582689 add cell tests (#965)
e4e4582689 is described below

commit e4e45826891aac6314058366189cfec14000cbe7
Author: PJ Fanning <[email protected]>
AuthorDate: Mon Dec 8 20:56:38 2025 +0100

    add cell tests (#965)
---
 .../apache/poi/xssf/usermodel/TestXSSFCell.java    | 45 ++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git 
a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFCell.java 
b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFCell.java
index 742b29af49..30363faf06 100644
--- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFCell.java
+++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFCell.java
@@ -61,6 +61,7 @@ import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.EnumSource;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellFormulaType;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType;
 
@@ -762,4 +763,48 @@ public final class TestXSSFCell extends BaseTestXCell {
         Cell cell = new 
XSSFWorkbook().createSheet().createRow(0).createCell(0);
         assertThrows(IllegalStateException.class, cell::getErrorCellValue);
     }
+
+    @Test
+    void setStringToBlank() throws IOException {
+        try (XSSFWorkbook wb = new XSSFWorkbook()) {
+            XSSFSheet sheet = wb.createSheet();
+            XSSFCell cell = sheet.createRow(0).createCell(0);
+            cell.setCellValue("test123");
+            cell.setCellType(CellType.BLANK);
+            assertEquals("", cell.getStringCellValue());
+        }
+    }
+
+    @Test
+    void setInlineStringToBlank() throws IOException {
+        try (XSSFWorkbook wb = new XSSFWorkbook()) {
+            XSSFSheet sheet = wb.createSheet();
+            XSSFCell cell = sheet.createRow(0).createCell(0);
+            cell.setCellType(CellType.STRING);
+            CTRst rst = CTRst.Factory.newInstance();
+            rst.setT("text123");
+            cell.getCTCell().setT(STCellType.INLINE_STR);
+            cell.getCTCell().setIs(rst);
+            assertEquals("text123", cell.getStringCellValue());
+            cell.setCellType(CellType.BLANK);
+            assertEquals("", cell.getStringCellValue());
+            assertFalse(cell.getCTCell().isSetIs(), "cell has InlineString XML 
struct still?");
+        }
+    }
+
+    @Test
+    void setFormulaToBlank() throws IOException {
+        try (XSSFWorkbook wb = new XSSFWorkbook()) {
+            XSSFSheet sheet = wb.createSheet();
+            XSSFCell cell = sheet.createRow(0).createCell(0);
+            cell.setCellFormula("ISODD(1)");
+            cell.setCellValue("3.14");
+            assertTrue(cell.getCTCell().isSetF(), "cell has formula XML 
struct?");
+            assertEquals("ISODD(1)", cell.getCellFormula());
+            assertEquals("3.14", cell.getStringCellValue());
+            cell.setCellType(CellType.BLANK);
+            assertEquals("", cell.getStringCellValue());
+            assertFalse(cell.getCTCell().isSetF(), "cell has formula XML 
struct still?");
+        }
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to