This means that there is no data in the table or it has not been initialized before writing into the excel. Do make sure that you have data in datatable
Error: Object reference not set to an instance of an object. This error usually occurs when using a variable with no set value (not initialized)
In my case, when there is no data in the datatable then it should return back successfully. But still it is throwing the error while returning back. How to solve this?
Write a check if DataTable.Rows.Count>0 then only it should proceed