Skip to main content

Posts

Showing posts with the label LinQ

Excel Automation Using UiPath

You can do Excel Automation in UiPath in four different ways: Using UiPath Activities. Using LinQ. Using Macros (VBA). Using Excel as a Database. Lets go with one by one : Using UiPath Activities Excel Application Scope: In this You can use Read Range Activity to read all the data into the DataTable. You can use the Read Cell Activity to read the data one by one into the Generic Format. You can use Loops on your DataTable. You can Filter DataTable Activity to filter out your data. Workbook: Even if excel is not installed in your system, then also you can use these activities to read or write excel. Using  LINQ You can use LinQ queries to Filter out the data directly on DataTable or List. In this case you cannot use Read Cell Activity. Read More About LinQ from here: Click here LinQ Syntax . LinQ Queries Used for Filter Out the Data . Using Macros (VBA) You can use macros also, not for Excel but you can do any type of work from Macros. VBA code is easy like a E...

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) ...