I have an Excel sheet with various data, and I need to focus on a specific column (Employee Code). If any cell in this column is blank, I need to fill it with the appropriate employee code. However, if the cell already has a value, no changes should be made. how to achieve this
You can go through the foreach data row loop and check by if condition inside for loop action
That if currentrow(column) is null or not
If null assign the value else add log and go for next
The option is that you can use linq query also.
Hi @Bharati_Mane
Use if condition String.IsNullOrEmpty(row(“Employee Code”).ToString.Trim)
Then:
- Assign:
row("Employee Code") = "EMP" & (rowIndex + 1).ToString
Else
No action (leave the cell as is)
Please share more details like sample input / output. Also what do you mean by
Welcome to the community
on hight level what you can do is loop on your excel
and then if condition isnide it to check for blank
on then side use lookup from the datatable where you have empployee data and get info and then write to the cell using currentrow
cheers
Hi, @Bharati_Mane
Fallow the steps below. If I helped you, please market it as solved.
Step 1:
Excel Application Scope: Open the Excel file.
Step 2:
Read Range: Read the spreadsheet and store the data in dt_Employees.
Step 3:
For Each Row in DataTable: Iterate over dt_Employees.
Step 4:
If: Check if the “EmployeeID” cell is empty:
String.IsNullOrEmpty(row(“EmployeeID”).ToString.Trim)
Step 5:
Assign: If empty, assign the appropriate value:
row(“EmployeeID”) = appropriateValue
Step 6:
Write Range: Write the updated table back to Excel
Hello @Bharati_Mane
You could read the file using “Read Range Workbook” activity and then iterate the rows using “For Each Row in Data Table”.
Then simply check if the row is empty using
If String.IsNullOrEmpty(CurrentRow("Employee Code").ToString)
Regards
Soren
First, read the Excel file and loop through each row in the data table.
Use an If condition to check whether the value in the “Employee Code” column is empty by using row(“Employee Code”).ToString.Trim.Equals(“”). If the condition is met, assign the desired value to that cell using Assign activity, like row(“Employee Code”) = [Value].
Once the loop is complete, write the updated data back to the Excel sheet using the Write Range activity.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.