Hi all,
Excel file has few mail id’s, if the mail id contains aaa@gmail.com
these mails needs to removed from the excel file.
Tried using if condition, it’s not working. Please guide me on this.
Hi all,
Excel file has few mail id’s, if the mail id contains aaa@gmail.com
these mails needs to removed from the excel file.
Tried using if condition, it’s not working. Please guide me on this.
-Use the “Read Range” activity to read the data from the Excel file into a DataTable.
Hi @lakshmi.mp
Read Range: ExcelSheet -> DataTable
filteredDataTable = dataTable.Select("EmailColumn <> 'aaa@gmail.com'").CopyToDataTable()
Write Range: filteredDataTable -> ExcelSheet
Hope it helps!!
@Dilli_Reddy , mail id is not fixed it will be changing. Domain name is fixed.
@gmail.com
is fixed
If any mail id’s ends with
@gmail.com
this has to be removed from the excel.
In this case what to do…
Hi @lakshmi.mp
Try this:
Dim filteredRows = dt.AsEnumerable().Where(Function(row) Not row.Field(Of String)("EmailColumn").EndsWith("@gmail.com")).CopyToDataTable()
→ Use Write Range Workbook to write filteredRows.
filteredRows is of DataType System.Data.DataTablr.
Hope it helps!!
can you provide which mail ids you need to remove like on what basis , is there any common values in that column
dtExcelData = (From row In dtExcelData.AsEnumerable()
Where Not row.Field(Of String)("EmailAddress").Equals("aaa@gmail.com")
Select row).CopyToDataTable()
@Shiva_Nikhil
Mail id’s needs to be removed
Example:
acv@gmail.com
abc@gmail.com
xyrt@gmail.com
sdfg@gmail.com
Please go through these mail id’s
Hi you can use below steps:
Use the “Read Range” activity to read the Excel file and store the data in a DataTable variable.
Use the “For Each Row in Datatable” activity to loop through each row in the DataTable.
Inside the loop, add an “If” activity:
row("Column_Name").ToString <> "aaa@gmail.com"
Inside the “If” activity, use the “Remove Data Row” activity to remove the current row if the condition is not met.
After the loop, use the “Write Range” activity to write the modified DataTable back to the Excel file.
or you can use below query
YourDataTable = YourDataTable.AsEnumerable().Where(Function(row) Not row.Field(Of String)(“Column_Name”).Equals(“aaa@gmail.com”)).CopyToDataTable()
can you try this once
dt.AsEnumerable.Where(Function(a) Not a("EmailColumn").tostring.EndsWith("@gmail.com")).CopyToDataTable
@Shiva_Nikhil , able to remove the mail id’s as expected.
Thanks for helping…
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.