org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler.SheetContentsHandler Java Examples

The following examples show how to use org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler.SheetContentsHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XLSX2CSV.java    From azeroth with Apache License 2.0 5 votes vote down vote up
/**
 * Parses and shows the content of one sheet using the specified styles and
 * shared-strings tables.
 *
 * @param styles
 * @param strings
 * @param sheetInputStream
 */
public void processSheet(StylesTable styles, ReadOnlySharedStringsTable strings, SheetContentsHandler sheetHandler,
                         InputStream sheetInputStream) throws IOException, ParserConfigurationException, SAXException {
    DataFormatter formatter = new DataFormatter();
    InputSource sheetSource = new InputSource(sheetInputStream);
    try {
        XMLReader sheetParser = SAXHelper.newXMLReader();
        ContentHandler handler = new XSSFSheetXMLHandler(styles, null, strings, sheetHandler, formatter, false);
        sheetParser.setContentHandler(handler);
        sheetParser.parse(sheetSource);
    } catch (ParserConfigurationException e) {
        throw new RuntimeException("SAX parser appears to be broken - " + e.getMessage());
    }
}
 
Example #2
Source File: XLSX2CSV.java    From jeesuite-libs with Apache License 2.0 5 votes vote down vote up
/**
 * Parses and shows the content of one sheet using the specified styles and
 * shared-strings tables.
 *
 * @param styles
 * @param strings
 * @param sheetInputStream
 */
public void processSheet(StylesTable styles, ReadOnlySharedStringsTable strings, SheetContentsHandler sheetHandler,
		InputStream sheetInputStream) throws IOException, ParserConfigurationException, SAXException {
	DataFormatter formatter = new DataFormatter();
	InputSource sheetSource = new InputSource(sheetInputStream);
	try {
		XMLReader sheetParser = SAXHelper.newXMLReader();
		ContentHandler handler = new XSSFSheetXMLHandler(styles, null, strings, sheetHandler, formatter, false);
		sheetParser.setContentHandler(handler);
		sheetParser.parse(sheetSource);
	} catch (ParserConfigurationException e) {
		throw new RuntimeException("SAX parser appears to be broken - " + e.getMessage());
	}
}
 
Example #3
Source File: ExcelReader.java    From excelReader with MIT License 3 votes vote down vote up
/**
 * Constructor: Microsoft Excel File (XSLX) Reader
 * 
 * @param pkg a {@link OPCPackage} object - The package to process XLSX
 * @param sheetContentsHandler a {@link SheetContentsHandler} object - WorkSheet contents handler
 * @param sheetCallback a {@link ExcelSheetCallback} object - WorkSheet callback for sheet
 *        processing begin and end (can be null)
 */
public ExcelReader(OPCPackage pkg, SheetContentsHandler sheetContentsHandler,
    ExcelSheetCallback sheetCallback) {
  this.xlsxPackage = pkg;
  this.sheetContentsHandler = sheetContentsHandler;
  this.sheetCallback = sheetCallback;
}
 
Example #4
Source File: ExcelReader.java    From excelReader with MIT License 2 votes vote down vote up
/**
 * Constructor: Microsoft Excel File (XSLX) Reader
 * 
 * @param filePath a {@link String} object - The path of XLSX file
 * @param sheetContentsHandler a {@link SheetContentsHandler} object - WorkSheet contents handler
 * @param sheetCallback a {@link ExcelSheetCallback} object - WorkSheet callback for sheet
 *        processing begin and end (can be null)
 */
public ExcelReader(String filePath, SheetContentsHandler sheetContentsHandler,
    ExcelSheetCallback sheetCallback) throws Exception {
  this(getOPCPackage(getFile(filePath)), sheetContentsHandler, sheetCallback);
}
 
Example #5
Source File: ExcelReader.java    From excelReader with MIT License 2 votes vote down vote up
/**
 * Constructor: Microsoft Excel File (XSLX) Reader
 * 
 * @param file a {@link File} object - The File object of XLSX file
 * @param sheetContentsHandler a {@link SheetContentsHandler} object - WorkSheet contents handler
 * @param sheetCallback a {@link ExcelSheetCallback} object - WorkSheet callback for sheet
 *        processing begin and end (can be null)
 */
public ExcelReader(File file, SheetContentsHandler sheetContentsHandler,
    ExcelSheetCallback sheetCallback) throws Exception {
  this(getOPCPackage(file), sheetContentsHandler, sheetCallback);
}