how to write continuously in a text file inside for each row

i have for each row inside a excel and if it meets certain criteria i am storing the cell value in string array
now when i try to write that string array in a text file it is writing only the last value
my expected result should be the value continuously written in textfile
thanks

  • Create a variable with the name strOutput (or whatever name you want) of the type ‘String’ in the variables manager

  • Drag in an assign activity and put in the For Each Row:

strOutput = strOutput + row.item(“ColumnName”).ToString + " "

where ColumnName is the name of the column you want the data from. You can put the assign in an if, if you want to do criteriaes.

2 Likes

Write this into your file to do it in one go:

String.Join(System.Environment.NewLine, myArray)

If you want to add a line at each iteration, use AppendLine activity.

https://docs.uipath.com/activities/docs/append-line

1 Like

can i use this in a excel?like writing value in a excel

im having a string array
if im using a write range activity it is asking for datattable as input
so from ur example i want to write it into a excel u diddnt mention any datatable?

While iterating, assign the value like row.items(“columname”)=String.Join(System.Environment.NewLine, myArray)

Then the input to the write range activity ll b the datatable same as the one you used for iterating

1 Like

sorry but I don’t understant what you want to do. I thought you wanted to write an array of strings into a text file.

What do you want to write into excel? If you want to write all string into a single cell, change the separator

String.Join(", ", myArray)

i want to write strings values to excelcells not text file @msan