cancel
Showing results for 
Search instead for 
Did you mean: 

Read a Excel file stored in WebDynpro packages(src/mimes/components)

ashish_shah
Contributor
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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/

Answers (1)

Answers (1)

ashish_shah
Contributor
0 Kudos

Used JXL libraries to read the excel file.