1
當我嘗試初始化一個工作簿對象,我總是得到這個錯誤:爲什麼我未能使用POI讀取Excel 2007?
The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF)
但我跟着辦公樣品要做到這一點,下面是我的代碼:
File inputFile = new File(inputFileName);
InputStream is = new FileInputStream(inputFile);
Workbook wb = new XSSFWorkbook(is);
異常出現在代碼行:
Workbook wb = new XSSFWorkbook(is);
下面是POI JAR包括:
poi-3.8-20120326.jar
poi-ooxml-3.8-20120326.jar
poi-ooxml-schemas-3.8-20120326.jar
xmlbeans-2.3.0.jar
任何人都可以給我指導嗎?顯示如何閱讀完整的Excel 2007文檔的示例將不勝感激。提前致謝!
我覺得我的Excel源代碼沒有問題。 –
解決。我可以通過以下代碼閱讀: File inputFile = new File(inputFileName); Workbook wb = WorkbookFactory.create(new FileInputStream(inputFile)); 即使它工作,我不知道下面和上面的代碼之間有什麼區別。 –
看到我上面編輯的答案 –