Skip to content

Instantly share code, notes, and snippets.

@erajanraja24
Created September 26, 2017 11:58
Show Gist options
  • Save erajanraja24/6f42699cb2154125d82b13399d85df8f to your computer and use it in GitHub Desktop.
Save erajanraja24/6f42699cb2154125d82b13399d85df8f to your computer and use it in GitHub Desktop.
Read Excel File
public static HashMap<Integer,HashMap<Integer,String>> getUsername() throws IOException
{
int lrow,lcol;
FileInputStream fs=new FileInputStream(new File("Upload_Sequence.xlsx"));
XSSFWorkbook wb=new XSSFWorkbook(fs);
XSSFSheet sh0=wb.getSheet("Sheet1");
lrow=sh0.getLastRowNum();
System.out.println("Last row "+lrow);
//HashMap<Integer,String> innerMap=new HashMap<Integer,String>();
//lrow=ExcelRead.getLastRow("Sheet2", "Upload_Sequence.xlsx");
for(int i=0;i<lrow;i++)
{
lcol=sh0.getRow(i).getLastCellNum();
outerMap.put(i, new HashMap<Integer, String>());
for(int j=0;j<lcol;j++)
{
outerMap.get(i).put(j,sh0.getRow(i).getCell(j).toString());
//outerMap.put(i,innerMap.put(j, ExcelRead.getvalue(j, i, "Sheet1", "Upload_Sequence.xlsx"));
//innerMap.put(j, ExcelRead.getvalue(j, i, "Sheet1", "Upload_Sequence.xlsx"));
//outerMap
//System.out.println(outerMap.get(i).get(j)+"Mapped To "+i+" "+j);
}
}
/*for(int i=0;i<lrow;i++)
{
lcol=sh0.getRow(i).getLastCellNum();
for(int j=0;j<lcol;j++)
{
System.out.println(outerMap.get(i).get(j));
}
}
*/
//wb.close();
System.out.println("Im calling");
return outerMap;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment