private Locale locale;
private final XSSFWorkbook workbook;
+ private final DataFormatter dataFormatter;
private boolean includeSheetNames = true;
private boolean formulasNotResults;
private boolean includeCellComments;
}
public XSSFExcelExtractor(XSSFWorkbook workbook) {
this.workbook = workbook;
+ this.dataFormatter = new DataFormatter();
+ this.dataFormatter.setUseCachedValuesForFormulaCells(true);
}
/**
}
// No supported styling applies to this cell
- String contents = ((XSSFCell)cell).getRawValue();
+ String contents = dataFormatter.formatCellValue(cell);
if (contents != null) {
+ if (type == CellType.ERROR) {
+ // to match what XSSFEventBasedExcelExtractor does
+ contents = "ERROR:" + contents;
+ }
checkMaxTextSize(text, contents);
text.append(contents);
}
}
}
+ @Test
+ void test67784() throws Exception {
+ try (XSSFExcelExtractor extractor = getExtractor("bug67784.xlsx")) {
+ String text = extractor.getText().replace("\r", "");
+ String[] lines = text.split("\n");
+ assertEquals("FALSE", lines[2]);
+ assertEquals("TRUE", lines[3]);
+ assertEquals("ERROR:#DIV/0!", lines[4]);
+ }
+ }
+
@Test
void test67784Formulas() throws Exception {
try (XSSFExcelExtractor extractor = getExtractor("bug67784.xlsx")) {