diff --git a/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java b/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java index 192d60d71..f479ef3b4 100644 --- a/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java +++ b/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java @@ -55,8 +55,8 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor private Locale locale; private XSSFWorkbook workbook; private boolean includeSheetNames = true; - private boolean formulasNotResults = false; - private boolean includeCellComments = false; + private boolean formulasNotResults; + private boolean includeCellComments; private boolean includeHeadersFooters = true; private boolean includeTextBoxes = true; @@ -110,7 +110,7 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor } /** * Should text within textboxes be included? Default is true - * @param includeTextBoxes + * @param includeTextBoxes True if textboxes should be included, false if not. */ public void setIncludeTextBoxes(boolean includeTextBoxes){ this.includeTextBoxes = includeTextBoxes; @@ -255,8 +255,10 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor // No supported styling applies to this cell String contents = ((XSSFCell)cell).getRawValue(); - checkMaxTextSize(text, contents); - text.append( contents ); + if (contents != null) { + checkMaxTextSize(text, contents); + text.append(contents); + } } private String extractHeaderFooter(HeaderFooter hf) { diff --git a/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExcelExtractor.java b/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExcelExtractor.java index 3fc281808..f4450c010 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExcelExtractor.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/extractor/TestXSSFExcelExtractor.java @@ -45,7 +45,6 @@ public class TestXSSFExcelExtractor extends TestCase { /** * Get text out of the simple file - * @throws IOException */ public void testGetSimpleText() throws IOException { // a very simple file @@ -105,7 +104,7 @@ public class TestXSSFExcelExtractor extends TestCase { extractor.close(); } - + public void testGetComplexText() throws IOException { // A fairly complex file XSSFExcelExtractor extractor = getExtractor("AverageTaxRates.xlsx"); @@ -114,10 +113,9 @@ public class TestXSSFExcelExtractor extends TestCase { assertTrue(text.length() > 0); // Might not have all formatting it should do! - // TODO decide if we should really have the "null" in there - assertStartsWith(text, + assertStartsWith(text, "Avgtxfull\n" + - "null\t(iii) AVERAGE TAX RATES ON ANNUAL" + "\t(iii) AVERAGE TAX RATES ON ANNUAL" ); extractor.close(); @@ -127,7 +125,6 @@ public class TestXSSFExcelExtractor extends TestCase { * Test that we return pretty much the same as * ExcelExtractor does, when we're both passed * the same file, just saved as xls and xlsx - * @throws IOException */ public void testComparedToOLE2() throws IOException { // A fairly simple file - ooxml @@ -156,7 +153,6 @@ public class TestXSSFExcelExtractor extends TestCase { /** * From bug #45540 - * @throws IOException */ public void testHeaderFooter() throws IOException { String[] files = new String[] { @@ -176,7 +172,6 @@ public class TestXSSFExcelExtractor extends TestCase { /** * From bug #45544 - * @throws IOException */ public void testComments() throws IOException { XSSFExcelExtractor extractor = getExtractor("45544.xlsx"); @@ -220,7 +215,6 @@ public class TestXSSFExcelExtractor extends TestCase { } /** * Simple test for text box text - * @throws IOException */ public void testTextBoxes() throws IOException { XSSFExcelExtractor extractor = getExtractor("WithTextBox.xlsx");