Solo
Solo

Reputation: 4126

How to enumerate excel worksheets in NPOI

How can I enumerate all the excel sheets name using NPOI? As a quick workaround, I'm using the following. But I feel super guilty for doing it...

        try
        {

            IWorkbook Iwb;
            Iwb = new XSSFWorkbook(filepath);

            int i = 0;
            while (i < 100)
            {
                MessageBox.Show(Iwb.GetSheetAt(i).SheetName);
                i++;
            }

        }
        catch (Exception ex)
        {//Do Nothing..
        }

Upvotes: 3

Views: 5127

Answers (1)

Daniel A. White
Daniel A. White

Reputation: 190897

There's a NumberOfSheets property that you can use.

Upvotes: 5

Related Questions