How to read 1 row or multiple rows from one excel sheet and write it in another excel sheet
- Use excel application scope activity
- To read excel sheet us read range activity
- Use write range activity to write into excel sheet
see im attaching one sheet, in that excel sheet C3 and C5, I dont have data and i need to fetch data only Row 3 and Row 5 complete row data to another sheet i need to fill
@sundeeperanti asiest and most understandable way to code is to simply use a for reach row loop and check if the data in column CC is blank. If it is blank, import the row to a second datatable. After the for each row loop is completed, your second datatable will contain copies of all the rows that had blank data, so you can write it into the new sheet using a write range activity.
- Read Range activity on excel sheet like you show in example // i’ll call this dt1
- Assign activity - Assign dt2 = dt1.clone // This copies the structure/schema of dt1 into another datatable variable called dt2
- For each row in dt1
3a. If String.IsNullOrWhiteSpace(row.item(“CC”).ToString)
3b. Then (true side) Import row - see this post for pics and explanation on how to do this with Invoke Method activity: Copy Row from one DataTable to another - #2 by UiRobot
3c. Else (false side) - leave false side blank - Write range activity - write dt2 into your new sheet
Hi Dave,
i tired it, i am able to get this, please help me any code for it.
@sundeeperanti - i have written it out step-by-step in pseudocode, which part specifically are you having trouble with?
I think it’s a good idea for you to try it for yourself to help with the learning aspect, but I will gladly help if you are having trouble with something still after trying it for yourself
Yes Dave,
i tired as you mentioned above pseudo code, but for me not coming correct output and please share any xaml for it.
Sure thing, if you upload your .xaml I can give you some pointers as to where your bugs are found
You can use a filter datatable activity to remove rows where column “CC” is empty.