poi 解析excel问题

以下是程序中的一段代码,正常的的excel2003或者2007文件都能解析,以及2007的文件另存在2003的文件之后也能够正常导入;

问题:2003的文件另存为2007的文件之后,导入就出现异常了;

[code="java"]publicWorkbook getWorkbook(File file,String fileName){

    Workbook wb = null;
    InputStream input = null;
    if(file == null || fileName == null)
    {
        return wb;
    }
    //获取excel文件
    try
    {
        input = new FileInputStream(file);
        if (!input.markSupported()) {
            input = new PushbackInputStream(input, 8);
        }
        if (POIFSFileSystem.hasPOIFSHeader(input)) {//2003
             wb = new HSSFWorkbook(input);
        }else if (POIXMLDocument.hasOOXMLHeader(input)) {//2007
            wb = new XSSFWorkbook(OPCPackage.open(input));
        }else{
            System.out.println("不支持");
        }

    }
    catch (Exception e)
    {
        e.printStackTrace();
    }    
    return wb;

}[/code]

望哪位朋友指点下~

2003的文件另存为2007文件问题吧。
“2007的文件另存在2003的文件之后也能够正常导入”他向下兼容啊,你07的文件,用03的软件能打开?

POI现在可以搞07了吗?

你确定是2003保存为2007后,你的代码里执行的是直接跳到输出“不支持”了嚒?

如果改用后缀名来打开文件呢?

[quote]publicWorkbook getWorkbook(File file,String fileName){
Workbook wb;
if(fileName.substring(fileName.lastIndexOf(".")+1).equals("xls")) {
wb = new HSSFWorkbook();
} else {
wb = new XSSFWorkbook();
}
。。。。。。。。。。。。
[/quote]