on 07-24-2008 10:01 AM
Hi Experts,
Few days back i asked a question in this forum to
Read a text file stored in WebDynpro packages(SRc/packages) , in this thread:
[https://www.sdn.sap.com/irj/sdn/thread?threadID=937592&tstart=0]
And i received many replies and was able to solve my problem, thanks to all the experts.
Now in a similar requirement i need to read an excel file kept under the folder
src/mimes/Components/com.demo.test.something
and the data in this excel file needs to be stored in a Node.
I tried the code:
String filePath = WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(), "test.xls");
File txtFile = new File(filePath);
BufferedReader reader = new BufferedReader(new FileReader(txtFile));
String line;
String res = "";
while ((line = reader.readLine()) != null){
res += line + "\n";
wdComponentAPI.getMessageManager().reportSuccess(line);
}
//res contains the full text of the file with line breaks preserved
reader.close();
Here "res" gave me many junk characters.
Seems it only works for text files and not for Excel files.
Can you guys suggest how can i read Excel file kept under src/mimes/components?
Regards,
Ashish Shah
Hi,
the excel file is a binary file so you cannot expect to parse it like a simple text file.
You should instead use a library, like jxl, to manage it.
Look here
http://jexcelapi.sourceforge.net/
http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Used JXL libraries to read the excel file.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.