CRUD -> Read excel content then print out
Code Source:
XSSFSheet sheet = workbook.getSheet("Sheet1");
Row currentRow = sheet.getRow(i);
Cell currentCell = currentRow.getCell(j);
currentCell.getStringCellValue();
@Then("^I print the data inside the workbook$")
public void i_print_the_data_inside_the_workbook() throws Throwable {
System.out.println("Printing Excel Workbook data from Sheet1 after adding data.......");
try
{
XSSFSheet sheet = workbook.getSheet("Sheet1");
for(int i=0;i<sheet.getPhysicalNumberOfRows();i++)
{
Row currentRow = sheet.getRow(i);
for(int j=0;j<currentRow.getPhysicalNumberOfCells();j++)
{
Cell currentCell = currentRow.getCell(j);
System.out.print(currentCell.getStringCellValue() + "\t");
}
System.out.println("\n");
}
}
catch (Exception e)
{
e.printStackTrace();
}
}

浙公网安备 33010602011771号