How to get and read uplaoded files

Hi,
I need to design a view wherein I need to list the uploaded files in Webdynpro(Java) application, and also need to read file from server. the filetype is Microsoft excel.

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
make sure that the cardinality of the node i.e. upload node is 1:1

Similar Messages

  • How to get and read a file from META-INF directory

    how to get and read a file from META-INF directory in a EJB project

    Use this.getClass().getResourceAsStream("/META-INF/filename");This should work. Probably, you would need to set the Manifest Class-Path attribute.

  • How to create and read text file using LabVIEW 7.1 PDA module?

    How to create and read text file using LabVIEW 7.1 PDA module? I can not create a text file and read it.
    I attach my code here.
    Attachments:
    File_IO.vi ‏82 KB

    Well my acquisition code runs perfect. The problem is reading it. I can't seem to read my data no matter what I do. My data gets saved as a string using the array to string vi but I've read that the string to array vi (which I need to convert back to array to read my data) does not work on the pda. I'm using version 8.0. So I was trying to modify the program posted in this discussion so that it would save data from my DAQ. I did that but I still can't read the data after its saved. I really don't know what else to do. All I need to do is read the data on the pda itself. I can't understand why I'm having such a hard time doing that. I found a possible solution on another discussion that talks about parsing the strings because of the bug in the "string to array" vi. However, that lead me to another problem because for some reason, the array indicators or graphs don't function on the pda. When i build the program to the pda or emulator, the array indicators are faded out on the front panel as if the function is not valid. Does this kind of help give a better picture of what I'm trying to do. Simply read data back. Thanks.

  • How to open and read binary files?

    How do I open and read Binary files?

    Did you  look on The Unarchiver's web site where it has a link to older versions? http://theunarchiver.googlecode.com/files/TheUnarchiver3.2_legacy.zip
    The best thing to do is ask your friends what programs they used to produce these files, or at least what format files they are producing.  Otherwise it's like being shown a car and given a bundle of 200 keys with no idea to which one to use, or even if any of them work with that car.
    Using The Unarchiver will likely not do anything because it too will not know what format files are involved, and they may not even been in an archived format.  If they sent you a Word file without telling you (a favorite of Windows users to do  -- it drives me crazy when they could have just sent them in plain text), The Unarchiver won't open them.  If it's a picture file then using Hexedit will just show you a bunch of unintelligible stuff as shown in an earlier post, though you may see a line of text providing a hint.
    As I said earlier, often .bin may be an executable program which needs another program to actually interpret it.  That's what Java is trying to do.  Still, it may think it can execute the file, but it is highly unlikely somebody would send you an executable program (and if they did I would not trust it).  For all you know it may be a Windows virus.

  • How to open and read many files from a directory and store contents in 2D array?

    I want to make a VI that opens and reads the data from various files contained in a directory (200 files each with 2 columns) and store these in a single 2D array. For file number 1 I want to store the data from both columns in the 2D array, but for files 2 to 200 I only want to store the second column of each file. Can someone please help?

    Hi Nadav,
    Thanks for your help. I have followed your instructions but i cannot get it to work. I used the LIST DIRECTORY to list the files in the directory - that works. However, how do I read each of the 200 files using READ FROM SPREADSHEET FILE without me having to manually select each of the 200 files? So, if I use LIST DIRECTORY to list all 200 files in an array, how do I get each of these to open and store the data in a 2D array? Here is what I have done (File called read_files.VI) Could you please help me? Thank you very much in advance.
    Attachments:
    read_files.vi ‏18 KB

  • How to get and display image file through servlet

    If I've got a jpg file on the server..
    How can I use servlet to return that image via the following calling method
    /displayfile?filename=image.jpg
    the image.jpg in the server will return
    I know that I need to set the content type to image/jpeg
    after that, how can I return the image file to browser?

    - Get the "file" Parameter from the URL QueryString
    - check if the File specified exists on your filesystem
    - read in the jpg from the file (best would be binary)
    - set the right Mime Type (as you already wrote)
    - write the filecontent to the ServletOutput as you would do with any other content
    - that's it.

  • How to get the read input file name in bpel process using File Adapter.

    Hi,
    I am reading a .txt file from configured directory using File Adapter.
    I had configured file adapter to read file with naming pattern “SalesOrder.*\.txt”.
    Now I had requirement to access the actual file name in bpel process eg: “SalesOrder123.txt”
    How can I get the file name in bpel process.
    Any help is appreciated.
    Vidya.

    1) create a variable of message type. Click on Browse Message type. Here you select Message Type-->Project WSDL Files -->fileAdapterInboundHeader-->Message Types-->Inboundheader_msg. Then click OK
    2)Next dbl Click on teh receive Activity which is receing your File from teh File Adapter. Go to the Adapter Tab. Click on Browse variable and select the variable that you had just created above.
    This would get the File name in the variable declared

  • How to write and read Xml file from database if possible?

    Hi all,
    I need to read the .Xml file when receives from Source systems and write the data into the table as well as write in the.xml file thru reading the data from table as per the client needs. I am stranger to this area. Since, please provide some examples how to approach the same.
    Thanks in advance !!
    Regards.
    Vissu.....

    The XML DB forum is better suited to your question.
    It also has a FAQ which details how to read and shred XML into tables as well as other common XML based questions...
    XML DB FAQ

  • HOW CAN GET SIZE OF UPLAODED FILES UNDER IRECUIRMENT

    Dear All ,
    How can we get size for Irecuitiment .When users uploaded documents . I want to know the size of uploaded files.
    I try select * from IRC_DOCUEMTNS ..
    Any Idea please.
    Edited by: user12010537 on 21/03/2010 01:29 ص

    Hi Jason!
    I believe that should be all you need to do but a better place to ask would be the Parallels forums. Have a look here <http://forums.parallels.com/>.
    Hope this helps! bill
    1 GHz Powerbook G4   Mac OS X (10.4.8)  

  • How to import and read .lmx files into 2710 Nav.?

    All,
    is there a way to import a route (lmx file) and use it with the 2710?
    I can't find the way to open such a file...
    Thanks a lot for any help, Benoit.

    There is a way (not very comfortable but working) how to import POIs in Nokia 2710.
    Create a set of LMX files, __each containing just one POI__.
    Store those files somewhere on the SD card.
    When you need to reach a POI, select the particular file (Menu / Gallery / All content / Memory card / (the particular directory) / (the particular file)) and select Open.
    The POI will open in the Ovi Maps. Now you can navigate to it (Options / Navigate to) or save it (by Options / Use location / Save location). When saving, you will need to insert the name (the name is NOT copied from the .LMX file).
    Make sure that you have a map covering the area of POIs (if you do NOT have it, upon opening the POI file, you will just get yellow background).
    Examples of LMX files are attached. Examples are located in the Czech republic so make sure that you have the map of the Czech republic.
    PS: Maybe someone would be interested to write a J2ME application which
    1) would parse .GPX file with a lot of POIs
    2) show the POIs to the user (including all the details of POI)
    3) when user selects a POI, generate an LMX file and invoke system to show it (using platformRequest J2ME API).
    4) alternatively, user could insert the GPS coordinates directly.
    Attachments:
    lm.zip ‏1 KB

  • I am getting messages that I can't download and read .pdf files since I have the wrong Adobe reader. I know about their security disasters of course, but I downloaded the latest version of Adobe Reader from the Adobe web site and I have other ,pdf file re

    I am getting messages that I can't download and read .pdf files since I have the wrong Adobe reader. I know about their security disasters of course, but I downloaded the latest version of Adobe Reader from the Adobe web site and I have other ,pdf file readers as well, and for some reason they won't work either. I have 5 computers running top end processors and RAM. By this I mean I have one, this one which I am using that has an AMD Phenom Black 3.2 Quad-core with 8 GBs of Corsair top DDR2 RAM, my other two AMD have either an Athlon II triple core with 4 GBs of DDR2 Corsair RAM, one with the Phenom X4 965 3.4 GHz Quad-core with 8 GBs of their best DDR2 RAM, and two Intels with the i7 920 Processors using the triple channel 1366 socket processors and one with 8 GBs of low latency DDR3 RAM and the other with 4 GBs of the same RAM. I am getting the message on this one, which has a fresh install of XP Pro X64 operating system, as do the other 4 as well. I have run Avast Business Pro Anti-virus on this one, which I am getting the message on with a single result which I deleted, and also both Spybot Search and Destroy, which came back clean as well as Malwarebytes Antimalware, which got a lot of tracing cookies now removed, and SuperAntiSpware which also found a few cookies also now deleted. Can you tell me what I need to do to get these files to show as .pdf files rather than as a clean blank page. One other issue is that I wish to know how to turn off my downloads so they are saved and Mozilla will give me the option of returning them instead of me losing them all together as it does now. Thanks for your assistance. If there is another Adobe reader I should download and install, could you provide me with the link to it? I appreciate your assistance here
    == When I download and try to read a .pdf file and when I am asked to turn off all Firefox files and if I do, I lose them since I need to know how to save them without rebooting my computer.

    Brilliant! Problem solved! Thanks so much.

  • Programming help - how to get the read-only state of PDF file is windows explorer preview is ON?

    Programming help - how to get the read-only state of PDF file is windows explorer preview is ON?
    I'm developing an application where a file is need to be saved as pdf. But, if there is already a pdf file with same name in the specified directory, I wish to overwrite it. And in the overwrite case, read-only files should not be overwritten. If the duplicate(old) file is opened in windows (Win7) explorer preview, it is write protected. So, it should not be overwritten. I tried to get the '
    FILE_ATTRIBUTE_READONLY' using MS API 'GetFileAttributes', but it didn't succeed. How Adobe marks the file as read-only for preview? Do I need to check some other attribute of the file?
    Thanks!

    Divya - I have done it in the past following these documents. Please read it and try it it will work.
    Please read it in the following order since both are a continuation documents for the same purpose (it also contains how to change colors of row dynamically but I didnt do that part I just did the read_only part as your requirement) 
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0625002-596c-2b10-46af-91cb31b71393
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0155eb5-b6ce-2b10-3195-d9704982d69b?quicklink=index&overridelayout=true
    thanks!
    Jason PV

  • How cot create and read files in ALLUSERSPROFILE directory

    Hi,
    I have a program that is to be used both with Windows XP, Vista, 7 and 8. It should create and read a file in ALLUSERSPROFILE, which I have learned to be different directories in XP and the other Windows versions. But after looking all over internet, I can't
    find any clear answer how to do this. I thought the following should work, but it doesn't:
    testfile = fopen("%ALLUSERSPROFILE%/testfile.dat", "r");
    Although the file exist, testfile gets the value of zero. I've also tried other strings instead of "ALLUSERSPROFILE," but no luck. Could anyone tell me how to do this?
    Thanks in advance.

    I tried the following:
         SHGetKnownFolderPath( &FOLDERID_ProgramData, 0, 0, &userpath); 
    Then the program compiled. But it did not work:
         fopen("%userpath%\\Testfolder\\Testfile.ini", "r"); 
    did not open the file, although it is there.
    Then I read that this function can't be used with Windows XP, so I
    switched to the deprecated SHGetFolderPath 
        TCHAR userpath[MAX_PATH];
         SHGetFolderPath(0, CSIDL_COMMON_APPDATA, 0, SHGFP_TYPE_CURRENT, userpath);
    According to the MSDN pages, one then could use the 
        PathAppend (userpath, TEXT("Testfolder/Testfile.ini"));
    I then added Shlwapi.h and compiled and got the following error message 
         main.obj : error LNK2001: unresolved external symbol __imp__PathAppendW@8  
         fatal error LNK1120: 1 unresolved externals
    Then I again tried 
       fopen("%userpath%\\Testfolder\\Testfile.ini", "r");
    but neither did this work. So now I don’t know what to do.

  • How to open and read an external file in Dashboard widget?

    I am new to Dashboard widgets and also Javascript. I have written a widget that needs to open and read a file on the local file system. I have searched a lot and have not found any documentation or reference on the internet as to how to do this.
    I know it can be done since there is a checkbox in the widget attributes that says "Allow External File Access".
    can anyone help me out here?
    Thanks

    You need to define the AllowFileAccessOutsideOfWidget key to Yes.
    You also need to define the AllowFullAccess key.
    You may also need to define the AllowSystem key (to Yes of course).
    Mihalis.
    PS. If you cannot find any other documentation please check http://widgetbook.blogspot.com.

  • How to get the most current file based on date and time stamp using SSIS?

    Hello,
    Let us assume that files get copied in a specific directory. We need to pick up a file and load data. Can you guys let me know how to get the most current file based on date and time stamp using SSIS?
    Thanks
    thx regards dinesh vv

    hi simon
    i excuted this script it is giving error..
       Microsoft SQL Server Integration Services Script Task
       Write scripts using Microsoft Visual C# 2008.
       The ScriptMain is the entry point class of the script.
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    namespace ST_9a6d985a04b249c2addd766b58fee890.csproj
        [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
        public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
            #region VSTA generated code
            enum ScriptResults
                Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
                Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
            #endregion
            The execution engine calls this method when the task executes.
            To access the object model, use the Dts property. Connections, variables, events,
            and logging features are available as members of the Dts property as shown in the following examples.
            To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value;
            To post a log entry, call Dts.Log("This is my log text", 999, null);
            To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true);
            To use the connections collection use something like the following:
            ConnectionManager cm = Dts.Connections.Add("OLEDB");
            cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;";
            Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
            To open Help, press F1.
            public void Main()
                string file = Dts.Variables["User::FolderName"].Value.ToString();
                string[] files = System.IO.Directory.GetFiles(Dts.Variables["User::FolderName"].Value.ToString());
                System.IO.FileInfo finf;
                DateTime currentDate = new DateTime();
                string lastFile = string.Empty;
                foreach (string f in files)
                    finf = new System.IO.FileInfo(f);
                    if (finf.CreationTime >= currentDate)
                        currentDate = finf.CreationTime;
                        lastFile = f;
                Dts.Variables["User::LastFile"].Value = lastFile;
                Dts.TaskResult = (int)ScriptResults.Success;
    thx regards dinesh vv

Maybe you are looking for