Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Excel to some type of Java data structure

 
Ranch Hand
Posts: 191
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wish to get an Excel sheet data into some kind of data structure in Java.

At first I was going to use an Array.  Then I found out that each row of data may have a different number of columns.   I don't know the maximum number of columns so I would have to make it a ragged array.  They only way that I know how to make the array larger is to copy it to a new array.  First I'm not sure how to do this but I'd imagine if the arrays got huge that I'd be using a lot of memory and maybe time.   I'd have to learn how to make new arrays and destroy old ones.

I read that using lists might be the way to go but I do not have experience with them.

A class for each row and then putting the row classes into a parent class might work but I don't know if it makes sense or how to go about it.

This is all easy in VBScript because it lets me redimension arrays but I don't know a good way to do this in Java.  

Can some of you guide me on how to get datasheet information into some kind of data holder in Java?  

Thanks,

Kevin
 
Marshal
Posts: 26912
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Excel sheets can cover a large spectrum of data designs (including lack of design). Your suggestion of a class to represent a row of the sheet and then producing a list of objects of that class is a fairly common solution, but it only works if all of the rows represent the same data items. This doesn't always work because people stick in things like headers and subtotals and who knows what else.

So there's no one right answer. You can't really decide on what Java data structure would work before knowing what data structure the sheet is supposed to represent.
 
Rancher
Posts: 508
15
Notepad Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

...how to get datasheet information into some kind of data holder in Java?



Apache POI software can be used to read from and write to spreadsheets, like MS Excel. Its opensource and free to use. I have used it myself sometime back to generate reports; its quite easy to use and is well documented online.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic