Excel文件导入异常-输入流无法识别

1、JXL方式导入
- [ INFO ] 导入文件名称为:LBS2设备导入模板.xls
2013-08-13 09:23:06 [ http-bio-8080-exec-7:52188 ] - [ INFO ] 导入文件大小为:13824 bytes
jxl.read.biff.BiffException: Unable to recognize OLE stream
2013-08-13 09:23:06 [ http-bio-8080-exec-7:52219 ] - [ INFO ] 导入文件--数据上传----------开始!!
at jxl.read.biff.CompoundFile.<init>(CompoundFile.java:116)
at jxl.read.biff.File.<init>(File.java:127)
at jxl.Workbook.getWorkbook(Workbook.java:268)
at jxl.Workbook.getWorkbook(Workbook.java:253)
at com.kvt.lbs.utils.ExportTableManager.readExcel2DeviceMember(ExportTableManager.java:437)
at com.kvt.lbs.system.action.DeviceAction.importExcel(DeviceAction.java:496)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
程序异常产生代码:
Workbook book = null;
List<DeviceMember> ldm = new ArrayList<DeviceMember>();
DeviceMember dm = null;
String result = null;
Sheet sheet = null;
try
{
   book = Workbook.getWorkbook(stream);//here is it
   //................
}
//.................
2、POI方式导入
[ INFO ] 导入文件名称为:LBS2设备导入模板.xls 本地地址:192.168.20.48
2013-08-13 10:42:49 [ http-bio-8080-exec-2:46516 ] - [ INFO ] 导入文件大小为:13824 bytes
2013-08-13 10:42:49 [ http-bio-8080-exec-2:46594 ] - [ ERROR ] Invalid header signature; read 0x005301AD65231462, expected 0xE11AB1A1E011CFD0
2013-08-13 10:42:49 [ http-bio-8080-exec-2:46594 ] - [ INFO ] 导入文件--数据上传----------开始!!
程序异常产生代码:
DeviceMember deviceMember = null;
HSSFWorkbook hssfWorkbook = null;
List<DeviceMember> list = new ArrayList<DeviceMember>();
try{
   hssfWorkbook = new HSSFWorkbook(ins);//here is it
   //..................
}
//......................

看到上面的异常了吧,很是令人郁闷  @_@ !!

后来找了很多网上大家的解决方案,最多的就是重新将Excel文件“另存为”一个新的Excel文件就解决了,但是我的不行,最后才想起公司的文档都是加了密的,一直没往这上面想,咨询同事才知道以前有人也遇到过,故此记录以知迷途。一家英文网站上的也是这么解决的。可以参考: http://www.techcrony.info/2008/02/18/admin/avaioioexception-invalid-header-signature-read/#comment-33788




你可能感兴趣的:(exception,poi,fileupload,JXL)