Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enumerate excel worksheets in NPOI

Tags:

c#

excel

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..
        }
like image 636
Solo Avatar asked Nov 24 '25 20:11

Solo


1 Answers

There's a NumberOfSheets property that you can use.

like image 63
Daniel A. White Avatar answered Nov 27 '25 11:11

Daniel A. White



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!