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;
* Retreives the text contents of the file
*/
public String getText() {
- String text = null;
+ String text;
try {
TextListener tl = triggerExtraction();
} 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)) {
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();
}
}
}
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;
}
}
/**
* 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;
}
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;
}
}
output.append('\n');
}
+ @Override
+ public void endSheet() {
+ }
+
@Override
public void cell(String cellRef, String formattedValue, XSSFComment comment) {
if(firstCellOfRow) {