from the given .xlsx file, I am trying to read data using Java programming
My code for read the file is as given below:
public static void main(String[] args) throws Exception {
FileInputStream file = new FileInputStream(new File("E:\test1.xlsx"));
XSSFWorkbook workbook = new XSSFWorkbook(file);
XSSFSheet test = workbook.getSheetAt(0);
student emp = new student();
Iterator<Row> itr = test.iterator();
itr.next();
while(itr.hasNext()){
Row row = itr.next();
emp.reedData(row);
System.out.println(id+","+name+","+options);
}
method is as given below:
void reedData(Row row){
id= row.getCell(0).toString();
name= row.getCell(1).toString();
options= row.getCell(2).toString();
}
But, I am getting output like this:
1.0,X,play game
,,sing song
2.0,Y,play game
,,sing song
Instead of this, I want output like this:
1.0,X,play game
1.0,X,sing song
2.0,Y,play game
2.0,Y,sing song
This problem is because I am combining two cells in .xlsx file.
Any suggestion? Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire