mirror of https://github.com/apache/poi.git
[bug-66365] rework XSSFCell getRichStringCellValue and getStringCellValue to better support array formula results. Thanks to Espen Amble Kolstad.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1905571 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
17bcceb615
commit
efc032babc
|
@ -297,6 +297,25 @@ public final class XSSFCell extends CellBase {
|
|||
rt = new XSSFRichTextString("");
|
||||
break;
|
||||
case STRING:
|
||||
rt = findStringValue();
|
||||
break;
|
||||
case FORMULA: {
|
||||
CellType cachedValueType = getBaseCellType(false);
|
||||
if (cachedValueType != CellType.STRING) {
|
||||
throw typeMismatch(CellType.STRING, cachedValueType, true);
|
||||
}
|
||||
rt = findStringValue();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw typeMismatch(CellType.STRING, cellType, false);
|
||||
}
|
||||
rt.setStylesTableReference(_stylesSource);
|
||||
return rt;
|
||||
}
|
||||
|
||||
private XSSFRichTextString findStringValue() {
|
||||
XSSFRichTextString rt;
|
||||
STCellType.Enum xmlbeanCellType = _cell.getT();
|
||||
if (xmlbeanCellType == STCellType.INLINE_STR) {
|
||||
if(_cell.isSetIs()) {
|
||||
|
@ -323,19 +342,6 @@ public final class XSSFCell extends CellBase {
|
|||
rt = new XSSFRichTextString("");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FORMULA: {
|
||||
CellType cachedValueType = getBaseCellType(false);
|
||||
if (cachedValueType != CellType.STRING) {
|
||||
throw typeMismatch(CellType.STRING, cachedValueType, true);
|
||||
}
|
||||
rt = new XSSFRichTextString(_cell.isSetV() ? _cell.getV() : "");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw typeMismatch(CellType.STRING, cellType, false);
|
||||
}
|
||||
rt.setStylesTableReference(_stylesSource);
|
||||
return rt;
|
||||
}
|
||||
|
||||
|
|
|
@ -754,6 +754,17 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void bug66365() throws Exception {
|
||||
try (XSSFWorkbook wb = openSampleWorkbook("66365.xlsx")) {
|
||||
XSSFSheet sheet1 = wb.getSheetAt(0);
|
||||
assertEquals(sheet1.getRow(0).getCell(0).getStringCellValue(),
|
||||
sheet1.getRow(0).getCell(1).getStringCellValue());
|
||||
assertEquals(sheet1.getRow(1).getCell(0).getStringCellValue(),
|
||||
sheet1.getRow(1).getCell(1).getStringCellValue());
|
||||
}
|
||||
}
|
||||
|
||||
private static final int INDEX_NOT_FOUND = -1;
|
||||
|
||||
private static boolean isEmpty(CharSequence cs) {
|
||||
|
|
|
@ -1168,3 +1168,8 @@ ctshapenonvisual6121type
|
|||
ctsdtrow2f71type
|
||||
ctsdtcontentrow740etype
|
||||
cttableformulaf801type
|
||||
sttotalsrowfunctioncb72type
|
||||
ctbubblechart3ff4type
|
||||
ctbubblesere172type
|
||||
ctdlblpos9ce4type
|
||||
stdlblpos1cf4type
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue