How to copy to a data table based on the value


#1

@arivu96

Hi,
I have an excel in which i want to copy the desired data , in one column there is policy number and their respective data , but i need to select only the particular data into the datatable , but i am unable to perform it

please find the attachments vjdj.xlsx (8.1 KB)
vjdj.xaml (6.7 KB)


#2

Hi @lalithya14,
Use read range activity to get the data into datatable.

After that use linq concept to split the data.

(From p in dt.Select() Select p("policy number"))ToArray.CopyToDataTable()

Else you can use the same datatable do for each row get the same value
Convert.tostring(Row("policy number"))

Regards,
Arivu.


#3

its not working , can u send me the xaml file , i want to select the entire data of the "502-2272826"rows into the another data table

please find the previous attachment of the xaml file

i want the output as sheet 2 , and suggest me the related solutionvjdj.xlsx (8.9 KB)
for that


#4

@lalithya14

Since your excel sheet is not having the headers you can do like this

dt2=(From p in dt1.Select
where string.Join(",",p.Item.Array).Contains("Required Policy number")
Select p).ToArray.CopyToDataTable

Required policy number as per your excel sheet is 502-2272826

Regards,
Mahesh


#5

i am not getting the output can u send me the .xaml file the want the entire data of that policy number into another data table ,
sorry i am not able to implement the logic , can u please provide the .xaml file @MAHESH1


#6

@lalithya14

Just create one Datatable dt2
then assign the Query to dt2

Then use write Range activity to write in excel sheet
where you are facing issue .

Regards,
Mahesh


#7

its working thanks for ur support