Я пытаюсь прочитать данные из Excel и хочу создать карту в Java для заголовка и значения.
Я могу читать данные, используя Java, но я не хочупропустите пустые значения, поскольку мне нужно создать hashmap
заголовка и значения, даже если оно пустое.
Iterator<Row> rowIterator = sheet.iterator();
while (rowIterator.hasNext()) {
Row row = rowIterator.next();
//For each row, iterate through all the columns
Iterator<Cell> cellIterator = row.cellIterator();
while (cellIterator.hasNext())
{
Cell cell = cellIterator.next();
//Check the cell type and format accordingly
//System.out.println(cell.getCellType());
if(cell.getCellType() == Cell.CELL_TYPE_NUMERIC)
{
System.out.print(cell.getNumericCellValue() + ";");
}
if(cell.getCellType() == Cell.CELL_TYPE_STRING)
{
System.out.print(cell.getStringCellValue() + ";");
}
if(cell.getCellType() == Cell.CELL_TYPE_BLANK)
{
System.out.print("Blank");
}
}
System.out.println("");
}
file.close();
attr_item_code;tag_warranty;MASTER;1032839;MASTER
Я хочу создать hashmap
, как показано ниже для вышеуказанных данных
{
"attr_item_code":"1032839",
"tag_warranty":"",
"MASTER":"MASTER"
}