Read row by row and column by column in excel

excel
activities

#1

Hi there,

how its possible to read a extrem long excel List row by row and column by columns until an empty field comes ?
Read Row1 in Excel the first Cell and INPUT in a Homepage. Than read the second Cell in Row 1 (Column 2) and Input this in a Homepage.

Then Jump in Row 2 in excel read the first Cell and Input in the Homepage. Then read the second Cell in Row 2 (Column2) and Input

As long as an empty field comes

Big Thanks

Erwerf


#2

Hello @Hovarda52, use “Read range” activity to read such list. Provide empty string in “Range” property as you might not know the exact range of the list. This activity would give you the data in form of a datatable which you can traverse using For Each row activity.

Please refer the link: https://www.uipath.com/activities-guide/excel.read-range

Let me know if this helps!


#3

Hello @Prakshi_Tyagi it works thank you very much.
But how I can read now cell by cell and row by row until the list is end ?

Copy a Cell in a other document then jump in the next column and copy this in a other dcument.
Then jump in a new Row and so on…

Thank you


#4

This can help

foreach (Row in dtOutput.Rows)// For each row
{
    foreach(Col in dtOutput.Columns)// For each column of a row
     {
            If( Row(col) = "Emp_Name")
            {
                // activity
             }
      }
}

#5

Hello, this might help you.

regards,


#6

One could use .TakeWhile here as well, if you want to iterate until a condition is met:

// Take rows until nested function returns false, in this example if first cell value = END it will break out of the loop
foreach (Row in dtOutput.AsEnumerable.TakeWhile(Function(x) x(0).ToString <> "END"))
{
   // your processing here
}

Tha way you avoid additional nesting which can make the workflow much less readable and you don’t need an exit condition inside the loop.
It depends on what you’re used to, but I find it much more readable. Same goes with .SkipWhile if you need to skip until some value is found (a date later than today for example).


#7

Touché


#8

please kindly provide solutions


#9

Hi
I tried reading rows thru first while loop and columns thru 2nd while loop, so that could print cell contents. But its not working. Attaching script. As, I’m new user, unable to attach my script here. Could some one please help me on this. Thanks

<?xml version="1.0" encoding="utf-16"?>TrueTrue[totalRows][dtbSampleDataTable.Rows.Count][intCurrentRow]0True[intTotalColumns][dtbSampleDataTable.Rows(intCurrentRow).ItemArray.Length]TrueTrue[intCurrentColumn < intTotalColumns]True[intCurrentColumn][intCurrentColumn + 1]True[intCurrentRow][intCurrentRow+1]

#10

I’m using Community version which is not showing code. How to proceed. Thanks


#11

HI,
I Want to select rows (based on my need) from excel sheet.
For example, first time I need first 10 rows and for the next time i just need 15 rows.
Could anyone tell suggestion for this.


#12

Hi, Did you get solution for this?


#13

did u get solution too ?


#14

#15

Hi,

Use the DataTable variable that you got from “Read Range” activity. And pass it in “For Each Row” activity as input. Then, it’ll take care of your need.

Example:(From your sample data)

First row comes as Datarow like user1 pswd1 under their respective columns. All you need to do for your scenario is pass the current variables to your respective text boxes (Webpage login)


#16

Hi,

Thanks, it works.

Regards