我用jxl读取excel,获得workbook和sheet时出现异常,请求帮忙!
Warning:CannotreadnamerangesforCstatus-settingtoemptyWarning:CannotreadnamerangesforD...
Warning: Cannot read name ranges for Cstatus - setting to empty
Warning: Cannot read name ranges for Division - setting to empty
Warning: Cannot read name ranges for Esqr - setting to empty
Warning: Cannot read name ranges for ESqr1 - setting to empty
Warning: Cannot read name ranges for Esqr2 - setting to empty
Warning: Cannot read name ranges for Fast - setting to empty
Warning: Cannot read name ranges for FASTROLE - setting to empty
Warning: Cannot read name ranges for FASTROLL - setting to empty
Warning: Cannot read name ranges for JobFunction - setting to empty
Warning: Cannot read name ranges for JVPortal - setting to empty
Warning: Cannot read name ranges for JVPortal2 - setting to empty
Warning: Cannot read name ranges for PersonType1 - setting to empty
Warning: Cannot read name ranges for Position - setting to empty
Warning: Cannot read name ranges for Print_Area - setting to empty
Warning: Cannot read name ranges for PRTS_Request - setting to empty
Warning: Cannot read name ranges for RoleCodes - setting to empty
Warning: Cannot read name ranges for RollCodes - setting to empty
Warning: Cannot read name ranges for STAT - setting to empty
common.AssertionFailed
at common.Assert.verify(Assert.java:37)
at jxl.read.biff.WorkbookParser.getName(WorkbookParser.java:1118)
at jxl.biff.formula.NameRange.read(NameRange.java:88)
at jxl.biff.formula.TokenFormulaParser.parseSubExpression(TokenFormulaParser.java:214)
at jxl.biff.formula.TokenFormulaParser.parse(TokenFormulaParser.java:111)
at jxl.biff.formula.FormulaParser.parse(FormulaParser.java:110)
at jxl.biff.DVParser.<init>(DVParser.java:431)
at jxl.biff.DataValiditySettingsRecord.initialize(DataValiditySettingsRecord.java:140)
at jxl.biff.DataValiditySettingsRecord.getFirstColumn(DataValiditySettingsRecord.java:234)
at jxl.read.biff.SheetReader.read(SheetReader.java:1016)
at jxl.read.biff.SheetImpl.readSheet(SheetImpl.java:686)
at jxl.read.biff.WorkbookParser.getSheet(WorkbookParser.java:252)
at aa.BooleanTest.readExcel(BooleanTest.java:52)
at aa.BooleanTest.main(BooleanTest.java:28)
Exception in thread "main" common.AssertionFailed 展开
Warning: Cannot read name ranges for Division - setting to empty
Warning: Cannot read name ranges for Esqr - setting to empty
Warning: Cannot read name ranges for ESqr1 - setting to empty
Warning: Cannot read name ranges for Esqr2 - setting to empty
Warning: Cannot read name ranges for Fast - setting to empty
Warning: Cannot read name ranges for FASTROLE - setting to empty
Warning: Cannot read name ranges for FASTROLL - setting to empty
Warning: Cannot read name ranges for JobFunction - setting to empty
Warning: Cannot read name ranges for JVPortal - setting to empty
Warning: Cannot read name ranges for JVPortal2 - setting to empty
Warning: Cannot read name ranges for PersonType1 - setting to empty
Warning: Cannot read name ranges for Position - setting to empty
Warning: Cannot read name ranges for Print_Area - setting to empty
Warning: Cannot read name ranges for PRTS_Request - setting to empty
Warning: Cannot read name ranges for RoleCodes - setting to empty
Warning: Cannot read name ranges for RollCodes - setting to empty
Warning: Cannot read name ranges for STAT - setting to empty
common.AssertionFailed
at common.Assert.verify(Assert.java:37)
at jxl.read.biff.WorkbookParser.getName(WorkbookParser.java:1118)
at jxl.biff.formula.NameRange.read(NameRange.java:88)
at jxl.biff.formula.TokenFormulaParser.parseSubExpression(TokenFormulaParser.java:214)
at jxl.biff.formula.TokenFormulaParser.parse(TokenFormulaParser.java:111)
at jxl.biff.formula.FormulaParser.parse(FormulaParser.java:110)
at jxl.biff.DVParser.<init>(DVParser.java:431)
at jxl.biff.DataValiditySettingsRecord.initialize(DataValiditySettingsRecord.java:140)
at jxl.biff.DataValiditySettingsRecord.getFirstColumn(DataValiditySettingsRecord.java:234)
at jxl.read.biff.SheetReader.read(SheetReader.java:1016)
at jxl.read.biff.SheetImpl.readSheet(SheetImpl.java:686)
at jxl.read.biff.WorkbookParser.getSheet(WorkbookParser.java:252)
at aa.BooleanTest.readExcel(BooleanTest.java:52)
at aa.BooleanTest.main(BooleanTest.java:28)
Exception in thread "main" common.AssertionFailed 展开
2个回答
展开全部
什木啊,就是代码错啦,给你个例子自己好好看看···
不行就把你的代码贴上···
// 创建可写入的Excel工作薄
OutputStream os = new FileOutputStream("D:\\数据汇总分析表.xls");
WritableWorkbook workbook1 = Workbook.createWorkbook(os);
WritableSheet sheet = workbook1.createSheet("数据汇总分析表", 0);
不行就把你的代码贴上···
// 创建可写入的Excel工作薄
OutputStream os = new FileOutputStream("D:\\数据汇总分析表.xls");
WritableWorkbook workbook1 = Workbook.createWorkbook(os);
WritableSheet sheet = workbook1.createSheet("数据汇总分析表", 0);
追问
这个错误不是一开始就有的,之前只是报内存溢出错误,我一修改jvm的参数,它才出现这个错误,所以绝对不是代码问题!而且后面验证这个内存溢出问题不是因为数据量大的问题,而是因为excel中运用了格式什么的原因,因为我把除了头部分的数据外全部copy到另外一个excel表中就没有了错误!
展开全部
如果不是代码错误,就是jxl包的版本不够,更新jxl包的版本后再试试
若果仍然报错试试这个:
package jxl_excel;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
public class JxlExcel {
/**
* @param args
* @throws IOException
* @throws BiffException
*/
public static void main(String[] args) throws BiffException, IOException {
InputStream is = new FileInputStream("c:\\a.xls");//path是文件路径
Workbook wb = Workbook.getWorkbook(is);// 获得工作薄
Sheet st = wb.getSheet(0);
//获得总行数
int rowSize=st.getRows();
//获得总列数
int columnSize=st.getColumns();
if(rowSize!=0){
for(int i=1;i<rowSize;i++){
for (int j=0;j<columnSize;j++){
//st.getCell(j,i).getContents()括号内的参数j代表总列数,i代表总行数
System.out.println(st.getCell(j,i).getContents());
}
}
}
}
}
若果仍然报错试试这个:
package jxl_excel;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
public class JxlExcel {
/**
* @param args
* @throws IOException
* @throws BiffException
*/
public static void main(String[] args) throws BiffException, IOException {
InputStream is = new FileInputStream("c:\\a.xls");//path是文件路径
Workbook wb = Workbook.getWorkbook(is);// 获得工作薄
Sheet st = wb.getSheet(0);
//获得总行数
int rowSize=st.getRows();
//获得总列数
int columnSize=st.getColumns();
if(rowSize!=0){
for(int i=1;i<rowSize;i++){
for (int j=0;j<columnSize;j++){
//st.getCell(j,i).getContents()括号内的参数j代表总列数,i代表总行数
System.out.println(st.getCell(j,i).getContents());
}
}
}
}
}
追问
这个错误不是一开始就有的,之前只是报内存溢出错误,我一修改jvm的参数,它才出现这个错误,所以绝对不是代码问题!
追答
可能是jvm参数修改错误导致的吧
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询