Thhere is a workbook where starting data starts with numbers and rest is starting with albhabets. I need to delete the data(rows) that starts with Numbers
-
Excel Application Scope:
- Input: Path to your Excel workbook
- Output: Workbook Application variable (let’s call it “excelApp”)
-
Read Range:
- Excel Application Scope: excelApp
- SheetName: Name of the sheet you want to work with
- Output: DataTable variable (let’s call it “data”)
-
For Each Row (row in data):
- Use a condition to identify rows you want to delete.
For example: If row should be deleted,- Add Data Row: DataRow: row, DataTable: data, RowState: Deleted
- Use a condition to identify rows you want to delete.
-
For Each Row (row in data.Rows):
- Remove Data Row:
- DataTable: data
- DataRow: row
(Loop in reverse order to avoid index issues)
- Remove Data Row:
-
Write Range:
- Excel Application Scope: excelApp
- SheetName: Same sheet name
- DataTable: data
-
Close Workbook:
- Excel Application Scope: excelApp
- Save Workbook: True (if you want to save changes)
Hope it helps
@ayushi_jain3 - Try the Workflow I attached.
DeleteRowsWithNumericData.zip (17,8 KB)
It uses the Insert/Delete Rows activity:
The Target File looks like this:
And becomes this after the run:
Hope this helps!
Actually, this is for Workbook and not excel. So the challenge is that I cannot Excel activities over here which needs Excel application Scope
You can try like this… @ayushi_jain3
1.Take for each row in data table and pass the
data table variable
2. Inside loop take if activity and pass condition
like this
If = Regex.Ismatch(CurrentRow(“ColumnName).ToString,”[0-9]+")
Then - you can remove the rows
Else - keep as it is blank
For the reference you can see the screenshot
It will remove the Row’s which having the digits
two ways
Directly on excel
- For each row in excel activity
- If condition with
System.Text.RegularExpressions.Regex.IsMatch(currentrow.ByField("ColumnName").StringValue,"^\d.*")
- On the then side use delete rows activity with specific row and give position value as the index variable value from the for loop properties
From Datatable
- Read the data into datatable dt
dt.AsEnumerable.Where(function(x) Not System.Text.RegularExpressions.Regex.IsMatch(x("ColumnName").Value,"^\d.*")).CopyToDatatable
- this gives the required rows only- use write datatable to write data to excel
cheers
Thanks @Anil_G , Tried the second solution and it worked
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.