Web Dynpro read excel cell

Hi,
How can I read a specific excel cell via Web Dynpro ?
It will be great if someone will provide a short sample of code for that ...
10x in advance
Hadar

Hi Chandran i followed you steps regarding  to upload excel sheet data to webdynpro table.
but iam not get clarity how to do this step.
Note : You cannot Read the Content from the excel file directly
First You Have to copy that file to the Server,
And from the Server you can get the file absolute path
With the absolute path you can read the contents of the Excel file
You have to save the Excel file as .xls Format and Not as xlsx format i will not accept that...
help me onthis step, i need  to develop the this feature in application.
you posted like this
Hi
First You have to download the jxl.jar file. You can get this file from the Below site
JExcelApi v2.6.4 (1747kbytes)
It will be in Compressed Fromat So Unzip it to get the Contents
After Unzipping The File You will get a Folder (jexcelapi/jxl.jar)
Now in NWDS open web dynpro explorer, Right Click Your Project, a popup menu will appear and in that click Properties
You will get window displaying your Project Properties
On Left Side of the window You Will Find "Java Build Path"
Click That "Java Build Path" and you will get 4 Tabs Showing ( Source,Projects,Libraries,Order and Export)
Click Libraries Tab
You will find options many options buttons
In that click the Button "Add External Jars"
You will get Window in order to fecth the jxl.jar file from the location you had stored
After selecting the jxl.jar i will get displayed and click ok
Now Open Navigator
Open Your Project
You will find Lib folder
Copy the jxl.jar to that lib folder
Note : You cannot Read the Content from the excel file directly
First You Have to copy that file to the Server,
And from the Server you can get the file absolute path
With the absolute path you can read the contents of the Excel file
You have to save the Excel file as .xls Format and Not as xlsx format i will not accept that...
You have Upload the Excel file from the Server Using the File Upload UI Element
This Coding will extract 3 columns from the Xls File
Coding
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import com.sap.fileupload.wdp.IPrivateFileUpload_View;
import com.sap.tc.webdynpro.services.sal.datatransport.api.IWDResource;
public void onActionUpload_File(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
    //@@begin onActionUpload_File(ServerEvent)
    IPrivateFileUpload_View.IContextElement element1 = wdContext.currentContextElement();
    IWDResource resource = element1.getFileResource();
    element1.setFileName(resource.getResourceName());
    element1.setFileExtension(resource.getResourceType().getFileExtension());
    //@@end
public void onActionUpload_File_in_Server(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
    //@@begin onActionUpload_File_in_Server(ServerEvent)
    InputStream text=null;
    int temp=0;
    try
         File file = new File(wdContext.currentContextElement().getFileResource().getResourceName().toString());
         FileOutputStream op = new FileOutputStream(file);
         if(wdContext.currentContextElement().getFileResource()!=null)
              text=wdContext.currentContextElement().getFileResource().read(false);
              while((temp=text.read())!=-1)
                   op.write(temp);                                      
         op.flush();
         op.close();
         path = file.getAbsolutePath();
         wdComponentAPI.getMessageManager().reportSuccess(path);
    catch(Exception e)
         e.printStackTrace();
    //@@end
public void onActionUpload_Data_into_Table(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
    //@@begin onActionUpload_Data_into_Table(ServerEvent)
    try
          Workbook wb =Workbook.getWorkbook(new File(path));
          Sheet sh = wb.getSheet(0);
          //wdComponentAPI.getMessageManager().reportSuccess("Columns = "+sh.getColumns());
          //wdComponentAPI.getMessageManager().reportSuccess("Rows = "+sh.getRows());
          int columns = sh.getColumns();
          int rows = sh.getRows();
          int i=0;
         for(int j=1;j<=rows;j++)
                   ele=wdContext.nodeTable_Data().createTable_DataElement();
                   Cell c1 = sh.getCell(i,j);
                  ele.setTab_Name(c1.getContents());
                   Cell c2 = sh.getCell(i+1,j);
                   ele.setTab_Degree(c2.getContents());
                      Cell c3 = sh.getCell(i+2,j);
                   ele.setTab_Percentage(c3.getContents());
                   wdContext.nodeTable_Data().addElement(ele);
    catch(Exception ex)
         wdComponentAPI.getMessageManager().reportSuccess(ex.toString());
    //@@end
The following code section can be used for any Java code that is
not to be visible to other controllers/views or that contains constructs
currently not supported directly by Web Dynpro (such as inner classes or
member variables etc.). </p>
Note: The content of this section is in no way managed/controlled
by the Web Dynpro Designtime or the Web Dynpro Runtime.
  //@@begin others
  String path;
  IPrivateFileUpload_View.ITable_DataElement ele;
//@@end
Regards
Chandran S

Similar Messages

  • Read excel cell when excel is already open

    Hello,
    I want to read a specific cell of a sheet with excel already open. Labview has only to read the cell and not have to open excel.
    I have several examples that show :
    Labvview open excel
    select excel file
    select workbook
    select sheet
    select cell
    read cell
    close workbook
    close excel
    In my vi i only need the step 3 to 6
    Thank for your help
    Djamel
    Solved!
    Go to Solution.

    The attached (LabVIEW 2012) vi will return the value in the cell 'A1' of 'Sheet1' of the already open excel workbook 'book1'
    Change the values for your specific names of workbook and worksheet and required cell.
    The value returned is a variant so need to be converted with 'Variant to Data' according to data type
    Ken
    Attachments:
    Get cell value from already open Excel.vi ‏18 KB

  • Drag and Drop between Web Dynpro Tables on Cell Basis

    Hi Experts,
    I need to develop a Drag and Drop Functionality as follows:
    I have two tables. I want to drag a row of the first table and drop it in a particular cell of the second table.
    Is it possible to implement this using the Web Dynpro Drap and Drop Functionality?
    If not, does anybody have an idea of how to implement this using other concepts (Flash Integration, Building up a Grid of Images and defining those as drop tragets, etc..)??
    Valuable Advice is highly appreciated!
    THANKS, Johannes

    Thanks for the Video.. It gives some information about Drag and Drop, but still, it does not say what I need to know.
    Again:
    I need to know if there is a way to drag particular cells in a Web Dynpro Table to other locations in that same table. Plus: I need to know if there is a way to drag and drop rows of one table into particular cell of another table.
    Similar to what we do in our Outlook Calendars: We have a week in view and we see our appointments as blocks within that week view. Now, we can drag and drop these blocks to other locations. That is what I need to implement!
    Does anybody have an idea?
    THANKS, Johannes

  • Read Excel cells - part2

    This is a follow up from my question last week. I am back to trying to figure out how to read excel data cells and store the values into variables. I've looked through the sample files and copied the code from excel2000demo.cws. I can't actually run this demo since I don't have excel on my system. I need to be able to read the .xls without having Excel loaded. I've put ReadDataFromExcel into my program but when I try and run it, I get an error code(negative) at the Excel_WorksheetRange statement. The error is invalid handle. The line is:
        error = Excel_WorksheetRange (ExcelWorksheetHandle, NULL, MyCellRangeV, CA_DEFAULT_VAL, &ExcelRangeHandle);
    I don't really understand what the parameters are or should be and if certain things need to be defined elsewhere.
    It also seems like I should have code to tell it what file to look into. The demo uses Excel_WorkbooksOpen. Is that ok to use with no Excel? I did try adding:
                    GetProjectDir (fileName);
                    strcat(fileName, "\\exceldem.xls");
                    error = Excel_WorkbooksOpen (ExcelWorkbooksHandle, NULL, fileName, CA_DEFAULT_VAL,
                                                 CA_DEFAULT_VAL, CA_DEFAULT_VAL,
                                                 CA_DEFAULT_VAL, CA_DEFAULT_VAL,
                                                 CA_DEFAULT_VAL, CA_DEFAULT_VAL,
                                                 CA_DEFAULT_VAL, CA_DEFAULT_VAL,
                                                 CA_DEFAULT_VAL, CA_DEFAULT_VAL,
                                                 CA_DEFAULT_VAL, &ExcelWorkbookHandle);
    I get invalid handle errors here too.
    Mike

    Unfortunately you cannot run this example without having installed Excel on your system, since the instrument driver it relies on is nothing but an ActiveX interface to the local Excel application.
    In effect, if you look into the source code for this example, you will notice that the very first operation performed is to connect to Excel: this instruction will fail if the application is not installed, so all the following code cannot be executed. You will notice that every opening function in the source code relies on an handle provided from a preceding statement, in a continuous chain whose first element is exactly the connection to the Excel app: this is valid for ExcelWorksheetHandle, ExcelWorbookHandle and all the handles used in the code.
    Edit: Eren has come first!
    Message Edited by Roberto Bozzolo on 04-28-2010 07:22 AM
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Read excel cell from pdf

    Hello
    I would like to link a pdf file to an excel file so that I can set some anchor points in the pdf file that will allow the pdf to change the value of these anchor points whenever the cells' values in excel change.
    Is there any way or any software to do this?
    Thanks

    hi,
    well you are saying that your excel file contains the name of the file which is stored at somewhere in your root directory structure?..........if is it so then do you want to store the name of the file which is specified in the excel cell, to oracle database as BLOB or CLOB or you want to read the actual content available in the doc or excel file and then store it to oracle database? please verify........
    this is possible using poi.....visit the apache's website for more information on POI api and downloads.......
    thanks
    shishir

  • WEB DYNPRO ALV GRID : CELL CONTENT - Initial Value

    I created a sort of 'Timesheet' in web dynpro...
    Unfortunatly, for all days of the month it displays '0.00' as initial value...
    Is it possible to not display this initial value or display space/empty ?
    In gui alv it is possible, I don't know if it could be done in web dynpro

    Hi,
    For the node to which the ALV is bound. For the column (context attribute) check the property of the attribute check the formatting propertioes as ZEROS AS BLANKS
    for ex: price is the context attrbiute check the properties.
    This FORMATTING options for the context attribute is found in the latest verions like EHP4.
    Regards,
    Lekha.

  • Read Excel cell data automatically

    From the given examples, before reading an excel data, you have to specify the start cell and the end cell number. Is there a method to read out excel data just by giving the file name?
    David

    Well, then you can open Excel, open the first sheet in the collection and then iterate into the sheet and search for non-empty cells.
    You can use the source code for ExcelRpt_ReadDataToTableControl () function into excelreport.c code as a guideline to develop your own function: iterate on all cells in the sheet and try to load only those that do not return CAVT_EMPTY in CA_VariantGetType () function.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Web dynpro ALV table cell popin

    from my understanding, it is possible to create a cell popin for a standard table.
    but now i wonder whether is it possible to create a cell popin for an ALV table?

    My question was about option Filter of ALV report.
    May be somebody knows how I can receive Interfacecontroller
    attributes: FILTER_VALUES. It should help to filter
    table inside code( in my ONFUNCTION method).
    Regards
    Irena

  • Read an Excel cell using LabView

    Hello,
    I'm trying to read Excel cells with LabView, witch can be numeric data
    or text.
    I want to chose the Excel cell to read.
    I try to use AtiveX commands in order to do so, but it doesn't work,
    and I don't understand all concepts of activeX.
    I searched on the web, but I didn't find any simple example witch can
    run for me.
    Can we do it without activeX commands?
    Do you have any simple example to send me?
    Thank you for your help.
    Jean-Louis, France.

    Here is a simple VI that uses ActiveX to read an Excel cell. It is set up for string values, but it can be changed. If you get a broken run arrow, than you may have to reconfigure some of the propery nodes for your version of Excel.
    Attachments:
    Get_Excel_Cell_Sub.vi ‏99 KB

  • Export to Excel Problem external DC using Web Dynpro binary cache

    Hallo,
    I want to export from Web Dynpro to Excel. For this I study the Tutorial "Excel Export Using the Web Dynpro Binary Cache".
    The example is running without a problem.
    I have create a new DC only for excel export. The name is ExcelExportWD. In this DC I create a Component and programmed the methods of the example. Also I create the View and the Context for it.
    This DC is used in other DCs. I put the Component to the public part. After than I make the entry in the used DCs in that DC which I want to use the Excel export. I use the DC ExcelExportWD in the DC ContactsWD.
    The ContactsWD is running without a problem.
    If I try now to export to Excel I got the following error.
    <b>com.sap.tc.webdynpro.services.sal.api.WDDispatcherException: Requested deployable object 'mgi.de/portalscmContactsWD' and application 'ResultGetContacts.xls' are not deployed on the server. Please check the used URL.</b>
    In the View of the ExcelExport the name of file is not visible in the URL of the ExcelFileName. The name "ResultGetContacts.xls" is the name of the node which I want to export.
    What is wrong? I have try to set a Sharing reference in the ContactWD without success.
    An idea ?
    Regards
    Gunter

    Hallo,
    I want to export from Web Dynpro to Excel. For this I study the Tutorial "Excel Export Using the Web Dynpro Binary Cache".
    The example is running without a problem.
    I have create a new DC only for excel export. The name is ExcelExportWD. In this DC I create a Component and programmed the methods of the example. Also I create the View and the Context for it.
    This DC is used in other DCs. I put the Component to the public part. After than I make the entry in the used DCs in that DC which I want to use the Excel export. I use the DC ExcelExportWD in the DC ContactsWD.
    The ContactsWD is running without a problem.
    If I try now to export to Excel I got the following error.
    <b>com.sap.tc.webdynpro.services.sal.api.WDDispatcherException: Requested deployable object 'mgi.de/portalscmContactsWD' and application 'ResultGetContacts.xls' are not deployed on the server. Please check the used URL.</b>
    In the View of the ExcelExport the name of file is not visible in the URL of the ExcelFileName. The name "ResultGetContacts.xls" is the name of the node which I want to export.
    What is wrong? I have try to set a Sharing reference in the ContactWD without success.
    An idea ?
    Regards
    Gunter

  • SAP GUI screens in Web dynpro ABAP

    Is there an easy way to convert SAPU GUI screns like VA01 into webdynpro screens like the old way of doing with ITS?
    I don't want to use the SAP portal. I just want to use Webdynpro ABAP only.  Please share your thoughts.
    Thanks

    ITS is the only tool with automatic translation of SAPGUI screens.  Even if we autoconverted to Web Dynpro, you would end up with a Web Dynpro Screen that pretty much looks and feels like the old SAPGUI screen. There is a screen conversion wizard in Web Dynpro, but it isn't really recommended.  It only does partial conversion, the screen designs aren't optimal (hence the WDA that looks like a dynpro) and the code of the component is messy.  You really need to redesign from scratch to take advantage of the features of Web Dynpro.

  • Reading contents of uploaded excel file in web dynpro java

    Hi All.
    I am aware how to provide facility to upload files in web dynpro java. But my requirement is that on uploading a particular file (for eg. an excel file having 10 columns), I need to read the contents of that file and store it in a table in R/3.Can anyone suggest a way how I can read the contents of the uploaded file?
    Thanks and Regards,
    Saurabh.

    Hi.
    I am having the following requirement : I have a FileUpload UI element where user clicks Browse button, selects a file from the local system and presses a Upload button. Upon pressing Upload, the name of the selected file and the contents of the file should be shown.
    In the View context, I have two value attributes: FileName of type String and FileResource of type binary.
    This is the code that I have in the Upload button action handler :
      public void onActionUpload(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionUpload(ServerEvent)
        IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute(
                 IPrivateReadExcelView.IContextElement.FILE_RESOURCE);
        IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType)attributeInfo.
                 getModifiableSimpleType();
        IPrivateReadExcelView.IContextElement element = wdContext.createContextElement();
        String fname = binaryType.getFileName();
        wdComponentAPI.getMessageManager().reportSuccess("File selected - "+fname);  //Statement 1
         try {
              wdComponentAPI.getMessageManager().reportSuccess("Successful");    // Statement 2
              InputStream in = new FileInputStream(fname);
              HSSFWorkbook wb = new HSSFWorkbook(in);
              wdComponentAPI.getMessageManager().reportSuccess("Successful");    //Statement 3
              int sheetsNo = wb.getNumberOfSheets();
              for (int i=0;i<sheetsNo;i++) {
                   HSSFSheet sheet = wb.getSheetAt(i);
                   Iterator rowsNo = sheet.rowIterator();
                   while(rowsNo.hasNext()) {
                        HSSFRow rows = (HSSFRow)rowsNo.next();
                        Iterator colsNo = rows.cellIterator();
                        while(colsNo.hasNext()) {
                             HSSFCell cell = (HSSFCell)colsNo.next();
                             wdComponentAPI.getMessageManager().reportSuccess("File uploaded" +
                                  "successfully");
                             if(cell.getCellType()==1) {
                                  wdComponentAPI.getMessageManager().reportSuccess("00000"+
                                       cell.getStringCellValue());
                             else if(cell.getCellType()==0) {
                                  String str=""+cell.getNumericCellValue();
                                  wdComponentAPI.getMessageManager().reportSuccess("11111"+str);
         catch(Exception e) { wdComponentAPI.getMessageManager().raisePendingException();
        //@@end
    On pressing Upload button, name of selected file is being shown(Statement 1). I am also getting Statement 2 in the output. However I am not getting Statement 3 onwards.
    Where am I going wrong? Can anyone shed some light on this?

  • Upload and Reading Excel File in Web Dynpro

    Hi all,
    I have a requirement in my application( in 04s), where in, i need to upload an excel from a client through a web dynpro application(using fileupload UI) and read each and every the content of that excel file in web dynpro and process the data accordingly.
    The format of the excel is fixed and pre-defined.
    I went through a lot of blogs, but could not find a direct and exact solution to this requirement.
    Please help me.
    Looking forward to your contribution
    Thank you,
    Gita KC.

    Reading Excel Sheet from Java without using any Framework
    Enhanced File Upload - Uploading and Processing Excel Sheets
    Reading Multiple Sheets of Excel Sheet from Java
    nikhil

  • Import data from excel/csv file in web dynpro

    Hi All,
    I need to populate a WD table by first importing a excel/CSV file thru web dynpro screen and then reading thru the file.Am using FileUpload element from NW04s.
    How can I read/import data from excel / csv file in web dynpro table context?
    Any help is appreciated.
    Thanks a lot
    Aakash

    Hi,
    Here are the basic steps needed to read data from excel spreadsheet using the Java Excel API(jExcel API).
    jExcel API can read a spreadsheet from a file stored on the local file system or from some input stream, ideally the following should be the steps while reading:
    Create a workbook from a file on the local file system, as illustrated in the following code fragment:
              import java.io.File;
              import java.util.Date;
              import jxl.*;
             Workbook workbook = Workbook.getWorkbook(new File("test.xls"));
    On getting access to the worksheet, once can use the following code piece to access  individual sheets. These are zero indexed - the first sheet being 0, the  second sheet being 1, and so on. (You can also use the API to retrieve a sheet by name).
              Sheet sheet = workbook.getSheet(0);
    After getting the sheet, you can retrieve the cell's contents as a string by using the convenience method getContents(). In the example code below, A1 is a text cell, B2 is numerical value and C2 is a date. The contents of these cells may be accessed as follows
    Cell a1 = sheet.getCell(0,0);
    Cell b2 = sheet.getCell(1,1);
    Cell c2 = sheet.getCell(2,1);
    String a1 = a1.getContents();
    String b2 = b2.getContents();
    String c2 = c2.getContents();
    // perform operations on strings
    However in case we need to access the cell's contents as the exact data type ie. as a numerical value or as a date, then the retrieved Cell must be cast to the correct type and the appropriate methods called. The code piece given below illustrates how JExcelApi may be used to retrieve a genuine java double and java.util.Date object from an Excel spreadsheet. For completeness the label is also cast to it's correct type. The code snippet also illustrates how to verify that cell is of the expected type - this can be useful when performing validations on the spreadsheet for presence of correct datatypes in the spreadsheet.
      String a1 = null;
      Double b2 = 0;
      Date c2 = null;
                        Cell a1 = sheet.getCell(0,0);
                        Cell b2 = sheet.getCell(1,1);
                        Cell c2 = sheet.getCell(2,1);
                        if (a1.getType() == CellType.LABEL)
                           LabelCell lc = (LabelCell) a1;
                           stringa1 = lc.getString();
                         if (b2.getType() == CellType.NUMBER)
                           NumberCell nc = (NumberCell) b2;
                           numberb2 = nc.getValue();
                          if (c2.getType() == CellType.DATE)
                            DateCell dc = (DateCell) c2;
                            datec2 = dc.getDate();
                           // operate on dates and doubles
    It is recommended to, use the close()  method (as in the code piece below)   when you are done with processing all the cells.This frees up any allocated memory used when reading spreadsheets and is particularly important when reading large spreadsheets.              
              // Finished - close the workbook and free up memory
              workbook.close();
    The API class files are availble in the 'jxl.jar', which is available for download.
    Regards
    Raghu

  • Unable to perform Calculations on Excel exported from Web Dynpro ABAP

    Hi Gurus,
    I have a custom functionality "Export to Excel" internal table data on my web dynpro application. I dint go with standard ALV feature because it doesnot give flexibility to add colours to excel sheet and add multiple tabs and so i had to write XML ABAP coding in the web dynpro application to achieve this. While passing the internal table data into cells, i created cells with string data type and hence all the fields in the excel are now in char type. Users are unable to perform any calculations because of this issue, i tried to format the cells but it doesnot work. Please help me.
    Regards,
    Pravs.

    Hi,
    Just do the following in excel before downloading and check whether it works.
    Tools->Options->International tab.
    In that mention decimal separator as ,(comma).
    Thousand separator as .(dot).
    Uncheck use system separators.

Maybe you are looking for

  • HP messed up my borderless printing

    I have always been able to do borderless printing to my Lexmark 705 printer by setting print margins to zero in the Print Set-up dialog. Unforunately, I recently installed an HP printer. Now, all my printers ignore the page margin settings, always pr

  • Where is the logfile for NetworkManager in Archlinux?

    I recently installed gnome shell on my arch build and decided to switch to NetworkManager so I could easily change the network stuff within gnome. ...but now I have no wireless. Selecting a wireless network in the gnome-panel's applet does nothing, n

  • Sun Studio 12 support DOS text (e.g. CR\LF) for line continuation ?

    I moved up to Sun Studio 12 hoping that I could solve a age old problem that allows me to share my code via NFS across multiple systems. AIX and GCC Linux precompilers and compilers have not problem with a code like this: #ifndef FSIBITON^M #define F

  • AP WAP4410N Product Info...

    Hello, I am planning to buy an access point (WAP4410N) for a meeting room office ...According to Cisco technical documents indicate that the AP is the only work in mixed mode (B / N / G) and supports remote administration with console Telnet (most im

  • Win 7 8.1, reinstall CR?

    Hi, I uograded to Win8.1.  Ran a scan (Windows Upgrade Advisor) that indicated a few apps that would need to be reinstalled, but it said that my install of CR v14 was fine. Lie among Lies. So now I'm reinstalling. Anyone with experience... do I need