Skip to Content
avatar image
Former Member

Excel download... and upload?

Hello everyone,

I'm using the web dynpro binary cache, as explained in sap tutorials, to download the content of a UI table to an excel file. Is there any form of doing the opposite? I mean, i would like to upload several columns of data from an excel file to multiple value attributes of a context node.

Is this possible??

Other problem i'm having is that when i download the data to the excel file all columns appear on an order that i don't want. How can i control the order of the columns in the excel file, when downloading it from web dynpro?

thank you everyone,


Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Jul 12, 2006 at 07:35 AM


    I can give solution to Upload Excel file.

    1)Add jxl jar folder in the lib folder of ur project.

    2)Go to properties of ur project and add jar to ur project.

    3)Using the File upload ui ,browse and upload the file.

    4)Write the read file in to ur server location using fileoutput stream.

    5)then using code u can read the excelfile from the server location itself.

    Here is the code:

    	IWDAttributeInfo attInfo =wdContext.getNodeInfo().getAttribute("upload");
    /** get the name of excel file and storing it in the server with the same name and extention****/
    fileuploaded = binaryType.getFileName();
    byte b[] = wdContext.currentContextElement().getUpload();
    File filename =new File("\\<Server name>\<folde name>\" + fileuploaded);
    try {
    FileOutputStream out = new FileOutputStream(filename);
    } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    } catch (IOException e) {
    // TODO Auto-generated catch block
    /***Readind from the server***/
    int iRows = 0;
    try {	Workbook wb = null;
    	Sheet sheet = null;
    	wb = Workbook.getWorkbook(filename);
    	sheet = wb.getSheet(0);
    	int iColumns = sheet.getColumns();
          iRows = sheet.getRows();
         int i = 0;
        //get Cell contents by (COLUMN, ROW);
        for (int r = 0; r < iRows; r++) {
       for (int c = 0; c < iColumns; c++) {
    	Cell cell = sheet.getCell(c, r);
    	characterarray<i> = cell.getContents();
    //wdComponentAPI.getMessageManager().reportSuccess("Row"+r+ characterarray<i>);

    Declare Globally

    //@@begin others

    String fileuploaded;

    IWDModifiableBinaryType binaryType;

    String characterarray[] = new String[1000];



    Vijayakhanna Raman

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 11, 2006 at 05:05 AM

    Hi ,

    Foe excel upload use FileUpload control to upload file .And use POI API to read excel file.

    Go through this blog.




    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member


      1.You have to add this jar to lib folder under the root of your project.

      2.right click on your project ,go to properties->Java build path -> Libraries ->add external jars add there the POI JARS.

      Hope this will help you.



  • avatar image
    Former Member
    Feb 08, 2008 at 07:20 AM

    Hi Vijayakhanna,

    I am working in NW04s . i tried the solution suggested by you:

    for uploading the excel file and then tried to create this excel file on the server and reading data from excel sheet into context. But in NW04s, we have a to set property 'Resource' of type - context attribute(IWDResource) for FileUpload UI Element - Resource which is of the type IWDResouce.

    Upload is successfull.

    I created a object of FileOutputStream

    FileOutputStream fo = new FileOutputStream(l_filename);

    This file gets created successfully on the server.

    Now, i am trying to write contents in this file using the following statement:


    where Resource is a context attribute of type - IWDResource.

    The problem is: file created on the server doesnot contain the data uploaded by the user. And hence, it gives an error while reading the file.

    Can you help me in extracting the data from context attribute 'Resource' and then writing into the file???

    Thanks for help.



    Add comment
    10|10000 characters needed characters exceeded