我使用Apache讀取xls文件POI 3.8,但我得到異常:無法讀取整個標題; 0字節讀取;預期512個字節
java.io.IOException: Unable to read entire header; 0 bytes read; expected 512 bytes
at org.apache.poi.poifs.storage.HeaderBlock.alertShortRead(HeaderBlock.java:226)
at org.apache.poi.poifs.storage.HeaderBlock.readFirst512(HeaderBlock.java:207)
at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:104)
at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:138)
使用的代碼示例:
FileInputStream myInput = new FileInputStream(excelFilePathWithExtension);
logger.debug("FileInputStream::"+myInput);
POIFSFileSystem myFileSystem = new POIFSFileSystem(myInput);
logger.debug("POIFSFileSystem::"+myFileSystem);
Workbook workbook = WorkbookFactory.create(myFileSystem);
幫我嗎?
你確定該文件不是空的嗎? – Thilo
你可以在excel或openOffice中打開文件嗎?如果不是則文件損壞 –
文件不爲空 –