温馨提示×

Java中workbook怎么获取sheet个数

小亿
597
2024-03-11 15:06:19
栏目: 编程语言

要获取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的个数。

1