Apache Poi: Converting from HSSF to SS?

后端 未结 1 1897
再見小時候
再見小時候 2021-01-25 09:28

I\'ve converted all of my old code in HSSF to SS except for the portion where I make the work book.


Old Code: HSSFWorkbook wb = new HSSFWorkbook(n

相关标签:
1条回答
  • 2021-01-25 10:01

    Workbook is an interface, you can't instantiate it. Instead, what you want is WorkbookFactory. Pass that either a File or an InputStream, and it'll give you the appropriate Workbook instance

    Your old code:

    HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(file));
    

    Becomes:

    Workbook wb = WorkbookFactory.create(file);
    
    0 讨论(0)
提交回复
热议问题