Skip to main content

Posts

Showing posts from August, 2019

Some Common LinQ used in Excel Automation

LinQ used on DataTable to Filter One Column and Copy the Data into DataTable : dataTable.Select.where(Function(x) (x.Item("Column1").ToString.ToLower.Contains("Value"))).copyToDatatable. LinQ used on DataTable to Filter More than one Column and Copy the Data into DataTable: dataTable.Select.where(Function(x)(x.Item("Column1").ToString.ToLower.Contains("Value1") Or x.Item("Column2").ToString.ToLower.Contains("Value2"))).copyToDatatable. LinQ used on DataTable to one Column and Copy the Data into List of DataRows: dataTable.Select.Where(Function(x) (x.Item("Column1").ToString.ToLower.Contains("Value"))).ToList() LinQ used on DataTable to one Column and Copy the Data into List/DataTable: dataTable.Select("[Column]='Value'") LinQ used on DataTable to one Column and check whether value present in that Column or not: dataTable.AsEnumerable().Any(Function(x) x("Column...

Understand the LinQ Syntax in Automation

LINQ means Language Integrated Query. Import the System.Linq namespace and it provides many extension methods. LINQ enables you to query data from a SQL Server database, XML, in-memory arrays and collections, ADO.NET datasets, or any other remote or local data source that supports LINQ. We are going to understand the basic Syntax of LINQ query to Filter One Column of Excel. For Example:  We have an Excel Sheet, which we already read by using activity ' Read Range in UiPath ' then all the data come into DataTable  ( Display Info in Tabular form Or Combination of Rows and Columns) DataTable.Select.Where(Function(x) x.Item("ColumnName").ToString.Trim.ToLower.Equals("y")) Now, Let's understand this LinQ query step by step: DataTable: The Excel you read comes into DataTable variable. Select: It Defines the results to return from the Query. Where: Specifies the Filtering Condition for the Query. Function(x): An anonymous (unnamed) ...