How to check excel row for data and add in first column

hi ,

i have an excel data is already there what i need to do is need to add A in first column if there is data in row
sample excel

how to work on this

2 Likes

You can do it in various way :

  1. Excel scope
  2. read range function → var (system.data.dataTable)
  3. for each row …
    3.1) If … then add …

Good luck

3 Likes
3 Likes

@manoj2500,

Below are the Steps to Follow :

1.Take Excel Application scope and Give the path of Excel
2. Read Range : Sheet Name as DATA and Range as “” (blank) - This will read the complete sheet and you will get a DataTable as Output say : dtData
3. Take a For each of DataTable
4. INside the foreach - row :
5.Take an IF and write your check . e.g : to check if Name column has value we write String.IsNullOrEmpty( row(“NAME”)) - Any condition - Here I am checking if Name Column is null or Empty:
6. Now for the true and False branch - you can specify what you have to do … lets says … you want to assign value to ACTION
7. we take an assign activty and write row(“ACTION”)=“NewVAlue”.

–
Mukesh

3 Likes

Hi ,
write row activity is not there i have used excel application
and write range

but its typing A only in A2 how i get it to other rows

2 Likes

okay , so inside the for each loop - you have to keep a counter.

  1. Take an integer variable say int counter and assign its default value as 2 as first row is header.
  2. Inside the For each row - in the write cell : you should write “A”+intcounter.toString - This will write the value in cell A2 first time.
    3.Now we increment thevalue of Counter - Take an assign and intCounter = intCounter+1 -This will make the int Counter to 3 , So next time when we are in loop - it will writein A3.

–
Mukesh

3 Likes

hi

its changing the values at A2 only

2 Likes

Please verify the scope of Vcount Variable .

It should NOT be the Excel application scope … Increase the Scope of the variable to complete xaml file.

Also , the “A”+vcount.toString Should come in the Cell position where you have written A2.refer the below screenshot

image
–
Mukesh

3 Likes

IT WORKED it was mine mistake

1 Like

@mukeshkala hi
if i 80 to 90 column names and i need to check for the same then how we need to do

1 Like

For 80 Columns - This Approach can work provided the time constraint.

Also , we can think of using Orchestrator Queues.

Another approach could be First Getting all the Records in DataTable and then Inside DataTable only - we apply filter and update the column in DataTable Itself. Once completed - Paste the Datatable at the end in Excel.

–
Mukesh

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