Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

read a excel file into java array list

 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author
Posts: 23956
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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









}







 
Sheriff
Posts: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic