I have a xlsx file, that has some tabs with different data. I want to be able to save each row of a tab in a list. The first thing that comes to mind is a list of lists, but I was wondering if there is another way. I'd like to save that information in a object, with all its benefits, but can't think of a way to generate/create such diverse objects on the fly. The data in the xlsx is diverse and ideally the program is agnostic of any content.So instead of e.g. create a list for each row, than put that list in another list for each tab and each tab in another list, I'd like to store the information that each row represents in a single object and just have a list of different objects.The question can be summarized as : What is an alternative to list of lists ?A small graphic to visualize the problem :+--------------------------------------------------------------------+|LIST                                                                ||                                                                    ||    +------------------+ +------------------+ +-----------------+   ||    | Class1           | | Class2           | | Class3          |   ||    |------------------| |------------------| |-----------------|   ||    | var1             | | var1             | | var5            |   ||    | var2             | | var2             | | var6            |   ||... | var3             | |                  | | var7            |...||    |                  | |                  | |                 |   ||    |                  | |                  | |                 |   ||    |                  | |                  | |                 |   ||    |                  | |                  | |                 |   ||    +------------------+ +------------------+ +-----------------+   ||                                                                    |+--------------------------------------------------------------------+
Flexible / Dynamic object creation or Alternative to list of lists
java;design patterns;object oriented design
I assume that your worksheets contain tabular data, i.e., the first row contains field names and the following rows contain values. In such a case it would make sense to define a Table class whose instances would each contain the contents of one worksheet. This Table object could hold general information regarding one worksheet, if necessary, like the name of the worksheet tab.It could also have a list holding the column names or a dictionary holding the column indexes with the column names as a key. If you define a Column class for this purpose (instead of just a string for the column name), it allows you to store additional information regarding a column, like its type (numeric, text, date) and display format.Even if you don't need this kind of infrastructure right now, having such classes allows you to add this kind of functionality much easier later.The Table class would also contain a list of rows. Here again, having a Row class can have advantages. However, it would be ok to represent one row as an array of strings, for instance. Since each row of the table has the same length, a list is not necessary here.Instead of using strings to store the values, having a Value class or struct can also have advantages. Such a type could automatically convert strings to an appropriate type, could perform comparisons between values of the same type etc.Without knowing more about your data and the kind of logic you want to apply to it, it is difficult to give you an answer tailored to fit your needs.