I am trying to read a excel file(xlsm as have macros) everything seem to be correct but somehow code taking lot of time to execute. Here is my code:
public Map<String, ReportParameter> getParameters(String excelFileName) {
File excelFile = new File(repo.getRepositoryPath() + File.separator + excelFileName);
try (FileInputStream input_document = new FileInputStream(excelFile);
XSSFWorkbook workbook = new XSSFWorkbook(input_document)) {
XSSFSheet sheet = workbook.getSheet("parametre");
Map<String, String> resultMap = new HashMap<>();
Map<String, Integer> indexMap = new HashMap<>();
int pos = 1;
for (Row row : sheet) {
Cell cell = row.getCell(0);
if(cell == null) {
continue;
}
indexMap.put(cell.getStringCellValue(), pos++);
resultMap.put(cell.getStringCellValue(), row.getCell(1).getStringCellValue());
}
return convertParameterTypesToReportParameters(resultMap, indexMap);
} catch (Exception e) {
throw new RuntimeException(e);
}
I also try to use OPCPackage but have same result. Can someone give me suggestion why it is taking lot of time and is there anything which can improve performance.