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

坚强是说给别人听的谎言 提交于 2020-08-25 06:49:48

问题


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

I have a excel sheet as follows:

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:

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:

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?


回答1:


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




回答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:

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

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:

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.



来源:https://stackoverflow.com/questions/54708675/how-to-read-an-excel-sheet-and-put-the-cell-value-within-different-text-fields-t

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!