How to extract the data in Excel using linq query

Hi Team,

I have one excel and need to check if F1001 data is available in column A.if data is available in Excel i want to extract the column B values using UiPath linq query

Hi @Baby123

Try this

dtOutput = (From row In dtInput.AsEnumerable()
                   Where row.Field(Of String)("ColumnA") = "F1001"
                   Select dtInput.Clone().Rows.Add(row.ItemArray)).CopyToDataTable()

Cheers!!

Hi @lrtetala ,

If F1001 is available in A3 cell I want extract the B3 cell as a string. Using. Linq query in UiPath

@Baby123

Can you please provide some sample input and output

Hi @Baby123

Try this. In the meanwhile provide the sample input and expected output

Output = (From row In dt.AsEnumerable()
              Where row.Field(Of String)("ColumnA") = "F1001"
              Select row.Field(Of String)("ColumnB")).FirstOrDefault()

Regards

![
This is my input file. If 42200 is available in A6 cell need to extract DE01 data in B6 cell .
Extracted B6 values stored in string variables

@Baby123

Try this

(From row In DT.AsEnumerable()
             Where row.Field(Of String)("GL Code") = "42200" 
             Select row.Field(Of String)("Department Code")).FirstOrDefault()

Hi @Baby123

=> Read Range Workbook
image
Output-> dt

=> Use below syntax in Assign:

Value = (From row In dt.AsEnumerable()
              Where row.Field(Of String)("GL Code") = "42200"
              Select row.Field(Of String)("Department Code")).FirstOrDefault()

Regards

I was tried with above syntax but getting error like this.

Kindly suggest

Hi @Baby123

Can you share the screenshot of the workflow, check if whether any value is empty.

If possible can you please share the excel file with dummy data.

Regards

Hi @Baby123

Check whether you have spaces in your column names. Try to copy them from excel and paste it there and check once.

Also check if you passed the correct sheetname @Baby123 as your datatable variable is null value
Regards

@Baby123

The datatable variable is getting to be null. Please check the Sheet name, excel file name and Datatable variable.

Thank You @lrtetala & @vrdabberu
I was forgot to pass the variable in Read range.

Thanks It’s working fine.

1 Like

Hi @Baby123

Since your query is resolved, please mark my post as solution to close the loop or if you have any questions I’m happy to help.

Regards

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