Can we manually assign the row count index?

Hi all, currently I am trying to make it so that if dt_Output is empty, then rowCount will be set to 0. However, currently it is running towards Else although my datatable is empty. What could be reason for this?
image

Could you share the previous contents of the xaml

@SRoyi

is there any headers in the excel??

If yes, then please check whether you have checked the has headers option is true for read range activity.

Regards

I didn’t select Add Headers so I will give it a try
Thanks

Hi due to confidentiality I cannot share the excel but I am having it read from D29


Thanks

@SRoyi

have you tried by keeping the add headers true

Regards

I just tried it and it doesnt work

@SRoyi

Try printing the dt_Output.RowCount in a message box and check the value

Regards

@SRoyi ,

Can you debug and check if the dt_Output data table is passed correctly, i guess the issue lies there

Also you can try below expression though its same as yours
dt_Output.RowCount.Equals(0)

@SRoyi

have you tried printing the data in message box

Regards

Hi there,
yes I have done that, and it turns out even empty rows are counted as a row. So what I did was implement a function that removes all empty rows.


The above is an assigned activity that is assigned to a data table variable dt_FilteredData
What I am trying to achieve is, should dt_FilteredData.RowCount = 0, then it will +2. However, it is failing at the activity in the above image, with the error message being data table is empty.
Regards,

@SRoyi

When the cells are formatted and you use a read range even empty cells are read as rows…

So before foing rowcount it is necessary to filter or remove the empty rows using a condition and then perform the row count

In the expression you gave instead of .CopyToDataTable use .Count=0 that will ensure the row count is 0 when all rows are empty …you cannot copy no rows to a datatable and that is the error

Cheers

Use filter datatable activity and provide remove empty datarow and save it in same datatable. then try to get the count. it will show 0.

Hope it helps.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.