代码内容如下:
public class TestReadXls {
/*** @param args
* @throws IOException
* @throws BiffException
*/
public static void main(String[] args) throws BiffException, IOException {
// TODO Auto-generated method stub
Workbook infoWorkbook = Workbook.getWorkbook(new File("E:/工作表.xlsx"));
Sheet sheet = infoWorkbook.getSheet(0);
int size = sheet.getRows();
for (int i = 0; i < size; i++) {
Cell cell = sheet.getCell(0, i);
String str = cell.getContents();
System.out.println("str" + i + ":" + str);
}
}
}
运行的时候提示:Unable to recognize OLE stream
原因是这个xlsx文件是office2010,需要打开文件后,保存成office2003版.xls文件即可