News Category

Get Worksheet Names in Java

2020-06-12 08:44:27 Written by  support iceblue
Rate this item
(0 votes)

This article demonstrates how to get names of worksheets in a workbook using Spire.XLS for Java.

import com.spire.xls.Workbook;
import com.spire.xls.Worksheet;

public class GetWorksheetName {
    public static void main(String[] args) {

        //Create a Workbook object
        Workbook wb = new Workbook();

        //Load a sample Excel file
        wb.loadFromFile("C:\\Users\\Administrator\\Desktop\\sample.xlsx");

        //Loop through the worksheets 
        for (Object sheet: wb.getWorksheets()
             ) {

            //Get worksheet name
            String sheetName = ((Worksheet) sheet).getName();
            System.out.println(sheetName);
        }
    }
}

Get Worksheet Names in Java

Additional Info

  • tutorial_title:
Last modified on Wednesday, 01 September 2021 02:29