Excel Automation Using VB.NET In UiPath

Introduction 

 
VB.NET, also know as Visual Basics.NET, is an object-oriented programming language and supports multiple features, such as polymorphism, encapsulation, and many others.
 
UiPath, being a low-code platform, provides an easier method to write custom code or logic and use it while building workflows using Invoke Code Activity. 
 
In this article, we are going to see the following things:
  • How to use the VB.NET code in UiPath?
  • What is Invoke Code Activity in UiPath? 
  • Adding columns using VB.NET
  • Performing arithmetic calculations using VB.NET
So, let's begin!
 
Step 1 - Creating a process
 
While creating the process, make sure you select the language VB.
 
Excel Automation using Vb.NET In UiPath
 
Step 2 - Understanding Input Excel File
 
This is how our input file looks: we have three columns... Product, Price, and Discount. After processing this output file, we will have two more columns, Discounted Amount and Final Price. 
 
Excel Automation using Vb.NET In UiPath
 
Step 3 - Reading an Excel File In UiPath
 
In this step, we are using a read range activity to read the data from an Excel file. The output is stored in the variable InputDT of data type DataTable.
 
Excel Automation using Vb.NET In UiPath
 
Step 4 - Creating arguments in Invoke Code Activity
 
Now, we have to create two arguments in Invoke Code activity DT1 -> store the InputDT and DT2 -> stores the OutputDT 
 
Excel Automation using Vb.NET In UiPath
 
Step 5 - Writing code in Invoke Code Activity 
 
In this step, we will write the VB.NET code to process the DT1 input, add columns, and perform arithmetic calculations.
 
Line 2 & 3 -> Used to add columns in our input data table DT1.
 
Line 4 to 7 -> Processing each row of the input data table and performing arithmetic calculations as required.
 
Line 8 -> Assigning the processed data table value to output data table DT2.
 
Excel Automation using Vb.NET In UiPath
 
Step 6 - Writing data to output Excel file
 
In this step, we will write the output data table to our excel file using Write Range Activity.
 
Excel Automation using Vb.NET In UiPath
 
Step 7 - Final output file
 
Our final output file looks like this:
 
Excel Automation using Vb.NET In UiPath
 
Hurray! With 7 simple and quick steps, we have successfully completed our workflow and understood how can we use custom VB.NET code to build logic in UiPath and perform Excel Automation.
 
Thank you for reading the complete article. Please comment with your suggestions or the topics you would like me to write articles about.


Similar Articles