当前页面: 开发资料首页 → JSP 专题 → poi 读取XLS文件时出现IO常
poi 读取XLS文件时出现IO常
摘要: poi 读取XLS文件时出现IO常
.....
public static void main(String[] args) {
try {
POIFSFileSystem f=new POIFSFileSystem(new FileInputStream("d:/a.xls"));
//这里出错:java.io.IOException: Unable to read entire block; 362 bytes read; expected 512 bytes
HSSFWorkbook workbook = new HSSFWorkbook(f);
HSSFSheet sheet = workbook.getSheetAt(0);
HSSFRow firstRow = sheet.getRow(0);
......
完整出错信息:
java.io.IOException: Unable to read entire block; 362 bytes read; expected 512 bytes
at org.apache.poi.poifs.storage.RawDataBlock.
(RawDataBlock.java:62)
at org.apache.poi.poifs.storage.RawDataBlockList.(RawDataBlockList.java:51)
at org.apache.poi.poifs.filesystem.POIFSFileSystem.(POIFSFileSystem.java:86)
at ReadXLS.main(ReadXLS.java:190)
已运行ReadXLS:java.io.IOException: Unable to read entire block; 362 bytes read; expected 512 bytes
用这个读两个不同的XLS文件,一个可以,另一个就报这个错!!!
是不是因为这两个XLS文件的格式问题!!!哪位大侠给指个路!!!
建议你再多弄几个Excel试试,估计多数是Excel的问题。