Count of rows giving null exception

Hii… I want to count rows of excel which contains somtimes only header and sometimes has data … i need to write if condition where i want to count rows if row contains 0 it will stop process but i have getting error as null exception… please attached screenshot…

if row contains 0 in the sense like is that a value ? or how is it like?

i want the count of record present in my excel file. But sometimes i may not have data in my excel file only header will be there. So while counting i m getting error as “Null Exception” in my assign activity.

1 Like

in if condition write - datatable.rows.count > 0

then execute true condition will have (data with header)
else (only header)

it’s working fine for me use Excel Application Scope


You can place the activities in Try catch, In catch you select “System.NullReferenceExeception” and define the steps in catch.

check below



You can use Read Range activity from the workbook, so you get count as 0

Hope this helps


Hi @Gauri_Rawool,

Please use Read Range activity (Excel Activities) inside the Excel Application Scope. Now set the Add Headers option in Read Range activity as Checked as I can see that this option is Unchecked in the shared screenshot.

Now use the below syntax in If condition -


Now you can proceed with your further activities.

Thanks & Regards,