I have an Excel file with values like in the screenshot attached below.
If a row in the column “ERP Code” is blank, I need to add remark as “XK01” in the column “Remarks”. Else if there’s value in a row, add remark as “XK02”
“Required Remarks” is added for your understanding.
How do I achieve this ?
Kindly attach an xaml file for my better understanding.
You want to use the excel activities, right. Then try the below workflow,
→ Use the Excel Process scope activity, inside of it insert the Use excel file activity.
→ Give the Path of the excel file in the Use excel file activity.
→ Inside Use excel file activity insert the For each excel row activity. Output is CurrentRow.
→ Inside for each insert the If activity and give the below condition,
→ Inside Then block insert the Write cell activity and give the “XK01” in what to write field and give CurrentRow.ByField(“Required Remarks”) in where to write field.
→ Inside else block insert the Write cell activity and give the “XK02” in what to write field and give CurrentRow.ByField(“Required Remarks”) in where to write field.
Check the below workflow for better understanding,
Is there any alternate for CurrentRow.ByField(“Remarks”) ? Because I get an error stating “ByField is not a member of System.Data.DataRow”. I’m using an older version of studio. Couldn’t update it because of policy issues.
Please check with it if you are using workbook activities
Use the Read Range Workbook activity to read the Excel file and store the data in a DataTable variable.
Use the For Each Row activity to loop through each row in the DataTable.
In for Each Row in Data Table properties create a variable (Ex: CurrentRowIndex) in Index
Inside For Each Row in Data Table
Use If activity to check if the “ERP Code” column is empty for the current row
Provide the following Expression
String.IsNullOrEmpty(CurrentRow(“ERP Code”).ToString)
In then
Add Write Cell activity
In cell: “C”+(CurrrentrowIndex+2).tostring
Cell Content: “XK01”