Question about Data Table and Add Data Row Acitivity

Hello, I’m Trying to make a project to read text files from a folder, check see if the files Contain word “Invoice” if yes Copy the Invoice number and the file Name from the folder and put them in a data table then extract them to a excel file.

I think I got most of them flow correct but there is an error I cannot resolve,
when I’m trying to Add Data Row, I’m getting this error:

and here is my DataTable setting
The image shows a "Build Data Table" window with two columns labeled "FileName" and "InvoiceNumber," both of type String, with one row of data containing the word "text" under the "FileName" column. (Captioned by AI)

what exactly I’m doing wrong and how to fix it ?

any help would be appreciated!

Thank you !

Hi @Pour_Medi

Try updating UiPath.System.Activities dependency.

Or try the below syntax:

New Object() {fileList, InvoiceNumber}

Hope it helps!!

Hi @Pour_Medi

Try the below one in arrayrow field,

{FileList.toString, InvoiceNumber.toString}

Hope it helps!!

Hi ,so I did that , it did not fix the issue however by adding .ToString after each of the VariableNames in Array the error was gone .

image

now I have another issue that I’m trying to save that info inside a excel sheet but using Write Range WorkBook doesn’t generate a result file

image

What is the error you are getting… @Pour_Medi when executing the write range workbook activity

In write range workbook activity give the path of the excel file, give the sheet name and pass the InvoiceFiles datatable variable to it. Check the add headers option in properties.

Hope it helps!!

I’m getting no Errors, it’s just not generating the "Result.xlsx file for me

Can you share a screenshot of write range workbook activity, if possible better to share the screenshot of your flow… @Pour_Medi

sure , here is the flow for the project :slight_smile:
(I do apologize in advance for scratching the file destination since it Contains CPI)


Don’t use the write range workbook activity inside the for each activity. You should place it outside the for each activity.

Then try it will work. When you place inside for each it overwrite the data in the excel everytime. If you place at outside of for each it will write all the data in InvoiceFiles to Excel.

Hope it helps!!

1 Like

Thank you that worked out! it generated the file however
this is what it shows inside:

image

1 Like

FileList is the array of string variable right, that’s why it was printing like that… @Pour_Medi

The variables you are passing in the add data row should be in string format.

Hope you understand!!

1 Like

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