diff --git a/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java b/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java index f83cc9c47c..725dab59d9 100644 --- a/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java +++ b/src/java/org/apache/poi/hssf/extractor/EventBasedExcelExtractor.java @@ -40,7 +40,6 @@ import org.apache.poi.hssf.record.NumberRecord; import org.apache.poi.hssf.record.Record; import org.apache.poi.hssf.record.SSTRecord; import org.apache.poi.hssf.record.StringRecord; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.POIFSFileSystem; @@ -128,7 +127,7 @@ public class EventBasedExcelExtractor extends POIOLE2TextExtractor implements or * Retreives the text contents of the file */ public String getText() { - String text = null; + String text; try { TextListener tl = triggerExtraction(); diff --git a/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java b/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java index 8f7b30d3c1..1b343e4c07 100644 --- a/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java +++ b/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java @@ -394,6 +394,9 @@ public class XSSFSheetXMLHandler extends DefaultHandler { } else if ("sheetData".equals(localName)) { // Handle any "missing" cells which had comments attached checkForEmptyCellComments(EmptyCellCommentsCheckType.END_OF_SHEET_DATA); + + // indicate that this sheet is now done + output.endSheet(); } else if("oddHeader".equals(localName) || "evenHeader".equals(localName) || "firstHeader".equals(localName)) { @@ -502,13 +505,19 @@ public class XSSFSheetXMLHandler extends DefaultHandler { public interface SheetContentsHandler { /** A row with the (zero based) row number has started */ public void startRow(int rowNum); + /** A row with the (zero based) row number has ended */ public void endRow(int rowNum); - /** + + /** * A cell, with the given formatted value (may be null), * and possibly a comment (may be null), was encountered */ public void cell(String cellReference, String formattedValue, XSSFComment comment); + /** A header or footer has been encountered */ public void headerFooter(String text, boolean isHeader, String tagName); + + /** Signal that the end of a sheet was been reached */ + public void endSheet(); } } diff --git a/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFBEventBasedExcelExtractor.java b/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFBEventBasedExcelExtractor.java index a55686f797..4772bca593 100644 --- a/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFBEventBasedExcelExtractor.java +++ b/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFBEventBasedExcelExtractor.java @@ -151,15 +151,9 @@ public class XSSFBEventBasedExcelExtractor extends XSSFEventBasedExcelExtractor } return text.toString(); - } catch (IOException e) { + } catch (IOException | OpenXML4JException | SAXException e) { LOGGER.log(POILogger.WARN, e); return null; - } catch (SAXException se) { - LOGGER.log(POILogger.WARN, se); - return null; - } catch (OpenXML4JException o4je) { - LOGGER.log(POILogger.WARN, o4je); - return null; } } diff --git a/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFEventBasedExcelExtractor.java b/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFEventBasedExcelExtractor.java index 000ee5387c..efcce6f94b 100644 --- a/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFEventBasedExcelExtractor.java +++ b/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFEventBasedExcelExtractor.java @@ -178,7 +178,7 @@ public class XSSFEventBasedExcelExtractor extends POIXMLTextExtractor /** * Concatenate text from <rPh> text elements in SharedStringsTable * Default is true; - * @param concatenatePhoneticRuns + * @param concatenatePhoneticRuns true if runs should be concatenated, false otherwise */ public void setConcatenatePhoneticRuns(boolean concatenatePhoneticRuns) { this.concatenatePhoneticRuns = concatenatePhoneticRuns; @@ -293,15 +293,9 @@ public class XSSFEventBasedExcelExtractor extends POIXMLTextExtractor } return text.toString(); - } catch(IOException e) { + } catch(IOException | OpenXML4JException | SAXException e) { LOGGER.log(POILogger.WARN, e); return null; - } catch(SAXException se) { - LOGGER.log(POILogger.WARN, se); - return null; - } catch(OpenXML4JException o4je) { - LOGGER.log(POILogger.WARN, o4je); - return null; } } @@ -348,6 +342,10 @@ public class XSSFEventBasedExcelExtractor extends POIXMLTextExtractor output.append('\n'); } + @Override + public void endSheet() { + } + @Override public void cell(String cellRef, String formattedValue, XSSFComment comment) { if(firstCellOfRow) {