Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

read a excel file into java array list

 
anvi kon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone give me some examples to read an excel file and store the contents of excel file into arraylist?
 
Henry Wong
author
Marshal
Pie
Posts: 20892
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

http://poi.apache.org/

Henry


 
anvi kon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic