on 07-31-2006 9:19 AM
Hi All,
I have a Web Dynpro project which reads from a constant excel file.
If I put the excel file somewhere in the server's file system I can read it without a problem.
However, I want the file to be embedded in the WD project.
Where do I need to put the file and how can I access it from Web Dynpro?
I try to put it in
<Project> -> src -> mimes -> Components -> <component name> -> <excel file>
but it didn't work
Thanks,
Omri
You have placed the file in the right location. In Webdynpro use:
InputStream templateInputStream = this.getClass().getClassLoader().getResourceAsStream("xyz.xls");
Regards
Sebastian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sebastian,
I tried using the following code:
<i>InputStream templateInputStream = this.getClass().getClassLoader().getResourceAsStream("myfile1213.csv");
InputStreamReader is = new InputStreamReader(templateInputStream,"windows-1255");
excelData = CSVParser.parse(is);</i>
and then print the content of the excelData.
I don't get an exception but the file isn't being parsed.
I found out that the location of the file is:
http://<server name>:<port>/webdynpro/resources/local/<project name>/Components/<component name>/<my file name>
How can I generate this URL in Web Dynpro?
Omri
Hi,
Your files should go here:
Project->src->mimes->Components-><your component>->file(say abc.csv).
You can do all this through the Navigator view of your NWDS.
Now you can read it as follows:
try{
String path = WDURLGenerator.getResourcePath( wdComponentAPI.getDeployableObjectPart(), "abc.csv");
FileReader f = new FileReader(path);
BufferedReader r = new BufferedReader(f);
//Do further processing...
}
catch(WDAliasResolvingException e3){
}
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Regards,
Satyajit.
Perhaps there is something wrong with the CSV parser. First of all try to print the file content without parsing it:
InputStream templateInputStream = this.getClass().getClassLoader().getResourceAsStream("xyz.csv");
ByteArrayOutputStream templateOutputStream = new ByteArrayOutputStream();
IOUtil.write(templateInputStream, templateOutputStream);
String test = new String(templateOutputStream.toByteArray());
// output the string in your application
Regards
Sebastian
Hi Omri,
As you mentioned in the first line "
If I put the excel file somewhere in the server's file system I can read it without a problem.".
My scenario is also like this only where in i am getting the path something like this .....usr\sap\server\....filename.doc.
I have placed this file there and now i want to read the whole contents of this into an internal table. Could you please provide me the sample code for this would be highly apreciable as i want to read this code into an internal table and send the same to the RFC at the backend.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Cohen,
You can also use the Excel file by creating a Resource Bundle.
You can create a resource BUndle by performing the following.
1. Add a new directory resource to the directory src/packages/",
this.getClass().getClassLoader());
resourceHandlerForQuestions.get();
Thanks,
Pavan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.