Figured it out :thumbsup:
private bool IsWorkbookEmpty(Workbook excelBook)
{
try
{
if (excelBook.Sheets.Count <= 0)
{
return true;
}
else
{
foreach (Worksheet sheet in excelBook.Sheets)
{
Range excelRange = sheet.UsedRange;
int test1 = excelRange.Columns.Count;
int test2 = excelRange.Rows.Count;
int test3 = excelRange.Count;
if (test1 > 1 || test2 > 1 || test3 > 1)
{
return false;
}
else //look for content..
{
foreach(Range cell in excelRange)
{
if (cell.Value2 != null)
{
string cellValue = cell.Value2.ToString();
if (cellValue.Trim().Length > 0)
return false;
}
}
}
}
}
}
catch (Exception)
{
return false;
}
retur