导入excel是,出现String index out of range: -2提示,这是怎么回事啊!
Stringindexoutofrange:-2atjava.lang.String.substring(String.java:1938)atjava.lang.Str...
String index out of range: -2
at
java.lang.String.substring(String.java:1938)
at
java.lang.String.substring(String.java:1905)
at
jxl.biff.HeaderFooter.<init>(HeaderFooter.java:542)
at
jxl.HeaderFooter.<init>(HeaderFooter.java:297)
at
jxl.read.biff.SheetReader.read(SheetReader.java:640)
at
jxl.read.biff.SheetImpl.readSheet(SheetImpl.java:611)
at
jxl.read.biff.WorkbookParser.getSheet(WorkbookParser.java:230)
at
com.dsxx.dao.ExcelDao.upExcelDb(ExcelDao.java:214)
at
com.dsxx.service.ExcelService.upExcelToDb(ExcelService.java:60)
at
com.dsxx.actions.PreWorkAction.getUploadPath(PreWorkAction.java:72)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 展开
at
java.lang.String.substring(String.java:1938)
at
java.lang.String.substring(String.java:1905)
at
jxl.biff.HeaderFooter.<init>(HeaderFooter.java:542)
at
jxl.HeaderFooter.<init>(HeaderFooter.java:297)
at
jxl.read.biff.SheetReader.read(SheetReader.java:640)
at
jxl.read.biff.SheetImpl.readSheet(SheetImpl.java:611)
at
jxl.read.biff.WorkbookParser.getSheet(WorkbookParser.java:230)
at
com.dsxx.dao.ExcelDao.upExcelDb(ExcelDao.java:214)
at
com.dsxx.service.ExcelService.upExcelToDb(ExcelService.java:60)
at
com.dsxx.actions.PreWorkAction.getUploadPath(PreWorkAction.java:72)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 展开
2个回答
展开全部
应该是string 的 substring方法 参数index访问下标越界,如:
String a = "abc";
System.out.println(a.substring(1)); //正常,显示“bc”
System.out.println(a.substring(2)); //正常,显示“c”
System.out.println(a.substring(4)); //错误,String index out of range: -1 因为一共只有3个字母。
String a = "abc";
System.out.println(a.substring(1)); //正常,显示“bc”
System.out.println(a.substring(2)); //正常,显示“c”
System.out.println(a.substring(4)); //错误,String index out of range: -1 因为一共只有3个字母。
追问
有一列时sourceid,bigint类型,不是主键,把src:11111改成11111就行,这是怎么回事啊!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询