一、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
//................
}
//.................
二、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