Paste multiple saved values in descendet rows

Hey everybody,

I was looking for some help in here. I’m trying to complete my automation but I’m stuck at this point.

I need to figure out the following: my bot needs to read one line within all the PDF files located in a directory (the number of PDF files will be variable every time). Subsequently, all the values extracted from those PDF files must be written in one column of an excel workbook, one value (or one PDF file extraction) in every row of the the same colum (i. e. Value 1 pasted in the cell A1, value 2 pasted on the cell A2 and so…).

Does anybody have an idea on how can i do this?.

Thanks for your help guys.

FOR EACH (item) in Directory.GetFiles("X:\yourfilepath") - Index : rowIndexVariable

  1. Read line from pdf > PdfOutputvariable (string)
  2. Write Cell Activity : PdfOutputvariable
    “A” (1+rowIndexVariable).ToString
1 Like

Hi! Thank you for the solution @TastyToast.

I’ve tried that, but I’m getting this exception:

System.IndexOutOfRangeException: Index was outside the bounds of the array

Do you know why?

Thank you!

1 Like

The main reason is: you try to access an array element that does not exists - you have reached the end and count beyond your array element.

There can be many reasons. More insight in the workflow would be helpful :slight_smile:

My guess is yout do [count = count + 1] and then put your array element in the DataTable.

do it reverse: arrayelement(count) > write to excel > count = count + 1
You can try to debug it with UiPath fantastic debug options, Good training also. With that you find the cause in no time :slight_smile:

Thank you so much for your reply!

What I’m trying to achieve is to scrape specific data from different pdf files and then write that range in an specific cell in an already existing excel file (this scrape process will complete an excel file to become a database).

Could you please explain what do you mean with this action? arrayelement(count)
What activities do I need for this?

Thank you again!

The error message you postet indicated that you work with an array and run an index-counter through it. arrayelement(count)

I made a proof of concept that might help.
It adds new data to the excel sheet dynamically at the end and expands your data to a “Database”

All you need to do is get all PDFs into an array and do your scraping in the ForEach Loop

AddDataToExcel.zip (7.6 KB)

Hey! Thank you for the example and all your help :slight_smile:

I think I’m almost there, but now I’m getting the next error in the Add to Collection activity:

Thanks again!

Strange error …never had that but google surely can help