How to process old excel .xls files using POI?

前端 未结 2 414
伪装坚强ぢ
伪装坚强ぢ 2020-12-10 10:46

I switched from jxl to poi since POI has more features. However, I wasn\'t able to process the xls files that were generated in the old format. Now I am getting this error:<

2条回答
  •  一个人的身影
    2020-12-10 11:07

    as per my knowledge you can use this code to read excel files of the .xls format

    FileInputStream in=new FileInputStream(new File("filename.xls"));
    Wookbook wb=new HSSFWorkbook(in);
    

    to read the new excel versions(2007 and up):

     FileInputStream in=new FileInputStream(new File("filename.xls"));
        Wookbook wb=new XSSFWorkbook(in);
    

    external jar files that you will need:

     1. poi-3.9 
     2. dom4j-1.6.1
     3. XMLbeams-2.5.0
    

    if you're work only requires you to work with .xls then only poi-3.0 will suffice. You need the other jars to work witht the new versions of excel.

提交回复
热议问题