请教poi问题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了请教poi问题相关的知识,希望对你有一定的参考价值。
.......
String filePath ="D:/test/aa.xls";
HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(filePath));
......
创建新的Excel 工作簿时(如上)出现以下错误,请问是什么原因该如何解决呢?急!!!!!!!
Exception in thread "main" org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance
at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:191)
at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:115)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:205)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:257)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:238)
at testPoi4.main(testPoi4.java:21)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:179)
... 5 more
Caused by: java.lang.UnsupportedOperationException: Unknown Ptg in Formula: 0xffffff8f (-113)
at org.apache.poi.hssf.record.formula.Ptg.createPtg(Ptg.java:357)
at org.apache.poi.hssf.record.formula.Ptg.createParsedExpressionTokens(Ptg.java:98)
at org.apache.poi.hssf.record.NameRecord.fillFields(NameRecord.java:740)
at org.apache.poi.hssf.record.Record.<init>(Record.java:56)
at org.apache.poi.hssf.record.NameRecord.<init>(NameRecord.java:143)
... 10 more
POIFSFileSystem fs = null;
FileInputStream fis = null;
HSSFWorkbook wb = null;
if (astrFileName.equals(""))
return wb;
try
fis = new FileInputStream(astrFileName);
fs = new POIFSFileSystem(fis);
fis.close();
wb = new HSSFWorkbook(fs);
catch (FileNotFoundException e)
System.out.println("no Excel file:" + astrFileName);
fs = null;
return wb;
catch (IOException e)
e.printStackTrace();
fs = null;
return wb;
fis = null;
return wb;
这是我们读取excel的方法 你对照一下 参考技术C 应该是"D:/test/aa.xls"这个文件的问题,在你执行上面这段代码之前要保证该xls文件存在,并且要可读..
以上是关于请教poi问题的主要内容,如果未能解决你的问题,请参考以下文章
请教大神POI解析word文档,如何获取标题前的数字(标题前的数字)。
关于操作Excel的POI我想请教下设置单元格宽度和高度的单位是啥?与厘米是不是可以转换?并且比例是多少?