How to get correct Excel Columns count

Hi all,
@Palaniyappan
when i am trying to get the columns count dt.Columns.Count.ToString its giving count 16384
but i have a data in 42 columns , i think it including empty columns as well.

Can any one help how to get actual columns count with data.

Best Regards,
Naveen

1 Like

Hi
This looks strange
Fine may I know what is the range mentioned in the read range activity
Kindly restart both the excel and uipath studio application once and try again pls

This expression you have used should work for sure

Cheers @Naveen.Ch

2 Likes

Read range i am reading whole excel sheet “” passed

fine let’s validate like this
Go to excel keep the cursor in first cell A1 and press ctrl+A if only the columns with data gets selected then we are good
Or if the whole excel gets selected then we need to check with excel that it has occupied all columns in excel
Cheers @Naveen.Ch

This happens when there is border around empty cells. If you remove border around empty cells, the expression you mentioned works fine.

1 Like

Hi @divyagupt,

Thanks for the response
Actually excel doesn’t have any boarders

Hi @Naveen.Ch
can you please share your excel file…
and remove the data and then fill some dummy data instead of original data…

ThankQ

1 Like

Hi @kumarD
Thanks for response.
when i am doing manually Ctrl+a it is selecting whole sheet but i need to seect columns which has data.

Hi @Naveen.Ch
This expression is working fine for me if I have no borders around empty cells. The empty cells are being stored in DataTable as Column1, Column2 , and so on.
So you can create and use a flowchart similar to the following to count non-empty columns
image

1 Like

Can you please send me the workflow if it is possible

Sure Naveen, please find the workflow attached.
test2.xaml (15.9 KB)

1 Like

Hi @divyagupt,

Yes now i am getting the count but when i am trying to add or removing the columns from data table its not updating the column count accordingly .

and one more thing when i am trying to print in msg box using output data table nothing is coming.

Hello @Naveen.Ch
This is because the DataTable still contains empty columns. Try filtering DataTable by removing the columns that have ‘Column*’ in their headers/column name. And then doing other operations.

1 Like

Hi,
Thanks for your query, I suggest you to use ZetExcel tools for easy solutions. Just try it and get the result. Thanks