Skip to Content
0
Former Member
Jul 12, 2016 at 09:13 AM

How to upload *.xls file in web dynpro for java 7.4

150 Views

Hi everybody,

I used jxl to upload *.xls file in web dynpro for java 7.4, i'm facing an issue "BiffException: jxl.read.biff.BiffException: Unable to recognize OLE stream"

My code as below:

resouce type: com.sap.ide.webdynpro.uielementdefinitions.Resource

try{

IPrivateMyCompView.IContextElement element = wdContext.currentContextElement();

if(element.getMyResource()!=null){

InputStream in = null;

int temp = 0;

File file = new File(wdContext.currentContextElement().getMyResource().getResourceName());

FileOutputStream out = new FileOutputStream(file);

in = element.getMyResource().read(false);

while((temp = in.read())!=-1){

out.write(temp);

}

out.flush();

out.close();

path = file.getAbsolutePath();

wdComponentAPI.getMessageManager().reportSuccess("path: "+path);

// path = usr/sap/DEP/J00/j2ee/cluster/server0/Book1.xls

try {

Workbook wb = Workbook.getWorkbook(new File(path));

} catch (BiffException e) {

wdComponentAPI.getMessageManager().reportException("BiffException: "+e.getMessage());

e.printStackTrace();

}

}

}catch (FileNotFoundException e){

wdComponentAPI.getMessageManager().reportException("FileNotFoundException: "+e.getMessage());

e.printStackTrace();

}catch (IOException e){

wdComponentAPI.getMessageManager().reportException("IOException: "+e.getMessage());

e.printStackTrace();

}

Thanks & Best Regard,

hhoang