cancel
Showing results for 
Search instead for 
Did you mean: 

excel is corrupted content in web dynpro java 7.4

Former Member
0 Kudos

Hi everyone,

I used fileupload in web dynpro for java 7.4, i'm facing an issue "corrupted content"  when upload an excel file to server.

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

My code :

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();

      }

Please help me

Thanks & Best Regard,

hhoang

Accepted Solutions (0)

Answers (3)

Answers (3)

christian_santej
Active Participant
0 Kudos

may i ask why you've opened a new thread (previous thread http://scn.sap.com/thread/3930784 /)?

junwu
Active Contributor
0 Kudos

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

create wb from stream directly, no need to save to disk....

Former Member
0 Kudos

Hi,

i get stream directly as below

Workbook wb = Workbook.getWorkbook(wdContext.currentContextElement().getMy_Resource().read(false));

it's still error, think there is something wrong when return wdContext.currentContextElement().getMy_Resource().read(false) . maybe SC of NWDS cause this issue ? I'm using SAP NetWeaver Developer Studio 7.3 SP18 PAT0002

Thanks

stefan_mahnke
Participant
0 Kudos

Hi hhoang,

did you compare the two files yet (the original and the uploaded one from the server)?

Maybe you can see the difference there or the point where the "corruption" starts.

Regards Stefan