How to loop through columns in an excel row

Hey Guys,

I am new to UI Path and would like to know how to achieve the following requirement.

  1. Loop through all the columns in a an excel row.
    I have to loop through all the columns in a row and read page count and split PDF
    My data is like the following:
    Ticket no A B C
    1234 1-4 5-6 8-19

@pooja.pakanati

Welcome to forums

For looping through excel columns

Use Read Range activity->output vairable datatable

You can use For Each activity and write as Datatable.Columns
Inside Foreach you can place message box / write line, so that you can get the output as the column name

and what do you mean by page count and split PDF ?

give me details on that

Thanks

Table1.xlsx (8.9 KB)
Thank u for the reply. As you can see in the attached Excel sheet, I will have a PDF document for each ticket number mentioned in the Excel Sheet. I will have to loop through all the rows and read page count from each column and split the PDF.
But i am not able to read the page ranges from the excel(as they are columns and not rows).


I followed as per your instructions but i can read is the first row.

OUTPUT.

TicketNumber
Doc_Type_2
Doc_Type_3
Doc_Type_4
Doc_Type_5

@pooja.pakanati

Are the columns are fixed?

Then use For Each row activity and give the split range as below
row(“Doc_Type_2”).ToString etc.,

You can call the range directly

Hope this may help you

Thanks

Yes the columns are fixed.


I am able to split as per the page range in columns. But I have to use Extract PDF Page Range activity for each column. Is there a way i could use one and loop all the values?

@pooja.pakanati

Check is your columns have the duplicate or it’s by mistake?

because the column name Doc_Type_3 is duplicating

Also you can keep a For Each activity inside the For Each row activity, as below

and in range write as row(item.ToString)

Hope this may help you

Thanks

Hi,

That was by mistake. Columns are unique here. I tried the following logic:

  1. Put all the page ranges in a list and tried to loop through them.
    PageCountList =New List(of string) from {pageRange1, pageRange2,pageRange3,pageRange4}

But the issue i face here is… when any column has null value, the values are getting mixed up…
How could I check if column name is “XXX”, and the value of that column is not empty, then split PDF and name the PDF as “TicketNumber_XXX.pdf”.
Please help!

@pooja.pakanati

You can use if condition for that

item.toString <> " " and Item.ToString = “XXX”

Hope this may help you

Thanks

Thank you for your help! I tried this way and it helped! :slight_smile:

@pooja.pakanati

I suggest to click mark as solution to close this thread and if you feel you are struck some where then suggest to start a new thread instead of continuing the old thread

Happy Automation

Thanks

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.