I am trying to read excel in java.I have following code.
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.
Use this : Input String filePath Output is list of list of json objects
Have these dependencies
org.apache.poi
poi-ooxml
3.9
org.apache.commons
commons-collections4
4.0
/**
* Function reads the input excel and gives list(sheet) of objects(rows of each sheet)
* @param filePath
* @return list of list of json objects
*/
public static List excelFileReader(String filePath){
ListtotalSheetList=new ArrayList<>();
XSSFWorkbook workbook= null;
try {
workbook = new XSSFWorkbook(filePath);
} catch (IOException e) {
e.printStackTrace();
}
//iteration for sheets in a workbook
for(int sheetIndex=0;sheetIndex singleSheetList=new ArrayList<>();
//excel header - first row and non-empty
String[] header=new String[sheet.getRow(0).getPhysicalNumberOfCells()];
if (sheet.getPhysicalNumberOfRows()!=0 && sheet.getRow(0).getRowNum()==0) {
row=sheet.getRow(0);
for(int index=0;index eachRow=new HashMap<>();
for(int colIndex=0;colIndex