-1

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.

ps007
  • 35
  • 6

2 Answers2

0

Use Apachie POI jars to read the excel file cell by cell . You can convert the data from Excel to Map very easyly

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