I am uploading an excel file which has got two columns as Name & Value. I want to read the value from column Name and corresponding value for name and put in HashMap as key value pair.
Asked
Active
Viewed 1,747 times
2 Answers
0
Use Apachie POI jars to read the excel file cell by cell . You can convert the data from Excel to Map very easyly

Radha Krishnan
- 21
- 2
0
You should first export the excel file as a CSV file.
Then you want to read through this CSV file and add each name-value pair to a HashMap.
I wrote up a sample program here:
FileReader reader = new FileReader(CSVFilePathHere);
BufferedReader buffer = new BufferedReader(reader);
Map<String, Integer> map = new HashMap<String, Integer>();
String input_string = "";
String s = "";
Scanner in = null;
while ((input_string = buffer.readLine()) != null) {
String[] arr = input_string.split(",");
map.put(arr[0], Integer.parseInt(arr[1]));
}
reader.close();
buffer.close();

CarManuel
- 325
- 3
- 12