本文整理汇总了Java中org.apache.poi.poifs.filesystem.DocumentFactoryHelper类的典型用法代码示例。如果您正苦于以下问题:Java DocumentFactoryHelper类的具体用法?Java DocumentFactoryHelper怎么用?Java DocumentFactoryHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DocumentFactoryHelper类属于org.apache.poi.poifs.filesystem包,在下文中一共展示了DocumentFactoryHelper类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handlesMagic
import org.apache.poi.poifs.filesystem.DocumentFactoryHelper; //导入依赖的package包/类
@Override
public boolean handlesMagic(InputStream stream) {
try {
return DocumentFactoryHelper.hasOOXMLHeader(stream);
} catch (Exception e) {
LOGGER.warn("An exception occured", e);
return false;
}
}
示例2: createPOIWorkbook
import org.apache.poi.poifs.filesystem.DocumentFactoryHelper; //导入依赖的package包/类
/**
* http://stackoverflow.com/questions/12593752/why-do-i-failed-to-read-excel-2007-using-poi
*
* @param inp
* @return
* @throws IOException
* @throws InvalidFormatException
*/
public static Workbook createPOIWorkbook(InputStream inp) throws IOException, InvalidFormatException {
// If clearly doesn't do mark/reset, wrap up
if(!inp.markSupported()) {
inp = new PushbackInputStream(inp, 8);
}
if(POIFSFileSystem.hasPOIFSHeader(inp)) {
return new HSSFWorkbook(inp);
}
if(DocumentFactoryHelper.hasOOXMLHeader(inp)) {
return new XSSFWorkbook(OPCPackage.open(inp));
}
throw new IllegalArgumentException("Your InputStream was neither an OLE2 stream, nor an OOXML stream");
}