Read Sheetname from excel - Excel Importer module

0
Hi Folks, Is there any way to read sheet name of Excel workbook in Excel Importer module. Many thanks in advance.!
asked
2 answers
0

You would have to alter the Java code of the module. The module retrieves the correct sheet based on the index set in the template. Since the Excel Importer module uses complex java code, it is hard to add this feature in there. The best bet would be to create an extra Java action to retrieve the name of the worksheet via the by the Excel Import module already loaded Apache POI Java library. After reading the Excel file to an InputStream, get the correct sheet based on the index set in the template. VIa the Apache POI library you can now get the sheetname. Something like:

File f = new File(Core.getConfiguration().getTempPath().getAbsolutePath() + "/Mendix_ExcelImporter_" + file.getId().toLong(), "");
try (InputStream inputstream = Core.getFileDocumentContent(context, file)) {
	XSSFWorkbook wb = new XSSFWorkbook(inputstream);
	XSSFSheet sheet = wb.getSheetAt(index);
	String sheetName = sheet.getSheetName();
	return sheetName;
}

 

answered
0

hi Nirmal have you tried this one is it working?

answered