[英]Find last row no in excel in a particular columnno using Apache poi
Try below code to identify last row from excelsheet. 尝试下面的代码,以识别excelsheet中的最后一行。 Below code automatically iterate through all rows and identify last row from all columns.
下面的代码自动遍历所有行,并标识所有列的最后一行。
public static void main(String[] args) throws IOException {
// Making of excel file object
File myFile = new File(CommonMethods.getFilePath("testdata", "Sample.xlsx"));
FileInputStream fis = new FileInputStream(myFile);
XSSFWorkbook myWorkBook = new XSSFWorkbook(fis);
XSSFSheet mySheet = myWorkBook.getSheet("Logout");
XSSFRow row = null;
// Making the object of excel row
row = mySheet.getRow(0);
int colCount = row.getLastCellNum();
System.out.println("Column Count :- " + colCount);
int rowCount = mySheet.getLastRowNum() + 1;
System.out.println("Row Count :- " + rowCount);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.