Self Resolved:Write CellXアクティビティで2行インクリメントしてセルに書き込みをしたい

こんにちは。UiPath Studio EnterPrise版23.4.2ユーザの初心者です。

Fow Each Rowアクティビティの中にWrite CellXアクティビティを配置しました。
2行インクリメントしてセルに書き込みをしたいため、Write CellXアクティビティの書き込む場所に
Excel.Sheet(“Sheet1”).Cell(“A” + (row+2).ToString)
と記入しました。rowはDataRowの暗黙変数です。

ところが、
演算子+はDataRow及びIntegerに対して定義されていません。
というエラーが出ました。
どう記述を修正すれば良いでしょうか?
Write Cell

Hi @gorby
Try this Syntax:

"Excel.Sheet("Sheet1").Cell("A"+ ((row+2).ToString))"

And it seems like you have created a same post and raised the query there itself. If you query is the same try combining the post.
https://forum.uipath.com/t/removed/570985?u=parvathy

Hope it helps!!

Hi As I modified the title , another thread will be removed shortly.
Thus, I do not feel the necessity of combining.

“Excel.Sheet(“Sheet1”).Cell(“A”+ ((row+2).ToString))”

Hi Your suggested advice raised the same error message…
Hope to see another advice!

Can I know what are you storing in the row @gorby

Regards

Hi @gorby

Show the full code which you are developing the above activities of write cell activities then we can understand what you are doing.

No more than String type data like {“ascf”,“sdfg”,“12/1/2023”}

I cannot show you full code because I am making this code for our customer.

Okay not a problem what is the activity that you are using above the write cell activity.

If you are using the for each excel row activity.
If you want to enter the data in the each excel in one column.
In Write cell activity in range you can give like this CurrentRow.byField(“Column name”)

If you want to give directly like Excel.Sheet("Sheet1).Cell(“A”+(row+2).toString).
In the above expression the row has to be in string format.

Hope you understand!!

In order to let you understand my code, I made a mock workflow.
Hope it helps.

@gorby

It worked for me i hope it also works for you, In your excel you have headers enable headers in for each excel row

Excel.Sheet(“Sheet2”).Cell(“C”+CurrentRow.RowCount.ToString)

Hi @gorby
Try this:

Excel.Sheet("Sheet1").Cell("A"+((CurrentRow.ToString.Count).ToString))

Regards

I think you have done many things not properly.

=> First Use excel file activity and pass the Excel path to it.
=> Inside use excel file activity insert the for each excel row activity to iterate the each row in excel.
=> After for each insert the If condition to check the condition, In then block insert the write cell activity.

This was the proper sequence.

If you are not satisfied with it then, let me know your requirement.

Hope you understand!!

Your advice does not meet my requirement because I want to iterate dt(NOT excel file).
Instead, I managed to find correct answer by myself as follows.

Excel.Sheet(“Sheet2”).Cell(“C”+(dt.rows.IndexOf(row)+6).ToString)

+6 should be checked because IndexOf(row) shows dt row number. We have to convert dt row number to Excel sheet row number.

Your advice does not meet my requirement because your understanding totally differs from mine.

If you check my uploaded mock image carefully,you can easily understand I want to iterate dt .(Not Excel file)
You are so careless guy!!
Since you are repeating mistaker, pls be noted if you commit mistake again,you are NOT qualified to give advice for me.

If you want to advice others as well as you are really UiPath Robot Master, pls think what questioner really wants to know first.
I have no spare time to listen to your confusing and careless advice.

It is important to reflect on what you did so you can do better next time…

Instead, I managed to find correct answer by myself as follows in the end.

Excel.Sheet(“Sheet2”).Cell(“C”+(dt.rows.IndexOf(row)+6).ToString)

+6 should be checked because IndexOf(row) shows dt row number. We have to convert dt row number to Excel sheet row number.

Your advice does not meet my requirement because I want to iterate dt(NOT excel file).
Instead, I managed to find correct answer by myself as follows.

Excel.Sheet(“Sheet2”).Cell(“C”+(dt.rows.IndexOf(row)+6).ToString)

+6 should be checked because IndexOf(row) shows dt row number. We have to convert dt row number to Excel sheet row number…

Am I correct if I think your suggested syntax aims to count number of row in dt?
if so, your understanding differs from mine…

@gorby

I don’t write the Excel data in the datatable. I simply take for each row in excel and write the data in the write cell.

No, the problem is you iterate excel file.
If you understand my requirement, no need to iterate Excel file.

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