Count of a column in excel

Hi team,

I would like to store the count of a column in excel in a variable and I would like to store the count of column B (105) in a variable.

Hi @Matthew2

Please use the below LINQ function to get particular Column count.


DtTable.Rows.Cast(Of DataRow)().Where(Function(row) Not row.Item("ColName") IsNot DBNull.Value Or row.Item("ColName").ToString() <> "").Count






regards
1 Like

Hi @Matthew2

What I have understood is you want the rows count of column B from your datatable if it so.
TestDt is the datatable name(output of the read range activity)
TestDt.AsEnumerable().Select(Function(x) (x(“YourColumnName”)).ToString).ToArray().Count

1 Like

Hi @Matthew2 ,

Use below expression to get column count from datatable

TotalCols=TestDT.Columns.Count

1 Like

@Matthew2

Hello!

If you want to get a particular column data count use Read Column activity which will return the output in Ienumerable(Object). Later you can use the variable (Ex : OutCountcolumn.count).

Same way, if you want entire the datatable column count you can use (Yourdatatable.columns.count)

Thanks!!!

1 Like

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