我将 web dynpro java 7.0 迁移到 7.4。上传 Excel 文件时出现问题。jxl.read.biff.BiffException:无法识别 OLE 流
我参考了文档“Upload Excel File With Example Web Dypro for Java”,但我仍然有一个错误。
(我使用office 2007保存AAAA.xls(97-2003)并上传
file.getAbsolutePath() = /usr/sap/DEP/J00/j2ee/cluster/server0/AAAA.xls)
我尝试在桌面上的项目 java 应用程序中使用 jxl.jar,读取 excel 文件 (*.xls) 时没问题
代码:工作簿 wb = Workbook.getWorkbook(new File("C:/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
}
}