Hi I have an excel and I want to get rows count for column can you please help on this??
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.
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
Just one question it is not counting blank rows in between records
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
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.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.