Bug 60352: Text extraction: Don't include the text "null" for empty cells
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1794260 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8313b17515
commit
d9df038f4a
@ -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) {
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user