要獲取workbook中sheet的個數,可以使用Workbook類中的getNumberOfSheets()方法。示例如下:
Workbook workbook = new XSSFWorkbook(new FileInputStream("workbook.xlsx"));
int numberOfSheets = workbook.getNumberOfSheets();
System.out.println("Number of sheets in the workbook: " + numberOfSheets);
以上代碼會打印出workbook中sheet的個數。