Free Support Forum - aspose.com

Aspose Cells Workbook Excel

Hi

I want a logic to check whether any data is present in the Worksheet or not and activate accordingly.

For Example :

I have some data in Sheet-1 and Sheet-2,but not in Sheet-3.

Then i require a logic to find whether data present in the sheet or not and if present then show there tabs accordingly.

So above,Sheet-1 and Sheet-2 ahould be shown in My Excel.But not Sheet-3.

Can you please help me in this.

Hi,

Thanks for your question and interest in Aspose.Cells.

If Worksheet.Cells.Count > 0 then it means, there is some data inside a worksheet and worksheet is not empty.

Please see the code below.

C#


string path = @“F:\Shak-Data-RW\Downloads\Files\source.xlsx”;

Workbook workbook = new Workbook(path);

Worksheet worksheet = workbook.Worksheets[0];

//Check if this worksheet is empty
if (worksheet.Cells.Count > 0)
{
Debug.WriteLine(“This worksheet is not empty.”);
}
else
{
Debug.WriteLine(“This worksheet is empty.”);
}