[bug-67442] add test

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912366 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2023-09-17 14:49:16 +00:00
parent 9e2ce70d2b
commit 8514b659ae
2 changed files with 28 additions and 0 deletions

View File

@ -35,6 +35,7 @@ import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -2386,4 +2387,31 @@ public final class TestXSSFSheet extends BaseTestXSheet {
sheet.addHyperlink(hyperlink);
return wb;
}
@Test
void testSetBlankOnNestedSharedFormulas() throws IOException {
try (XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("testSharedFormulasSetBlank.xlsx")) {
XSSFSheet s1 = wb1.getSheetAt(0);
assertNotNull(s1);
Iterator<Row> rowIterator = s1.rowIterator();
int count = 0;
StringBuilder sb = new StringBuilder();
while (rowIterator.hasNext()) {
Row row = rowIterator.next();
Iterator<Cell> cellIterator = row.cellIterator();
while (cellIterator.hasNext()) {
Cell cell = cellIterator.next();
// the toString is needed to exhibit the broken state
sb.append(cell.toString()).append(",");
count++;
// breaks the sheet state
cell.setBlank();
}
}
assertEquals(10, count);
assertEquals("2-1,2-1,1+2,2-1,2-1,3+3,3+3,3+3,2-1,2-1,", sb.toString());
}
}
}