2

How to read an excel sheet and put the cell value within different text fields through UiPath?

I have a excel sheet as follows:

SAP_excel

I have read the excel contents and to iterate over the contents later I have stored the contents in a Output Data Table as follows:

  • Read Range - Output:

    • DataTable: CVdatatable
  • Output Data Table

    • DataTable: CVdatatable
    • Text: opCVdatatable

Screenshot:

SAP_OutputDataTable

Finally, I want to read the text opCVdatatable in a iteration and write them into text fields. So in the desired Input fileds I mentioned opCVdatatable or opCVdatatable+ "[k(enter)]" as required.

Screenshot:

SAP_iterate_OutputDataTable

But UiPath seems to start from the begining of the Output Data Table whenever I called for opCVdatatable.

Inshort, each desired Input fileds are iteratively getting filled up by all the data with the data stored in the Output Data Table.

Can someone help me out please?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    Just to be sure I understand - you want the first field to contain XK01 (the transaction, row 1), the second one 1000 (row 2), the third one 1000 (row 3), and so on - is that correct? – Wolfgang Radl Feb 15 '19 at 19:08
  • @WolfgangRadl Yes, you got it right. However there is a small progress and I will update the question with it. – undetected Selenium Feb 15 '19 at 19:24

2 Answers2

2

My first recommendation is to use Workbook: Read range activity to read data from Excel because it is quicker, works in the background, and does not require excel to be installed on the system.

Start your sequence like this (note the add headers property is not checked):

You do not need to use Output Data Table because this activity outputs a string containing all row items. What you want to do instead is to access the items in the data table and output each one as a string in your type into, e.g., CVDatatable.Rows(0).Item(0).ToString, like so:

You mention you want to read the text opCVdatatable in an iteration and write them into text fields. This is a little bit more complex, but i'll give you an example. You can use a For Each Row activity and loop through each row in CVDatatable, setting the index property if required. See below:

The challenge is to get the selector correct here and make it dynamic, so that it targets a different text field per iteration. The selector for the type into activity will depend on the system you are targeting, but here is an example:

And the selector for this:

Also, here is a working XAML file for you to test.

Hope this helps.

Chris

Cristophs0n
  • 1,246
  • 3
  • 19
  • 27
2

Here's a different, more general approach. Instead of including the target in the process itself, the Excel would be modified to include parts of a selector:

enter image description here

Note that column B now contains an identifier, and this ID depends on the application you will be working with. For example, here's my sample app looks like. As you can see, the first text box has an id of 585, the second one is 586, and so on (note that you can work with any kind of identifier including the control's name if exposed to UiPath):

uiexplorer

Now, instead of adding multiple Type Into elements to your workflow, you would add just a single one, loop over each of the datatable's row, and then create a dynamic selector:

workflow

In my case the selector for the Type Into activity looks as follows:

"<wnd cls='#32770' title='General' /><wnd ctrlid='" + row(1).ToString() + "' />"

This will allow you to maintain the process from the Excel sheet alone - if there's a new field that needs to be mapped, just add it to your sheet. No changes to the Workflow are required.

Wolfgang Radl
  • 2,319
  • 2
  • 17
  • 22
  • Just to ensure that I understood your concept and solution, as you mentioned _...note that you can work with any kind of identifier including the control's name if exposed to UiPath..._ as per the demo [snapshot](https://i.stack.imgur.com/Ckdb0.png) which you have provided, the element clearly had the **ctrlid** exposed which doesn't seems to be available to me for the SAP UI [_TCODE_ field](https://i.stack.imgur.com/LirXv.png) with which I am currently working. Am I right? – undetected Selenium Feb 18 '19 at 11:57
  • Additionally, can you please guide me if I can generate a static **ctrlid** and creating a selector I would be able to attach it to a particular control so the `Type Into` activity becomes similar to `""` which you have provided? – undetected Selenium Feb 18 '19 at 12:32
  • The final counter question is, if **ctrlid** is **`585`** in `B1` cell how does it references the value in `A1` cell which holds the string **XK01**? – undetected Selenium Feb 18 '19 at 18:40
  • Seems like the `ctrlid` isn't exposed for said fields, but another property is: `tbar[0]/okcd`. I can only assume this attribute is different for each individual text box, e.g. `tbar[1]/okcd` for the next one. So, your column B would hold this value. Then, your selector may look like this: `"`. The value itself is then used in the `Text` property of the `Type Into` activity: `row(0).ToString()`. – Wolfgang Radl Feb 18 '19 at 19:06
  • Can you point me to some documentation on **ctrlid** please about _how they are generated_, _expiry_ along with _ctrlid of child locators_, _timeStamp_ and _fingerprint_ attributes? – undetected Selenium Feb 20 '19 at 11:47