Quantcast
Channel: Java Programming Forum - Learn Java Programming - Apache POI
Viewing all articles
Browse latest Browse all 120

Read column from Excel represented as Enum

$
0
0
Hello,

Assuming that we have Excel file and the elements of requested column represented as Enum class
Code:

public enum FederalState {BW, BY, BE, BB, BR, HH, HE, MV, NI, NRW, RP, SL, SN, ST, SH, TH}
As know in Enum there are no setters and getters so how to represent our data from enum class to read that column which contain the elements.

Code:

//Iterate through each rows from first sheet
            Iterator<Row> rowIterator = sheet.iterator();
            while(rowIterator.hasNext()) {
                Row row = rowIterator.next();
               
                //display from the first row
                if(row.getRowNum() > 0)
                {
                        FederalState[] loc = FederalState.values();
// do some thing to read the elements from that column

That all what i could do it , i doubt if FederalState[] loc = FederalState.values(); is correct and if correct i have no idea how to continue using object "loc" as long as i don't have any setters or getters. (or should i create another class to represent the data with setters and getters?

Viewing all articles
Browse latest Browse all 120

Trending Articles