代码如下:
InputStream inp = xxx
if(! inp.markSupported()) {
inp = new PushbackInputStream(inp, 8)
}
if(POIFSFileSystem.hasPOIFSHeader(inp)) {
System.out.println("2003及以下")
}
if(POIXMLDocument.hasOOXMLHeader(inp)) {
System.out.println("2007及以上")
}
apache poiWorkbook hssWB = null
try {
//2003
hssWB = new HSSFWorkbook(new FileInputStream("excel文件"))
} catch (Exception e) {
//培饥坦 TODO: handle exception
//2007
hssWB = new XSSFWorkbook(new FileInputStream("配桐肢汪excel文件"))
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)