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) を読み取ると問題ありません
コード: Workbook 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
}
}