我尝试使用jxl读取excel文件。它正在提供StringIndexOutOfBoundsException
。我不知道为什么我会为此代码获取该代码。
public class TestExcelReader {
public static void main(String args[]) throws BiffException, IOException{
File file=new File("D:\\TestExcel.xls");
Workbook workbook=Workbook.getWorkbook(file); \\Line number 14
Sheet sheet=workbook.getSheet(0);
System.out.println("No of rows is "+sheet.getRows());
}
}
我的例外:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 68
at java.lang.String.checkBounds(Unknown Source)
at java.lang.String.<init>(Unknown Source)
at jxl.biff.StringHelper.getString(StringHelper.java:164)
at jxl.read.biff.WriteAccessRecord.<init>(WriteAccessRecord.java:56)
at jxl.read.biff.WorkbookParser.parse(WorkbookParser.java:821)
at jxl.Workbook.getWorkbook(Workbook.java:237)
at jxl.Workbook.getWorkbook(Workbook.java:198)
at ext.gt.test.TestExcelReader.main(TestExcelReader.java:14)
答案 0 :(得分:2)
问题是因为您使用的是Excel95文件,不幸的是它似乎不受支持(只有Excel97之后的文件)。
在这里
http://www.java-forum.org/allgemeine-java-themen/140138-java-tabelle-auslesen-xls-excel-fehler.html