2016-07-11 161 views
0

我将web dynpro java 7.0迁移到7.4。上传Excel文件时遇到问题。 jxl.read.biff.BiffException:无法识别OLE流Sap Portal NetWeaver 7.4:jxl.read.biff.BiffException:无法识别OLE流

我参考了一个文档“上传带有示例Web Dypro for Java的Excel文件”,但我仍然有错误。

(我使用Office 2007,以节省AAAA.xls(97-2003),并上传

file.getAbsolutePath()=的/ usr/SAP/DEP/J00/J2EE /组/ server0对/ AAAA。工作簿WB = Workbook.getWorkbook(新文件(“C:XLS)

我在项目中的Java应用程序使用jxl.jar我的桌面上试过,读取Excel文件(的* .xls)

代码时的确定: /Users/pcname/Desktop/AAAA.xls“));

但在门户网站,它抛出以下异常“无法识别OLE流”

的代码如下:

type of Va_Resource = com.sap.ide.webdynpro.uielementdefinitions.Resource 
    .... 
InputStream inpStr = null; 
int temp = 0; 
File file = new File(wdContext.currentContextElement() 
    .getVa_Resource().getResourceName().toString()); 

FileOutputStream opStr = new FileOutputStream(file); 

if(wdContext.currentContextElement().getVa_Resource()!=null){ 

    inpStr = wdContext.currentContextElement().getVa_Resource().read(false); 

    while((temp = inpStr.read())!= -1){ 
     opStr.write(temp); 
    } 
} 

opStr.flush(); 
opStr.close(); 
path = file.getAbsolutePath(); 
     if(path.substring(path.length()-3,path.length()).trim().equalsIgnoreCase("xls")) 
{ 
    //call method for upload 
    Execute_UploadOperation(); 
} 

..... 
public void Execute_UploadOperation{ 
    try{ 
     //path = /usr/sap/DEP/J00/j2ee/cluster/server0/AAAA.xls 
     Workbook wb = Workbook.getWorkbook(new File(path)); error this line, throw exception here 

.... 
    } 
    catch (BiffException e) { 
     e.getMessage() = jxl.read.biff.Biff Exception: Unable to recognize OLE stream 
    } 
} 

回答

0

你的编码似乎是罚款。
你使用什么Excel版本? TheExcelApi现在是obsolete,并且仅适用于Excel版本直到2003年,上次在2009年更新。
对于后者版本的MS Office使用Apache POI