How to get rows count from column

Hi I have an excel and I want to get rows count for column can you please help on this??

1 Like

Hi @Addy_619
Can you share what’s de input, and what would be the output desired?

simple just want row count of column. ex. how many records present in column B in excel like that.

Hi @Addy_619
You can try this way

dt1.AsEnumerable().Select(Function(r) r(columnname).ToString).ToArray().Where(Function(r1) r1<>“”).Count

columnname should be put in quotes for eg, if the column name is Data u had to write code like

dt1.AsEnumerable().Select(Function(r) r(“Data”).ToString).Where(Function(r1) r1<>“”).Count

2 Likes

ColumnRowsCount.xaml (5.3 KB)
sample.xlsx (8.3 KB)

Take a look at this WF, and let me know.

1 Like

Just one question it is not counting blank rows in between records

Hi

Hope these steps would help you resolve this

—use a excel application scope and pass the file path as input and get the output as dt

—now create a variable in variable panel named Finaldt of type System.Data.Datatable with default value as New System.Data.Datatable

—then use a assign activity like this

Finaldt = dt.DefaultView.ToTable(False,”yourcolumnname”).CopyToDatatable()

Here Finaldt is our new dt with just the column B

—now use a Assign activity like this

Int_rowcount = Finaldt.Rows.Count

Int_rowcount is the row count of column B

Cheers @Addy_619

2 Likes

@Addy_619
You can modify the highlighted code as you need

If you leave it like this: Where item(“ColumnB”) IsNot Nothing
it will count all the rows, no matter what the content of the cell is.

1 Like

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