cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

christian_santej
Active Participant
0 Kudos

Hi,

I'm quite sure this is not a web dynpro but a jxls issue. are you sure that the uploaded excel is a .xls (saved as 97-2003) format and not a .xlsx as .xls (saved as 2010)format?

regards,

Christian

Former Member
0 Kudos

i'm sure my file is *.xls format. i used excel 2007 save as 97-2003

christian_santej
Active Participant
0 Kudos

i see.

i remember we had a similar issue with uploaded documents where the uploaded file got corrupted. which SP is your netweaver system on? - check the sap note http://service.sap.com/sap/support/notes/2297508

regards,

christian

ErvinSzolke
Product and Topic Expert
Product and Topic Expert
0 Kudos

I agree too that this is not due to wd java but rather about how you use jxl.

Former Member
0 Kudos

I consult this document

I use for web dynpro NWDS 7.3 . (deploy on netweaver server 7.4).

But i tested with file text *.txt and read text file is ok.

I think the issue in upload excel file, not in read excel file because Workbook.getWorkbook working on my desktop application.

Thanks for reply,

christian_santej
Active Participant
0 Kudos

that might be possible. check my previous post which points out this issue.

extract from the note 2297508:


"...Files are being uploaded during HTTP communication between the Web client and AS Java. The resulting file has the correct size but the content is corrupted..."

Regards,

Christian

Answers (1)

Answers (1)

Former Member
0 Kudos

i use POI to read excel file and exception:

InvalidFormatException: Your InputStream was neither an OLE2 stream, nor an OOXML stream
vdurgarao09
Contributor
0 Kudos

Hi,

Check this code for help you.

Java Code Example

otherwise try this logic

InputStream inputStream = getFile_Resource().read(false);//IWDResource

Workbook workbook = Workbook.getWorkbook(inputStream);

Regards,

Durga Rao./message-abuse!input.jspa?objectID=16834416&objectType=2

Former Member
0 Kudos

i tried as the same you say but it still has error. upload excel created an excel with no sheet, (content is corrupted)

christian_santej
Active Participant
0 Kudos

have you checked the note 2297508 as i mentioned previously?

Former Member
0 Kudos

Hi Christian,

Thanks for reply, but the note 2297508 page not found.

christian_santej
Active Participant
0 Kudos

hmm that's odd. i've just tried it (http://service.sap.com/sap/support/notes/2297508) and for me it works

Former Member
0 Kudos

Hi Christian,

Thank you very much, i will try to use as the tutorial.

hhoang

Former Member
0 Kudos

Hi Christian,

I did as the sam note 2297508 but itsitll have error.

my project only use SC:  FRAMEWORK, ENGFACADE, WD-RUNTIME

Hhoang