cancel
Showing results for 
Search instead for 
Did you mean: 

How to read an excel file in webdynpro application

0 Kudos

Hello Experts,

Can someone please tell me how to read an excel file in a webdynpro application?

There is a tutorial for how to write contect into an excel, but i want to read the excel.

Can someone help please !!

Thanks and Kind regards,

G.Singh.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

Check this thread ....

https://forums.sdn.sap.com/click.jspa?searchID=6699422&messageID=2935176

https://forums.sdn.sap.com/click.jspa?searchID=6699422&messageID=2760876

check this blog ...

/people/subramanian.venkateswaran2/blog/2006/10/02/enhanced-file-upload--uploading-and-processing-excel-sheets

Regards

Akshaya

Answers (9)

Answers (9)

Former Member
0 Kudos

Hi

Refer this Thread

Regards

Chandran S

0 Kudos

Thanks experts...

Kind Regards,

G. Singh

Former Member
0 Kudos

Hi G.Singh,

I have a similar requirement for my application can u let me know the procedure step-by-step on how u got to fulfill the requirement.

In my application i have a Browse Button,when i click on it and get the Excel file the contents of the file must be displayed in the page through WebDynPro.

Can anyone let me know how this is possible.

Thanks and regards,

Chandrashekar.

Former Member
0 Kudos

Hello,

First u have to create a Library file which contains the jar for reading the excel file.

Then u have to add this library as used DC i ur project.

After this u can use the code given above to read the excel file from the KM folder.

Regards,

Gursimran Singh

Former Member
0 Kudos

Hi Gursimran,

I too have a requirement of reading and writing to excel file in KM repository.

Can you post links to the tutorial or the code for writing to excel file.

Regards,

Sumant

0 Kudos

Hello Experts,

I have done all the given above.

I want to read a excel file from KM. My code is as below

ResourceContext resourceContext = buildResourceContext();

IResourceFactory resourceFactory = ResourceFactory.getInstance();

RID pathRID = RID.getRID("/documents/ExcelReport.xls");

IResource resource = resourceFactory.getResource(pathRID, resourceContext);

Workbook wb = Workbook.getWorkbook(resource.getURI().getPath());

Sheet sh = wb.getSheet(0);

int columns = sh.getColumns();

int rows = sh.getRows();

wdComponentAPI.getMessageManager().reportSuccess(" Rows: " + rows);

wdComponentAPI.getMessageManager().reportSuccess(" Columns: " + columns);

This does not give me the excel file form the KM

Can you please just what i can do at this point?

Kind Regards,

G Singh.

0 Kudos

Can you please be a little elaborate on how to create and external library and then how to refer it..

Thanks and Regards,

G. Singh

Former Member
0 Kudos

Hi,

Refer this blog /people/valery.silaev/blog/2005/09/14/a-bit-of-impractical-scripting-for-web-dynpro

Regards

Ayyapparaj

0 Kudos

I have laready added it as an External jar to my project.

Thanks and Regards,

G. Singh

0 Kudos

Hello LakshmiNarayana

Yes i am using a DC. Can you tell me how to include this jar into the DC project.

Regards,

G. Singh

Former Member
0 Kudos

hi,

Create external library for the jare, and reference this.

Regards

Ayyapparaj

0 Kudos

Hello Experts,

I have already gone through all these links.

My code looks something like this

File xlsFile = new File(resource.getURI().getPath());

Workbook wb =Workbook.getWorkbook(xlsFile);

Sheet sh = wb.getSheet(0);

int columns = sh.getColumns();

int rows = sh.getRows();

int i=0;

for(int j=1;j<=rows;j++){

Cell c1 = sh.getCell(i,j); wdComponentAPI.getMessageManager().reportSuccess( " Report ID: " + c1.getContents());

}

I am addinh the Librarary reference to "jxl.jar". Also copying it to the Lib folder of my project. But still i get the error

"java.lang.NoClassDefFoundError: jxl/Workbook "

Can you help.

Kind Regards,

G. Singh

Former Member
0 Kudos

Hi,

Add "jxl.jar" as External jar to your WD Application

Try Reload+Rebuild after adding

or

Right click on your project> repair> ProjectStructureAndClassPath

If you are using DC, the jar will be lost after "build"ing DC

Regards

LakshmiNarayana

Former Member
0 Kudos

Hi ,

try this code Using JExcel Library

Workbook w=Workbook.getWorkbook(f);

Sheet sh=w.getSheet(0);

int cols=sh.getColumns();

int rows=sh.getRows();

Cell c=null;

String s1=null;

String s2=null;

String s3=null;

String s4=null;

for(int i=1;i<rows;i++)

{

s1=sh.getCell(0,i).getContents();

s2=sh.getCell(1,i).getContents();

s3=sh.getCell(2,i).getContents();

s4=sh.getCell(3,i).getContents();

}

Add jxl.jar file in java build path of your application

then Organize imports

Regards

LakshmiNarayana

Former Member
0 Kudos

Hi

Try using Apache POI

http://poi.apache.org/

Regards

Ayyapparaj