Main.xaml (10.9 KB)
Tst.xlsx (23.1 KB)
I have been trying to read this excel file and select certain rows/cells based on condition in column A. In this case, if the value in column A (Apple A) is Z67, get all the values in column C (Citrus) and write them into text file. So I should get CA, CB, CC, CD back.
At this point, I am just trying to get all the records that belongs to Z67. However, I get the error saying the object reference not set blahblah with the workflow that I have in the xaml.
Also, is there a way to select only column A and column C even before I start to create the dataTable? Using if else condition? I think it would be faster and more efficient because I don’t need all other information in that excel - only column A and column C.
I am aware of this site - https://www.uipath.com/kb-articles/how-to-filter-a-data-table
In terms of the forloops as indicated on the website above, why do we need 2 forloops? and what should the TypeArgument be for the second for loop?
Please see attachments and check my xaml. Thanks in advance
I have changed a little bit in the code and I have attached the xml here.
File : object reference not set to an instance of an object.zip (17.9 KB)
The xl source is having the 9 columns. That is the reason you are getting the null error.
Thank you so much for your rapid reply. The solution that you provided works well! And my next question is how to print all the result in one setting, i.e., [CA,CB,CC,CD] in a text file in separate lines.
Currently when I write text file, it only shows CD because it is overwriting the text file every time it goes through the for loop. I am thinking to assign a list string above the for loop, then add row into the list for each row. but how can I achieve this? Thanks!
p.s. I removed the forloop, and tried to use output datatable and show the result in the message box but all data are shown instead of just [CA,CB,CC,CD]…
And I tried to put invoke method inside the forloop to add on the empty list variable that I created, but I got "Ststem.Collections.Generic.List’1[System.String] as the result for my message box… Please see attachment
Main.xaml (12.8 KB)
Here i have attached the xml for your situation.
File : StringJoin.zip (11.9 KB)
Works perfectly! Learning from your code. Thanks a lot!