|
|
|
@ -22,7 +22,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
*/
|
|
|
|
|
public class EXCELParser {
|
|
|
|
|
|
|
|
|
|
public <R> List<R> parse(InputStream file, String classForName)
|
|
|
|
|
public <R> List<R> parse(InputStream file, String classForName, String sheetName)
|
|
|
|
|
throws ClassNotFoundException, IOException, IllegalAccessException, InstantiationException,
|
|
|
|
|
InvalidFormatException {
|
|
|
|
|
|
|
|
|
@ -30,7 +30,11 @@ public class EXCELParser {
|
|
|
|
|
OPCPackage pkg = OPCPackage.open(file);
|
|
|
|
|
XSSFWorkbook wb = new XSSFWorkbook(pkg);
|
|
|
|
|
|
|
|
|
|
XSSFSheet sheet = wb.getSheet("cordisref-H2020topics");
|
|
|
|
|
XSSFSheet sheet = wb.getSheet(sheetName);
|
|
|
|
|
|
|
|
|
|
if(sheetName == null){
|
|
|
|
|
throw new RuntimeException("Sheet name " + sheetName + " not present in current file");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<R> ret = new ArrayList<>();
|
|
|
|
|
|
|
|
|
@ -49,7 +53,7 @@ public class EXCELParser {
|
|
|
|
|
headers.add(dataFormatter.formatCellValue(cell));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Class<?> clazz = Class.forName("eu.dnetlib.dhp.actionmanager.project.utils.EXCELTopic");
|
|
|
|
|
Class<?> clazz = Class.forName(classForName);
|
|
|
|
|
final Object cc = clazz.newInstance();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < headers.size(); i++) {
|
|
|
|
|