Skip to content

Instantly share code, notes, and snippets.

@sae13
Created October 6, 2019 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sae13/89006ff3102689b03a2c94d5dc2b94f9 to your computer and use it in GitHub Desktop.
Save sae13/89006ff3102689b03a2c94d5dc2b94f9 to your computer and use it in GitHub Desktop.
public static void getUserName(String xlsLocation) throws IOException {
FileInputStream file = new FileInputStream( new File(xlsLocation));
Workbook workbook = new XSSFWorkbook(file);
Sheet sheet = workbook.getSheetAt(0);
for(Row row: sheet)
{
Cell tenCell = row.getCell(0);
tenCell.setCellType(CellType.STRING);
Cell sixCell = row.getCell(1);
sixCell.setCellType(CellType.STRING);
try {
String email = getEmail(Integer.parseInt(sixCell.getStringCellValue()));
Cell emailCell = row.createCell(2);
if (email != null) {
emailCell.setCellValue(email);
}
}
catch (Exception e){
e.printStackTrace();
}
}
workbook.write(new FileOutputStream("/tmp/2.xlsx"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment