I am new for Apache Poi. I have to read the excel with multi columns. i did something but i got unexpected result. please find the sample input and code with output.
I have to read particular column and get that column values was presented in excel.
Sample Input :
Code :
FileInputStream file = new FileInputStream(new File(path));
//Create Workbook instance holding reference to .xlsx file
XSSFWorkbook workbook = new XSSFWorkbook(file);
//Get first/desired sheet from the workbook
XSSFSheet sheet = workbook.getSheetAt(0);
DataFormatter dataFormatter = new DataFormatter();
for(Row row : sheet){
Cell cell = row.getCell(6);
String s = dataFormatter.formatCellValue(cell);
System.out.println(s + "\n");
}
Output :
Product ID
835,885
891,875,895,897,888
924,894
897,895,898,869
897,899,893,888,890
897,891
897,869
.......
967,617,691,688,976,1,366,128,136
But, i want below output,
8,35,885
89,18,75,89,58,97,888
9,24,894
8,97,89,58,98,869
89,78,99,89,38,88,890
8,97,891
8,97,869
......
967,617,691,688,976,1,366,128,136
I am googled the solution but i can't able to find out. And also i tried (POI, JEXCEL, Aspose) some logic but it was give different output. So, please help me to solve the problem.