public list readvaluefromexcelsheet () {
list mapdataslist = new Arraylist ();
file rececilecate = new File ("D: \ eclipse \ string_api \ excelsheet \ book1111.xlsx"); "Новый"; < /p>
if (!excelLocation.exists()) {
throw new RuntimeException("File not found at location: " + excelLocation.getAbsolutePath());
}
try (FileInputStream f = new FileInputStream(excelLocation);
Workbook w = new XSSFWorkbook(f)) {
Sheet sheet = w.getSheet(sheetName);
Row headerRow = sheet.getRow(0);
for (int i = 1; i < sheet.getPhysicalNumberOfRows(); i++) {
Row currentRow = sheet.getRow(i);
HashMap mapDatas = new HashMap();
for (int j = 0; j < headerRow.getPhysicalNumberOfCells(); j++) {
Cell currentCell = currentRow.getCell(j);
String header = headerRow.getCell(j).getStringCellValue();
if (currentCell != null) {
switch (currentCell.getCellType()) {
case STRING : mapDatas.put(header, currentCell.getStringCellValue());
case NUMERIC : mapDatas.put(header, String.valueOf(currentCell.getNumericCellValue()));
}
}
}
mapDatasList.add(mapDatas);
}
} catch (Exception e) {
e.printStackTrace();
}
return mapDatasList;
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... rjava-lang
Я использовал ниже метод предоставления моих входных данных, но получить ошибку java.lang.error: неразрешенные проблемы ⇐ JAVA
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
## React Native Document Ficker Error Error Error: `GuardEdresultAsynctask` не найдена
Anonymous » » в форуме Android - 0 Ответы
- 14 Просмотры
-
Последнее сообщение Anonymous
-
-
-
## React Native Document Ficker Error Error Error: `GuardEdresultAsynctask` не найдена
Anonymous » » в форуме Android - 0 Ответы
- 13 Просмотры
-
Последнее сообщение Anonymous
-