aspose file tools*
The moose likes Java in General and the fly likes read a excel file into java array list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "read a excel file into java array list" Watch "read a excel file into java array list" New topic
Author

read a excel file into java array list

anvi kon
Ranch Hand

Joined: Jan 08, 2010
Posts: 133
Can anyone give me some examples to read an excel file and store the contents of excel file into arraylist?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18715
    
  40


There is an open sourced project specifically for this... It may be a good idea to start there.

http://poi.apache.org/

Henry



Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
anvi kon
Ranch Hand

Joined: Jan 08, 2010
Posts: 133
Is it possible iwth jxl?

I don't see any examples?

I am reading a excel file like bleow.

Workbook book = Workbook.getWorkbook(file.getInputStream());

Sheet sheet = book.getsheet(0);

Bean b = new Bean();
ArrayList list = new ArrayList();

for(in t i=1; i< sheet.getRow(); i++)
{

String name = sheet.getCell(0, i).getContents();

and so on.....


//add to a bean.

b.setName(name);

and so on...

}

I want to add a ArrayList..

Is that possible.?

Please let me know...

Thanks









}







Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

Please UseCodeTags. But yes, it's possible with JExcelAPI as well.

The trick is to create the bean instances inside the loop. In pseudo code


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: read a excel file into java array list