How to create new empty row

Hi there,
I was trying to enhance my ui project as I was about to paste new empty row below each of my existing row.
For example,
Capture
This is how my current excel file looks like.

Capture1
This is what I wish to paste out using uipath command.

Can anyone suggest or give me some advice on this?
I appreciate any assistance from you. Thanks in advance.

Compare Two Files.xaml (30.9 KB)

1 Like

Hi
hope these steps would help you resolve this
–use excel application scope and pass the file path as input
–inside the scope use read range activity and get the output with a variable of type datatable named dt
–now use a BUILD DATATABLE ACITIVIY and create same column structure of this excel and get the output with a variable of type datatable named finaldt
–now use a CLEAR DATATABLE activity and mention the input as finaldt
–now use FOR EACH ROW activity and mention the input as dt
–inside the loop use ADD DATA ROW activity and in the arrayrow property mention as row.ItemArrayand in the datatable mention as finaldt
–followed by that use counter = 0 in a assign activity where counter is a variable of type int32
–inside this loop next use a while loop like this counter < 4 as condition
inside that while loop use ADD DATA ROW activity and mention like this in datarow property
finaldt.NewRow and in datatable mention as finaldt
–this will add 4 empty rows
–finally use a write range activity next to this FOR EACH ROW activity and pass finaldt as input

Cheers @yushinchan

Hi what you can do is
Read the excel file with excel application scope and read range
The Datatable variable is the output ex:DT1
Now create another Datatable variable ex:DT2
Copy the data fromDT1 to DT2
Assign
DT2 = DT1.copy
Now use for each row of DT2
Inside body of for each row
Use
Get row item , for any column value and output as variable ex: Var1
Now use if condition
If
String.isnullorempty(var1)
Then
Use assign activity
Create a int variable for index number ex:Rownum
Rownum = DT2.rows.index(row)
Now below to that
Add data row activity
In the properties of RowArray give as
DT1(Rownum).newrow

Now.outside the for each row loop
You can use excel application scope to write entire DT1 into a new excel file with added rows

Hi @Palaniyappan
I have tried your suggested steps but my workflow were stuck and seems like doesn’t work.
Any steps do I need to modify to run it smoothly?
Attaching my xaml
Compare Two Files.xaml (40.0 KB)

1 Like

Hi @vinay_reddy

Capture

For this add data row activity, I have input the dt1(Rownum).newrow as the properties for ArrayRow. But it turns up with the error. What can I do for this?

@yushinchan

In ArrayRow, you have to pass like below.

        {"Column 1","Column 2",......."Column N"}

Hi all,

Yes, that is good to use the activity itself but how to do what the ‘Add Data Row’ activity does using code only?

Regards,