Assumed you need a generic solution, where the program is not tied to a specific column structure at run time, you can use an
ArrayList of rows, where each row is a string array
String. You will need an additional
HashTable<String,int> to store the mapping of the column name to the column index (a
HashMap will probably work, either). So if you have
you can implement
String getColumnValue(String columnName, int indexOfValue)
You may consider to add some error handling here, some code which determines the column names and some more code which reads the excel rows into the
String arrays with one entry per column. If you need the values in a typed form, consider to replace the
String rows by
Object and store the cell content as objects of type
Date. You can also implement a speficic class
CellContent and store your rows as
CellContent arrays, if you have specific requirements and a need to implement specific behaviour or methods for a content element.
Note this is a rough scetch of a general purpose solution. One can modify this and create different variants, for more specific requirements.
If you need a less generic variant, because your program expects a specific column structure, best solution is probably to create a specific DTO class
MyRowType for holding the specific values of a row, and use a variable like
ArrayList<MyRowType> tableValues for storing the table content.