How to insert data dynamically into column in excel

Hi,

I have 1 excel having columns A B C
and having intcap=10; and strname=som;

I want to insert name in 10 rows of c column initially(usually starts from 2nd row index(c2)
and next time intcap=5 then insert name from 11 th row onwards

can anyone help me here…
thanks in advance

1 Like

Hi

It looks like you are trying to add Datarow to excel
after 10 row and then from 11

If that’s the case

  1. Read the datatable with read range activity and keep the output as datatable named dt

  2. Now use a assign activity like this

Counter = 0

Where counter is a variable of type int32

  1. Then use a WHILE Loop and mention the condition as counter < 10

Inside the loop use a Add Datarow activity and pass the value as {string.Empty, String.Empty, “your value”} in ArrayRow property and mention the datatable as dt

Next to this add Datarow use a assign activity like this

Counter = Counter + 1

  1. Next time when u try to add any rows with ADD DATATOW activity it gets added from 11 row only

Hope this helps

Cheers @panguluri_saritha

1 Like

Hello @panguluri_saritha

  1. Read Range: Read the Excel file into a DataTable.

  2. Assign: Assign the starting row based on the value of intcap. For example, if intcap = 10, assign startingRow = 2; if intcap = 5, assign startingRow = 11.

  3. For Each (index) in Range: Loop based on the desired number of rows (e.g., 10 times if intcap = 10, or 5 times if intcap = 5).

    a. Assign rowIndex = startingRow + index.

    b. Write Cell: Write the name into the “C” column for the rowIndex.

  4. Write Range: Write the updated DataTable back to the Excel file to save the changes.

Thanks & Cheers!!!

Hi @panguluri_saritha

for your processs you can try this xaml it will work surly

xaml :-Insert Data Dynamically.zip (2.6 KB)

Let me know its working or not for you

Cheers…!
@panguluri_saritha

Hi @Praveen_Mudhiraj ,
unfortunately I am not able to open this xaml , some template issues version issues facing, client studio is 2021 here

No worries , i will share the screenshots you can do same way for your output

Build data table
image

at the end you can use the write range work book activity for your out put

@panguluri_saritha

Let me know its working or not for you

Hi @Praveen_Mudhiraj ,

thank you for your time, but eg intcap=10; is coming from queue, so there is no scope to loop i think,

i have name=ram, capacity=5; coming from queue
excel having some columns A B C d

ist queue item -write into orginal excel
for eg d column

d2 cell ram
d3 ram
d4 ram
d5 ram
d6 ram

and for 2nd queue item
capacity 2 , name=som,
then write d7 som
d8 som

@panguluri_saritha
Yeah with queues wont require the loop…
when ever you get queue item suppose in_cap=10 and name =som

1.Take assign activtiy
counter= 0
2. Take while Activity and use the conditions
count<in_transaction.SpecificContent(“”).tostring
in side the loop use the add row activity and assign activity and pass like this

So on next Transaction it will replace the count value to 0 and again flow will be same and at the end if all the transactions over use the Write Range Workbook to display out

Hi @Praveen_Mudhiraj ,
okay thank you , I will try this logic.

but I want to pass dynamic range in write range activity here
any suggestion

“but I want to pass dynamic range in write range activity” Can you elaborate more this I’m not getting…

@panguluri_saritha

at 1st queue item : if intcap=4 insert data to the excel
d2 ram
d3 ram
d4 ram
d5 ram

at 2nd queue if incap=3, name=som

in above excel

d6 =som
d7=som
d8=som

like that I need to insert in d column with dynamic cell index
@Praveen_Mudhiraj

HI @panguluri_saritha

xaml:- RFW_Dynamic data.zip (956.5 KB)

For me its working exactly as your out only …you can go throw this xaml if not go with this steps

if your doing in Reframework

  1. In Initialization you can create Build datatable and pass in the for each row and in the loop use the Add Queue Item …so it will add the items to queue like in_cap and name

Note:- create one more datatable for out put like name A,B,C,D COLUMNS

2.In process you can do this as it is

Note:- For columns A,B,C,D datatable based on aruguments you can cal in process and keep argument type =in/out

3.In the End Process

you can use the write range workbook And pass the dt

output :slight_smile:

image

@Praveen_Mudhiraj
Thank you for your patience and time

1 Like

Than you for your time and quick response
@Palaniyappan

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