How to find workbook is having particular name worksheet using aspose.cells?

how to find workbook is having particular name worksheet using aspose.cells?

Hi,


You may try to use Worksheet.Name property to find out a particular worksheet in the workbook, e.g
See the following sample code:

Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(“e:\test\Book1.xls”);

foreach (Worksheet worksheet in workbook.Worksheets)
{
if (worksheet.Name == “Sheet1”)
{
//Your code goes here.
}
}

Hi,

Please use the following code to find, if the particular sheet exists inside your workbook.

Please download and use the latest version:
Aspose.Cells
for .NET v7.0.4.6



C#


Workbook workbook = new Workbook(“c:\source.xlsx”);

string sheetName = “MySheet”;

Worksheet worksheet = workbook.Worksheets[sheetName];

if (worksheet == null)
{
//sheet does not exist
}
else
{
//sheet exists
}

1 Like