poi 文件无法找到
最近做一项目,客户要求一上传excel功能,在网上找了一些资料,有了大概的做法.....
我用的struts做的上传,由于数据可能比较大,所以是先把excel压缩成zip进行上传,上传后再进行解压,解析excel的信息,然后插入库。下面是一些代码
文件已经上传成功,而且接压缩也没有问题,路径是对的,可是在去取excel的时候出错了:
zip中的东西没有实际解压到硬盘中,是不是这个原因而拿不到啊??改怎么解决?
我用的struts做的上传,由于数据可能比较大,所以是先把excel压缩成zip进行上传,上传后再进行解压,解析excel的信息,然后插入库。下面是一些代码
ZipInputStream in = null;
List errors=null;
// FileInputStream(path+fileName));
try {
in = new ZipInputStream(new FileInputStream(path + "\\" + fileName));
ZipEntry entry = new ZipEntry(path + "\\" + fileName);
while ((entry = in.getNextEntry()) != null) {
String entryName = entry.getName();
if (entry.isDirectory()) {
File file1 = new File(path + "\\" + entryName);
file1.mkdirs();
// System.out.println("创建文件夹" + entryName);
} else {
System.out.println(path + "\\" + entryName);
POIFSFileSystem poi = new POIFSFileSystem(new FileInputStream(path+"\\"+fileName)); HSSFWorkbook book = new HSSFWorkbook(poi);
}
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
in.closeEntry();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
文件已经上传成功,而且接压缩也没有问题,路径是对的,可是在去取excel的时候出错了:
D:\work\projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\JS\tmp\ko.zip
D:\work\projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\JS\tmp\test.xls
java.io.FileNotFoundException: D:\work\projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\JS\tmp\test.xls (系统找不到指定的文件。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at ie.js.tyxxc.service.impl.TyxxcSiteDenizenServiceImpl.isQualified(TyxxcSiteDenizenServiceImpl.java:116)
at ie.js.tyxxc.service.impl.TyxxcSiteDenizenServiceImpl.upload(TyxxcSiteDenizenServiceImpl.java:81)
at ie.js.tyxxc.service.impl.TyxxcSiteDenizenServiceImpl$$FastClassByCGLIB$$c398d221.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:696)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:631)
at ie.js.tyxxc.service.impl.TyxxcSiteDenizenServiceImpl$$EnhancerByCGLIB$$4df71e08.upload(<generated>)
at ie.js.tyxxc.action.TyxxcSiteDenizenAction.parse(TyxxcSiteDenizenAction.java:259)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
zip中的东西没有实际解压到硬盘中,是不是这个原因而拿不到啊??改怎么解决?
...全文
相关推荐
POI导出Excel报错No such file or directory的解决方法
文件路径不正确:POI需要正确的文件路径来读写Excel文件。如果文件路径不正确,POI可能无法找到正确的文件,从而引发“No such file or directory”的错误。3.
Invalid header signature POI的解决方案
然而,当遇到“Invalid header signature”错误时,它意味着POI无法识别文件的头部信息,这通常是由于文件损坏、不兼容的格式或编码问题导致的。
poi源码的代码
备注填写环节,如果数据融合成功,需记录核实细节,如电话内容、街景链接等;若无法融合,应说明理由和细节,如无法核实、名称全错、坐标全错或非同 POI。
POI 导入Excel 提醒LeftoverDataException求帮助
**单元格格式错误**:Excel的某些单元格可能使用了不常见的格式,POI无法正确识别。4. **数据量过大**:如果Excel文件包含大量数据,可能超过了POI的默认处理限制。5.
android使用POI操作替换word docx文档中指定内容
如果找到,可以使用XWPFRun的`setText()`方法替换相应的内容。**步骤5:更新并保存**替换所有匹配项后,需要更新`document.xml`文件。


