Hello,
I’d like to find a way to determine whether a workbook is completely empty (of values). I considered using the SaveToCSV method to examine the output file, but I wanted to toss the question to you all to see if you had another suggestion.
Thanks,
Mike
Hi Mike,
I am afraid there is no specific API to directly check whether a workbook is empty or not.
Thank you.
Hi,
I think you may easily check each worksheet to get whether the workbook is empty or not. See following sample code:
for (int i = 0; i < workbook.Worksheets.Count; i++)
{
Cells cells = workbook.Worksheets[i].Cells;
if (cells.Count != 0)
{
//this workbook is not empty.
break;
}
}
Hopefully this sample code helps you to achieve your desired task.
Thank you.
Thank you, Amjad.
I also thought of using the Save method to save it to memory stream as CSV. If the MemoryStream has a zero length, the file has no content.
Mike