How to Compare Two Excel Sheet Using C# code in BluePrism

vishnu

New Member
Hi
Can any one tell how to compare two excel sheets using C# code what are the 'namespace imports' i have to add in code options in Blueprism
 
Hi, this is how i do it:
First you read the excels you want to compare, and each of them pass it to a collection using the "get Worksheet as collection" from the Excel VBO. After that you create a code stage, using the "code" connector, i see this codes stage as methods if someone ask me to compare them to a normal coding language like Java. The inputs in the code stage are the parameters in the method and the outputs are the returns. Now, in the code stage with C# the collections are managed like DataTable, if you need more information of all the things you can do with DataTables, look for the documentation in C#.

Code:
CollectionOut = new DataTable(); //Your return collection
CollectionOut.Columns.Add("user"); //create columns to the return collection
CollectionOut.Columns.Add("email");
for (int i = 0; i < CollectionIn.Rows.Count; i++)
{
    string value1 = CollectionIn.Rows[i].ItemArray[0].ToString().ToLower(); //First collection in the code stage input
    for (int i2 = 0; i2 < CollectionIn2.Rows.Count; i2++)
    {
        string value2 = CollectionIn2.Rows[i2].ItemArray[0].ToString().ToLower(); //second collection in the code stage input
        if (value1 == value2)
        {
            //What you want to do when you find an element of file 1 in file 2
        }
    }
    CollectionOut.Rows.Add(value1,value2); //This is how you add to your return collection
   
}
//At the end you dont need to write return CollectionOut or anything, you just capture
//the value of CollectionOut by creating a collection element in Blue Prism with the same name
//as the output in the code stage you specify.

Now in the Initialise Page of your Object, double click in the big box with the name of the object, go to code options tab, here if you need to use some namespace or something in your code stage is where you "import" it, and in the bottom you select the language which in this case should be c#.

Hope this helps.
Andres.
 
Top