For each row - Excel app issue

When having a “For each row” activity inside of an Excel Application Scope activity. It is taking 9 minutes to write 4 columns and 200 rows of data. Does anyone know why it is taking this long? Please note, there is an “if” statement inside the “For each row” activity.

Hi @mojisola.ayanwale

Are u using write cell activitiy for this for writing data into the column

Regards

Nived N :robot:

Hi @mojisola.ayanwale ,

Please check:

or

It might helps you

Best regards,
Marius

Hi Nived, yes I am using the write cell activity.

Hi @mojisola.ayanwale

Instead of write cell activitiy

Try assigning values to the each column of row directly

row(ColumnName)= value

Then after exiting from loop

Use write range to write the datatable to excel

I think it would be but faster

Regards

Nived N :robot::robot:

Happy Automation :relaxed::relaxed:

Hi Nived, what I am doing is “assigning” then writing cell. When I do write range I get an error:
image

Hi @mojisola.ayanwale

In write range u can write only datatable

Not the string

I can’t do that because for many of the columns I had to do a substring. when I try to change the variables to “data tables” I get an error. Any other suggestion?

@mojisola.ayanwale - You can’t perform Write Range without Inputting the datatable…Output22 is not datatable so it is throwing an error. If you dont have any output datatable then try write cell.

What is the value Output22 is holding?

I am doing write cell and it is working; however, it is taking a very long time to write to the excel sheet. It takes 9 minutes to write a little less than 200 rows.

What I understand you should read excel to dt variable or create dt variable.
Then for each row of this dt variable you should edit values like row(0)= “sth” with simple assign activity. Of course you can use if statement but for the whole for each row you shouldn’t use any excel activities.
Then after editing this data table variable u can just simply save it to excel with write range under for each row (I suggest workbook activity rather then excel app scope).

Thank you so much! This worked!

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